text
stringlengths 2
104M
| meta
dict |
---|---|
// C > Functions > Students Marks Sum
// An easy challenge on pointers
//
// https://www.hackerrank.com/challenges/students-marks-sum/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
// (skeliton_head) ----------------------------------------------------------------------
//Complete the following function.
int marks_summation(int* marks, int number_of_students, char gender)
{
int sum = 0;
for (int i = gender == 'b' ? 0 : 1; i < number_of_students; i += 2)
{
sum += marks[i];
}
return sum;
}
// (skeliton_tail) ----------------------------------------------------------------------
int main() {
int number_of_students;
char gender;
int sum;
scanf("%d", &number_of_students);
int *marks = (int *) malloc(number_of_students * sizeof (int));
for (int student = 0; student < number_of_students; student++) {
scanf("%d", (marks + student));
}
scanf(" %c", &gender);
sum = marks_summation(marks, number_of_students, gender);
printf("%d", sum);
free(marks);
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Functions > Calculate the Nth term
// Use recursion to solve this challenge.
//
// https://www.hackerrank.com/challenges/recursion-in-c/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
//Complete the following function.
int find_nth_term(int n, int a, int b, int c) {
//Write your code here.
if (n == 3) return c;
if (n == 2) return b;
if (n <= 1) return a;
return find_nth_term(n - 1, a, b, c) +
find_nth_term(n - 2, a, b, c) +
find_nth_term(n - 3, a, b, c);
}
int main() {
int n, a, b, c;
scanf("%d %d %d %d", &n, &a, &b, &c);
int ans = find_nth_term(n, a, b, c);
printf("%d", ans);
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [C](https://www.hackerrank.com/domains/c)
#### [Functions](https://www.hackerrank.com/domains/c/c-functions)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Calculate the Nth term](https://www.hackerrank.com/challenges/recursion-in-c)|Use recursion to solve this challenge.|[C](recursion-in-c.c)|Easy
[Students Marks Sum](https://www.hackerrank.com/challenges/students-marks-sum)|An easy challenge on pointers|[C](students-marks-sum.c)|Easy
[Sorting Array of Strings](https://www.hackerrank.com/challenges/sorting-array-of-strings)||[C](sorting-array-of-strings.c)|Hard
[Permutations of Strings](https://www.hackerrank.com/challenges/permutations-of-strings)|Find all permutations of the string array.|[C](permutations-of-strings.c)|Medium
[Variadic functions in C](https://www.hackerrank.com/challenges/variadic-functions-in-c)||[C](variadic-functions-in-c.c)|Medium
[Querying the Document](https://www.hackerrank.com/challenges/querying-the-document)||[C](querying-the-document.c)|Hard
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Conditionals and Loops > Sum of Digits of a Five Digit Number
// to calculate the sum of digits of a five digit number.
//
// https://www.hackerrank.com/challenges/sum-of-digits-of-a-five-digit-number/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n;
scanf("%d", &n);
//Complete the code to calculate the sum of the five digits on n.
int sum = 0;
while (n != 0)
{
sum += n % 10;
n /= 10;
}
printf("%d\n", sum);
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank(conditional-statements-in-c conditional-statements-in-c.c)
add_hackerrank(printing-pattern-2 printing-pattern-2.c)
add_hackerrank(sum-of-digits-of-a-five-digit-number sum-of-digits-of-a-five-digit-number.c)
add_hackerrank(for-loop-in-c for-loop-in-c.c)
add_hackerrank(bitwise-operators-in-c bitwise-operators-in-c.c)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Conditionals and Loops > Bitwise Operators
// Apply everything we've learned in this bitwise operators' challenge.
//
// https://www.hackerrank.com/challenges/bitwise-operators-in-c/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
//Complete the following function.
void calculate_the_maximum(int n, int k)
{
//Write your code here.
int max_and = 0, max_or = 0, max_xor = 0;
for (int a = 1; a < n; ++a)
{
for (int b = a + 1; b <= n; ++b)
{
int x;
x = a & b; if (x < k && x > max_and) max_and = x;
x = a | b; if (x < k && x > max_or) max_or = x;
x = a ^ b; if (x < k && x > max_xor) max_xor = x;
}
}
printf("%d\n", max_and);
printf("%d\n", max_or);
printf("%d\n", max_xor);
}
int main()
{
int n, k;
scanf("%d %d", &n, &k);
calculate_the_maximum(n, k);
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Conditionals and Loops > For Loop in C
// Learn how to use for loop and print the output as per the given conditions
//
// https://www.hackerrank.com/challenges/for-loop-in-c/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
static const char *digits[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
int main()
{
int a, b;
scanf("%d\n%d", &a, &b);
// Complete the code.
for (int i = a; i <= b; ++i)
{
if (i >= 0 && i < 10)
printf("%s\n", digits[i]);
else if (i % 2 == 0)
printf("even\n");
else
printf("odd\n");
}
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Conditionals and Loops > Conditional Statements in C
// Practice using chained conditional statements.
//
// https://www.hackerrank.com/challenges/conditional-statements-in-c/problem
//
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* readline();
int main()
{
char* n_endptr;
char* n_str = readline();
int n = strtol(n_str, &n_endptr, 10);
if (n_endptr == n_str || *n_endptr != '\0') { exit(EXIT_FAILURE); }
// Write Your Code Here
if (n < 10)
{
static const char *digits[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
printf("%s\n", digits[n]);
}
else
{
printf("Greater than 9\n");
}
return 0;
}
char* readline() {
size_t alloc_length = 1024;
size_t data_length = 0;
char* data = malloc(alloc_length);
while (true) {
char* cursor = data + data_length;
char* line = fgets(cursor, alloc_length - data_length, stdin);
if (!line) { break; }
data_length += strlen(cursor);
if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') { break; }
size_t new_length = alloc_length << 1;
data = realloc(data, new_length);
if (!data) { break; }
alloc_length = new_length;
}
if (data[data_length - 1] == '\n') {
data[data_length - 1] = '\0';
}
data = realloc(data, data_length);
return data;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [C](https://www.hackerrank.com/domains/c)
#### [Conditionals and Loops](https://www.hackerrank.com/domains/c/c-conditionals-and-loops)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Conditional Statements in C](https://www.hackerrank.com/challenges/conditional-statements-in-c)|Practice using chained conditional statements.|[C](conditional-statements-in-c.c)|Easy
[For Loop in C](https://www.hackerrank.com/challenges/for-loop-in-c)|Learn how to use for loop and print the output as per the given conditions|[C](for-loop-in-c.c)|Easy
[Sum of Digits of a Five Digit Number](https://www.hackerrank.com/challenges/sum-of-digits-of-a-five-digit-number)|to calculate the sum of digits of a five digit number.|[C](sum-of-digits-of-a-five-digit-number.c)|Easy
[Bitwise Operators](https://www.hackerrank.com/challenges/bitwise-operators-in-c)|Apply everything we've learned in this bitwise operators' challenge.|[C](bitwise-operators-in-c.c)|Easy
[Printing Pattern using Loops](https://www.hackerrank.com/challenges/printing-pattern-2)||[C](printing-pattern-2.c)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Conditionals and Loops > Printing Pattern using Loops
//
//
// https://www.hackerrank.com/challenges/printing-pattern-2/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define max(x,y) ((x)>(y)?(x):(y))
int main()
{
int i, j;
int n;
scanf("%d", &n);
// Complete the code to print the pattern.
for (i = 0; i < 2 * n - 1; ++i)
{
for (j = 0; j < 2 * n - 1; ++j)
{
printf("%d ", max(abs(n - i - 1) + 1, abs(n - j - 1) + 1));
}
printf("\n");
}
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Arrays and Strings > Digit Frequency
// Given a very large number, count the frequency of each digit from [0-9]
//
// https://www.hackerrank.com/challenges/frequency-of-digits-1/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
char s[1001];
int freq[10] = { 0 };
scanf("%s", s);
for (char *c = s; *c; c++)
{
if (*c >= '0' && *c <= '9')
{
freq[*c - '0']++;
}
}
for (int i = 0; i < 10; i++)
printf("%d ", freq[i]);
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Arrays and Strings > Array Reversal
// Given an array, reverse it.
//
// https://www.hackerrank.com/challenges/reverse-array-c/problem
//
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num, *arr, i;
scanf("%d", &num);
arr = (int*) malloc(num * sizeof(int));
for(i = 0; i < num; i++) {
scanf("%d", arr + i);
}
/* Write the logic to reverse the array. */
for (int i = 0; i < num / 2; ++i)
{
int tmp = arr[i];
arr[i] = arr[num - i - 1];
arr[num - i - 1] = tmp;
}
for(i = 0; i < num; i++)
printf("%d ", *(arr + i));
free(arr);
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Arrays and Strings > Dynamic Array in C
//
//
// https://www.hackerrank.com/challenges/dynamic-array-in-c/problem
//
#include <stdio.h>
#include <stdlib.h>
/*
* This stores the total number of books in each shelf.
*/
int* total_number_of_books;
/*
* This stores the total number of pages in each book of each shelf.
* The rows represent the shelves and the columns represent the books.
*/
int** total_number_of_pages;
// (skeliton_head) ----------------------------------------------------------------------
int main()
{
int total_number_of_shelves;
scanf("%d", &total_number_of_shelves);
int total_number_of_queries;
scanf("%d", &total_number_of_queries);
total_number_of_books = (int *) calloc(sizeof(int), total_number_of_shelves);
total_number_of_pages = (int **) calloc(sizeof(int *), total_number_of_shelves);
while (total_number_of_queries--) {
int type_of_query;
scanf("%d", &type_of_query);
if (type_of_query == 1) {
/*
* Process the query of first type here.
*/
int shelf, pages;
scanf("%d %d", &shelf, &pages);
total_number_of_books[shelf]++;
total_number_of_pages[shelf] = realloc(total_number_of_pages[shelf], sizeof(int *) * total_number_of_books[shelf]);
total_number_of_pages[shelf][total_number_of_books[shelf] - 1] = pages;
// (skeliton_tail) ----------------------------------------------------------------------
} else if (type_of_query == 2) {
int x, y;
scanf("%d %d", &x, &y);
printf("%d\n", *(*(total_number_of_pages + x) + y));
} else {
int x;
scanf("%d", &x);
printf("%d\n", *(total_number_of_books + x));
}
}
if (total_number_of_books) {
free(total_number_of_books);
}
for (int i = 0; i < total_number_of_shelves; i++) {
if (*(total_number_of_pages + i)) {
free(*(total_number_of_pages + i));
}
}
if (total_number_of_pages) {
free(total_number_of_pages);
}
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank(1d-arrays-in-c 1d-arrays-in-c.c)
add_hackerrank(reverse-array-c reverse-array-c.c)
add_hackerrank(printing-tokens- printing-tokens-.c)
add_hackerrank(frequency-of-digits-1 frequency-of-digits-1.c)
add_hackerrank(dynamic-array-in-c dynamic-array-in-c.c)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Arrays and Strings > 1D Arrays in C
// Create an array in c and sum the elements.
//
// https://www.hackerrank.com/challenges/1d-arrays-in-c/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
scanf("%d", &n);
int *arr = (int *) malloc(n * sizeof(int));
for (int i = 0; i < n; ++i)
scanf("%d", &arr[i]);
int sum = 0;
for (int i = 0; i < n; ++i)
sum += arr[i];
printf("%d\n", sum);
free(arr);
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
// C > Arrays and Strings > Printing Tokens
// Given a sentence, print each word in a new line.
//
// https://www.hackerrank.com/challenges/printing-tokens-/problem
//
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
char s[1001];
while (scanf("%s", s) == 1)
{
printf("%s\n", s);
}
return 0;
}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [C](https://www.hackerrank.com/domains/c)
#### [Arrays and Strings](https://www.hackerrank.com/domains/c/c-arrays-and-strings)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[1D Arrays in C](https://www.hackerrank.com/challenges/1d-arrays-in-c)|Create an array in c and sum the elements.|[C](1d-arrays-in-c.c)|Medium
[Array Reversal](https://www.hackerrank.com/challenges/reverse-array-c)|Given an array, reverse it.|[C](reverse-array-c.c)|Medium
[Printing Tokens](https://www.hackerrank.com/challenges/printing-tokens-)|Given a sentence, print each word in a new line.|[C](printing-tokens-.c)|Medium
[Digit Frequency](https://www.hackerrank.com/challenges/frequency-of-digits-1)|Given a very large number, count the frequency of each digit from [0-9]|[C](frequency-of-digits-1.c)|Medium
[Dynamic Array in C](https://www.hackerrank.com/challenges/dynamic-array-in-c)||[C](dynamic-array-in-c.c)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_subdirectory(bash)
add_subdirectory(textpro)
add_subdirectory(arrays-in-bash)
add_subdirectory(grep-sed-awk) | {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Linux Shell](https://www.hackerrank.com/domains/shell)
Bash and command-line tools can be very powerful. Test your Linux scripting skills.
#### [Bash](https://www.hackerrank.com/domains/shell/bash)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Let's Echo](https://www.hackerrank.com/challenges/bash-tutorials-lets-echo)|Let's get started with the simplest Bash command: echo.|[bash](bash/bash-tutorials-lets-echo.sh)|Easy
[Looping and Skipping](https://www.hackerrank.com/challenges/bash-tutorials---looping-and-skipping)|Let's play with for loops, a little more. Let's skip numbers!|[bash](bash/bash-tutorials---looping-and-skipping.sh)|Easy
[A Personalized Echo](https://www.hackerrank.com/challenges/bash-tutorials---a-personalized-echo)|A very gentle on-boarding, to accepting input in Bash.|[bash](bash/bash-tutorials---a-personalized-echo.sh)|Easy
[Looping with Numbers](https://www.hackerrank.com/challenges/bash-tutorials---looping-with-numbers)|Let's experiment with 'For' loops|[bash](bash/bash-tutorials---looping-with-numbers.sh)|Easy
[The World of Numbers](https://www.hackerrank.com/challenges/bash-tutorials---the-world-of-numbers)|Let's move on to playing with numbers in Bash.|[bash](bash/bash-tutorials---the-world-of-numbers.sh)|Easy
[Comparing Numbers](https://www.hackerrank.com/challenges/bash-tutorials---comparing-numbers)|Simple comparisons between numbers: Greater than, less than, equal to.|[bash](bash/bash-tutorials---comparing-numbers.sh)|Easy
[Getting started with conditionals](https://www.hackerrank.com/challenges/bash-tutorials---getting-started-with-conditionals)|-|[bash](bash/bash-tutorials---getting-started-with-conditionals.sh)|Easy
[More on Conditionals](https://www.hackerrank.com/challenges/bash-tutorials---more-on-conditionals)|Three sides of a triangle are provided to you. Is the Triangle Scalene, Equilateral or Isosceles?|[bash](bash/bash-tutorials---more-on-conditionals.sh)|Easy
[Arithmetic Operations](https://www.hackerrank.com/challenges/bash-tutorials---arithmetic-operations)|Math in shell scripts.|[bash](bash/bash-tutorials---arithmetic-operations.sh)|Medium
[Compute the Average](https://www.hackerrank.com/challenges/bash-tutorials---compute-the-average)|Compute the average of a list of N numbers provided to you.|[bash](bash/bash-tutorials---compute-the-average.sh)|Medium
[Functions and Fractals - Recursive Trees - Bash!](https://www.hackerrank.com/challenges/fractal-trees-all)|Create a Fractal Tree|[bash](bash/fractal-trees-all.sh)|Hard
#### [Text Processing](https://www.hackerrank.com/domains/shell/textpro)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Cut #1](https://www.hackerrank.com/challenges/text-processing-cut-1)|Playing with the 'cut' command.|[bash](textpro/text-processing-cut-1.sh)|Easy
[Cut #2](https://www.hackerrank.com/challenges/text-processing-cut-2)|Playing with the 'cut' command.|[bash](textpro/text-processing-cut-2.sh)|Easy
[Cut #3](https://www.hackerrank.com/challenges/text-processing-cut-3)||[bash](textpro/text-processing-cut-3.sh)|Easy
[Cut #4](https://www.hackerrank.com/challenges/text-processing-cut-4)|Playing with the 'cut' command.|[bash](textpro/text-processing-cut-4.sh)|Easy
[Cut #5](https://www.hackerrank.com/challenges/text-processing-cut-5)|Playing with the 'cut' command.|[bash](textpro/text-processing-cut-5.sh)|Easy
[Cut #6](https://www.hackerrank.com/challenges/text-processing-cut-6)|Playing with the 'cut' command.|[bash](textpro/text-processing-cut-6.sh)|Easy
[Cut #7](https://www.hackerrank.com/challenges/text-processing-cut-7)|Playing with the 'cut' command.|[bash](textpro/text-processing-cut-7.sh)|Easy
[Cut #8](https://www.hackerrank.com/challenges/text-processing-cut-8)|Playing with the 'cut' command.|[bash](textpro/text-processing-cut-8.sh)|Easy
[Cut #9](https://www.hackerrank.com/challenges/text-processing-cut-9)|Playing with the 'cut' command and TSV files.|[bash](textpro/text-processing-cut-9.sh)|Easy
[Head of a Text File #1](https://www.hackerrank.com/challenges/text-processing-head-1)|Introducing the 'head' command.|[bash](textpro/text-processing-head-1.sh)|Easy
[Head of a Text File #2](https://www.hackerrank.com/challenges/text-processing-head-2)|The 'head' command.|[bash](textpro/text-processing-head-2.sh)|Easy
[Middle of a Text File](https://www.hackerrank.com/challenges/text-processing-in-linux---the-middle-of-a-text-file)|Display lines from the middle of a text file|[bash](textpro/text-processing-in-linux---the-middle-of-a-text-file.sh)|Easy
[Tail of a Text File #1](https://www.hackerrank.com/challenges/text-processing-tail-1)|Introduction to the 'tail' command.|[bash](textpro/text-processing-tail-1.sh)|Easy
[Tail of a Text File #2](https://www.hackerrank.com/challenges/text-processing-tail-2)|The 'tail' command.|[bash](textpro/text-processing-tail-2.sh)|Easy
['Tr' Command #1](https://www.hackerrank.com/challenges/text-processing-tr-1)|Introduction to the 'tr' command.|[bash](textpro/text-processing-tr-1.sh)|Easy
['Tr' Command #2](https://www.hackerrank.com/challenges/text-processing-tr-2)|Introduction to the 'tr' command.|[bash](textpro/text-processing-tr-2.sh)|Easy
['Tr' Command #3](https://www.hackerrank.com/challenges/text-processing-tr-3)||[bash](textpro/text-processing-tr-3.sh)|Easy
[Sort Command #1](https://www.hackerrank.com/challenges/text-processing-sort-1)|Introducing the 'sort' command in Linux.|[bash](textpro/text-processing-sort-1.sh)|Easy
[Sort Command #2](https://www.hackerrank.com/challenges/text-processing-sort-2)|Introducing the 'sort' command in Linux.|[bash](textpro/text-processing-sort-2.sh)|Easy
[Sort Command #3](https://www.hackerrank.com/challenges/text-processing-sort-3)|Introducing the 'sort' command in Linux.|[bash](textpro/text-processing-sort-3.sh)|Easy
[Sort Command #4](https://www.hackerrank.com/challenges/text-processing-sort-4)|Playing around with the 'sort' command.|[bash](textpro/text-processing-sort-4.sh)|Easy
[Sort Command #5](https://www.hackerrank.com/challenges/text-processing-sort-5)|Playing around with the 'sort' command.|[bash](textpro/text-processing-sort-5.sh)|Easy
['Sort' command #6](https://www.hackerrank.com/challenges/text-processing-sort-6)|Let's learn about the 'sort' command.|[bash](textpro/text-processing-sort-6.sh)|Easy
['Sort' command #7](https://www.hackerrank.com/challenges/text-processing-sort-7)|Let's learn about the 'sort' command.|[bash](textpro/text-processing-sort-7.sh)|Easy
['Uniq' Command #1](https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-1)|Introduction to the 'uniq' command.|[bash](textpro/text-processing-in-linux-the-uniq-command-1.sh)|Easy
['Uniq' Command #2](https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-2)|Introduction to the 'uniq' command.|[bash](textpro/text-processing-in-linux-the-uniq-command-2.sh)|Easy
['Uniq' command #3](https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-3)|Let's learn about the 'uniq' command.|[bash](textpro/text-processing-in-linux-the-uniq-command-3.sh)|Easy
['Uniq' command #4](https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-4)|Let's learn about the 'uniq' command.|[bash](textpro/text-processing-in-linux-the-uniq-command-4.sh)|Easy
[Paste - 3](https://www.hackerrank.com/challenges/paste-3)|Getting started with the 'paste' command.|[bash](textpro/paste-3.sh)|Medium
[Paste - 4](https://www.hackerrank.com/challenges/paste-4)|Getting started with the 'paste' command.|[bash](textpro/paste-4.sh)|Medium
[Paste - 1](https://www.hackerrank.com/challenges/paste-1)|Getting started with the 'paste' command.|[bash](textpro/paste-1.sh)|Medium
[Paste - 2](https://www.hackerrank.com/challenges/paste-2)|Getting started with the 'paste' command.|[bash](textpro/paste-2.sh)|Medium
#### [Arrays in Bash](https://www.hackerrank.com/domains/shell/arrays-in-bash)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Read in an Array](https://www.hackerrank.com/challenges/bash-tutorials-read-in-an-array)|Read in an Array - and display all its elements.|[bash](arrays-in-bash/bash-tutorials-read-in-an-array.sh)|Easy
[Slice an Array](https://www.hackerrank.com/challenges/bash-tutorials-slice-an-array)|Slice a given array.|[bash](arrays-in-bash/bash-tutorials-slice-an-array.sh)|Easy
[Filter an Array with Patterns](https://www.hackerrank.com/challenges/bash-tutorials-filter-an-array-with-patterns)|Read in an array and filter out certain elements based on a pattern.|[bash](arrays-in-bash/bash-tutorials-filter-an-array-with-patterns.sh)|Medium
[Concatenate an array with itself](https://www.hackerrank.com/challenges/bash-tutorials-concatenate-an-array-with-itself)|Concatenate an array with itself.|[bash](arrays-in-bash/bash-tutorials-concatenate-an-array-with-itself.sh)|Easy
[Display an element of an array](https://www.hackerrank.com/challenges/bash-tutorials-display-the-third-element-of-an-array)|Read in an Array - and display the fourth element in it.|[bash](arrays-in-bash/bash-tutorials-display-the-third-element-of-an-array.sh)|Easy
[Count the number of elements in an Array](https://www.hackerrank.com/challenges/bash-tutorials-count-the-number-of-elements-in-an-array)|Read in an Array - and count the number of elements in it.|[bash](arrays-in-bash/bash-tutorials-count-the-number-of-elements-in-an-array.sh)|Easy
[Remove the First Capital Letter from Each Element](https://www.hackerrank.com/challenges/bash-tutorials-remove-the-first-capital-letter-from-each-array-element)|The first capital letter in each element should be replaced with a dot ('.').|[bash](arrays-in-bash/bash-tutorials-remove-the-first-capital-letter-from-each-array-element.sh)|Medium
[Lonely Integer - Bash!](https://www.hackerrank.com/challenges/lonely-integer-2)|Find the integer that occurs only once in the Array|[bash](arrays-in-bash/lonely-integer-2.sh)|Hard
#### [Grep Sed Awk](https://www.hackerrank.com/domains/shell/grep-sed-awk)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
['Awk' - 3](https://www.hackerrank.com/challenges/awk-3)|Let's play around with 'awk'.|[bash](grep-sed-awk/awk-3.sh)|Medium
['Awk' - 4](https://www.hackerrank.com/challenges/awk-4)|Let's play around with 'awk'.|[bash](grep-sed-awk/awk-4.sh)|Medium
['Grep' #1](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-1)|Introduction to 'grep' in Linux.|[bash](grep-sed-awk/text-processing-in-linux-the-grep-command-1.sh)|Medium
['Grep' #2](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-2)|Introduction to 'grep' in Linux.|[bash](grep-sed-awk/text-processing-in-linux-the-grep-command-2.sh)|Medium
['Grep' #3](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-3)|Introduction to 'grep' in Linux.|[bash](grep-sed-awk/text-processing-in-linux-the-grep-command-3.sh)|Medium
['Grep' - A](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-4)|Let's 'grep' out stuff from text files!|[bash](grep-sed-awk/text-processing-in-linux-the-grep-command-4.sh)|Easy
['Grep' - B](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-5)|Let's 'grep' out stuff from text files!|[bash](grep-sed-awk/text-processing-in-linux-the-grep-command-5.sh)|Easy
['Sed' command #1](https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-1)|Let's learn about the 'sed' command.|[bash](grep-sed-awk/text-processing-in-linux-the-sed-command-1.sh)|Medium
['Sed' command #2](https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-2)|Let's learn about the 'sed' command.|[bash](grep-sed-awk/text-processing-in-linux-the-sed-command-2.sh)|Medium
['Sed' command #3](https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-3)|Let's learn about the 'sed' command.|[bash](grep-sed-awk/text-processing-in-linux-the-sed-command-3.sh)|Easy
['Sed' command #4](https://www.hackerrank.com/challenges/sed-command-4)|Let's learn about the 'sed' command.|[bash](grep-sed-awk/sed-command-4.sh)|Hard
['Sed' command #5](https://www.hackerrank.com/challenges/sed-command-5)|Let's learn about the 'sed' command.|[bash](grep-sed-awk/sed-command-5.sh)|Hard
['Awk' - 1](https://www.hackerrank.com/challenges/awk-1)|Introduction to the 'awk' command in Linux.|[bash](grep-sed-awk/awk-1.sh)|Medium
['Awk' - 2](https://www.hackerrank.com/challenges/awk-2)|Let's play around with 'awk'.|[bash](grep-sed-awk/awk-2.sh)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Arrays in Bash > Lonely Integer - Bash!
# Find the integer that occurs only once in the Array
#
# https://www.hackerrank.com/challenges/lonely-integer-2/problem
#
# il suffit de faire des XOR avec les nombres
# les nombres en double vont s'annuler
# le nombre isolé va rester
read n
a=($(cat))
echo $((0 ${a[@]/#/^}))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Arrays in Bash > Concatenate an array with itself
# Concatenate an array with itself.
#
# https://www.hackerrank.com/challenges/bash-tutorials-concatenate-an-array-with-itself/problem
#
declare -a a
a=($(cat))
b=("${a[@]}" "${a[@]}" "${a[@]}")
echo ${b[@]}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Arrays in Bash > Slice an Array
# Slice a given array.
#
# https://www.hackerrank.com/challenges/bash-tutorials-slice-an-array/problem
#
declare -a a
a=($(cat))
echo ${a[*]:3:5}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Arrays in Bash > Filter an Array with Patterns
# Read in an array and filter out certain elements based on a pattern.
#
# https://www.hackerrank.com/challenges/bash-tutorials-filter-an-array-with-patterns/problem
#
declare -a a
a=($(cat))
echo ${a[@]/*[aA]*/}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_shell(bash-tutorials-read-in-an-array.sh)
add_hackerrank_shell(bash-tutorials-slice-an-array.sh)
add_hackerrank_shell(bash-tutorials-filter-an-array-with-patterns.sh)
add_hackerrank_shell(bash-tutorials-concatenate-an-array-with-itself.sh)
add_hackerrank_shell(bash-tutorials-display-the-third-element-of-an-array.sh)
add_hackerrank_shell(bash-tutorials-count-the-number-of-elements-in-an-array.sh)
add_hackerrank_shell(bash-tutorials-remove-the-first-capital-letter-from-each-array-element.sh)
add_hackerrank_shell(lonely-integer-2.sh)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Arrays in Bash > Read in an Array
# Read in an Array - and display all its elements.
#
# https://www.hackerrank.com/challenges/bash-tutorials-read-in-an-array/problem
#
a=($(cat))
echo ${a[@]}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Arrays in Bash > Remove the First Capital Letter from Each Element
# The first capital letter in each element should be replaced with a dot ('.').
#
# https://www.hackerrank.com/challenges/bash-tutorials-remove-the-first-capital-letter-from-each-array-element/problem
#
a=($(cat))
echo ${a[@]/#?/.}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Linux Shell](https://www.hackerrank.com/domains/shell)
Bash and command-line tools can be very powerful. Test your Linux scripting skills.
#### [Arrays in Bash](https://www.hackerrank.com/domains/shell/arrays-in-bash)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Read in an Array](https://www.hackerrank.com/challenges/bash-tutorials-read-in-an-array)|Read in an Array - and display all its elements.|[bash](bash-tutorials-read-in-an-array.sh)|Easy
[Slice an Array](https://www.hackerrank.com/challenges/bash-tutorials-slice-an-array)|Slice a given array.|[bash](bash-tutorials-slice-an-array.sh)|Easy
[Filter an Array with Patterns](https://www.hackerrank.com/challenges/bash-tutorials-filter-an-array-with-patterns)|Read in an array and filter out certain elements based on a pattern.|[bash](bash-tutorials-filter-an-array-with-patterns.sh)|Medium
[Concatenate an array with itself](https://www.hackerrank.com/challenges/bash-tutorials-concatenate-an-array-with-itself)|Concatenate an array with itself.|[bash](bash-tutorials-concatenate-an-array-with-itself.sh)|Easy
[Display an element of an array](https://www.hackerrank.com/challenges/bash-tutorials-display-the-third-element-of-an-array)|Read in an Array - and display the fourth element in it.|[bash](bash-tutorials-display-the-third-element-of-an-array.sh)|Easy
[Count the number of elements in an Array](https://www.hackerrank.com/challenges/bash-tutorials-count-the-number-of-elements-in-an-array)|Read in an Array - and count the number of elements in it.|[bash](bash-tutorials-count-the-number-of-elements-in-an-array.sh)|Easy
[Remove the First Capital Letter from Each Element](https://www.hackerrank.com/challenges/bash-tutorials-remove-the-first-capital-letter-from-each-array-element)|The first capital letter in each element should be replaced with a dot ('.').|[bash](bash-tutorials-remove-the-first-capital-letter-from-each-array-element.sh)|Medium
[Lonely Integer - Bash!](https://www.hackerrank.com/challenges/lonely-integer-2)|Find the integer that occurs only once in the Array|[bash](lonely-integer-2.sh)|Hard
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Arrays in Bash > Display an element of an array
# Read in an Array - and display the fourth element in it.
#
# https://www.hackerrank.com/challenges/bash-tutorials-display-the-third-element-of-an-array/problem
#
a=($(cat))
echo ${a[3]} | {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Arrays in Bash > Count the number of elements in an Array
# Read in an Array - and count the number of elements in it.
#
# https://www.hackerrank.com/challenges/bash-tutorials-count-the-number-of-elements-in-an-array/problem
#
a=($(cat))
echo ${#a[@]}
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Grep' - B
# Let's 'grep' out stuff from text files!
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-5/problem
#
grep -E '([0-9]) ?\1'
# -E extended grep
# ([0-9]) = capture un chiffre
# " ?" = un espace ou rien
# \1 = référence à la capture
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Sed' command #5
# Let's learn about the 'sed' command.
#
# https://www.hackerrank.com/challenges/sed-command-5/problem
#
sed 's/\([0-9]\{4\}\) \([0-9]\{4\}\) \([0-9]\{4\}\) \([0-9]\{4\}\)/\4 \3 \2 \1/' | {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Sed' command #4
# Let's learn about the 'sed' command.
#
# https://www.hackerrank.com/challenges/sed-command-4/problem
#
sed 's/\([0-9]\{4\}\) \([0-9]\{4\}\) \([0-9]\{4\}\) \([0-9]\{4\}\)/**** **** **** \4/'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Awk' - 1
# Introduction to the 'awk' command in Linux.
#
# https://www.hackerrank.com/challenges/awk-1/problem
#
awk '{ if (NF < 4) { print "Not all scores are available for "$1 }}'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Grep' #1
# Introduction to 'grep' in Linux.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-1/problem
#
grep "the "
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Awk' - 3
# Let's play around with 'awk'.
#
# https://www.hackerrank.com/challenges/awk-3/problem
#
awk '{ p = int(($2 + $3 + $4) / 3);
if (p >= 80) q = "A"; else if (p >= 60) q = "B"; else if (p >= 50) q = "C"; else q ="FAIL";
print $1" "$2" " $3" " $4 " : " q ; }'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Sed' command #2
# Let's learn about the 'sed' command.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-2/problem
#
sed 's/thy/your/ig'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Awk' - 4
# Let's play around with 'awk'.
#
# https://www.hackerrank.com/challenges/awk-4/problem
#
awk '{if (NR % 2) { printf $0 ";"; } else { printf $0 "\n"; } }'
# il y a moyen d'écrire beaucoup plus concis
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Grep' #3
# Introduction to 'grep' in Linux.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-3/problem
#
grep -i -v "that "
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Grep' - A
# Let's 'grep' out stuff from text files!
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-4/problem
#
grep -E -i 'the |that |then |those '
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_shell(text-processing-in-linux-the-grep-command-1.sh)
add_hackerrank_shell(text-processing-in-linux-the-grep-command-2.sh)
add_hackerrank_shell(text-processing-in-linux-the-grep-command-3.sh)
add_hackerrank_shell(text-processing-in-linux-the-grep-command-4.sh)
add_hackerrank_shell(sed-command-5.sh)
add_hackerrank_shell(sed-command-4.sh)
add_hackerrank_shell(awk-1.sh)
add_hackerrank_shell(awk-3.sh)
add_hackerrank_shell(awk-4.sh)
add_hackerrank_shell(text-processing-in-linux-the-grep-command-5.sh)
add_hackerrank_shell(text-processing-in-linux-the-sed-command-1.sh)
add_hackerrank_shell(awk-2.sh)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_hackerrank_shell(text-processing-in-linux-the-sed-command-2.sh)
add_hackerrank_shell(text-processing-in-linux-the-sed-command-3.sh)
endif() | {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Awk' - 2
# Let's play around with 'awk'.
#
# https://www.hackerrank.com/challenges/awk-2/problem
#
awk '{ if ($2 >= 50 && $3 >= 50 && $4 >= 50) print $1,": Pass"; else print $1, ": Fail" }'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Grep' #2
# Introduction to 'grep' in Linux.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-2/problem
#
grep -i "the " | {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Sed' command #3
# Let's learn about the 'sed' command.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-3/problem
#
sed 's/\(thy\)/{\1}/ig'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Grep Sed Awk > 'Sed' command #1
# Let's learn about the 'sed' command.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-1/problem
#
sed 's/the /this /'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Linux Shell](https://www.hackerrank.com/domains/shell)
Bash and command-line tools can be very powerful. Test your Linux scripting skills.
#### [Grep Sed Awk](https://www.hackerrank.com/domains/shell/grep-sed-awk)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
['Awk' - 3](https://www.hackerrank.com/challenges/awk-3)|Let's play around with 'awk'.|[bash](awk-3.sh)|Medium
['Awk' - 4](https://www.hackerrank.com/challenges/awk-4)|Let's play around with 'awk'.|[bash](awk-4.sh)|Medium
['Grep' #1](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-1)|Introduction to 'grep' in Linux.|[bash](text-processing-in-linux-the-grep-command-1.sh)|Medium
['Grep' #2](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-2)|Introduction to 'grep' in Linux.|[bash](text-processing-in-linux-the-grep-command-2.sh)|Medium
['Grep' #3](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-3)|Introduction to 'grep' in Linux.|[bash](text-processing-in-linux-the-grep-command-3.sh)|Medium
['Grep' - A](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-4)|Let's 'grep' out stuff from text files!|[bash](text-processing-in-linux-the-grep-command-4.sh)|Easy
['Grep' - B](https://www.hackerrank.com/challenges/text-processing-in-linux-the-grep-command-5)|Let's 'grep' out stuff from text files!|[bash](text-processing-in-linux-the-grep-command-5.sh)|Easy
['Sed' command #1](https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-1)|Let's learn about the 'sed' command.|[bash](text-processing-in-linux-the-sed-command-1.sh)|Medium
['Sed' command #2](https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-2)|Let's learn about the 'sed' command.|[bash](text-processing-in-linux-the-sed-command-2.sh)|Medium
['Sed' command #3](https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-3)|Let's learn about the 'sed' command.|[bash](text-processing-in-linux-the-sed-command-3.sh)|Easy
['Sed' command #4](https://www.hackerrank.com/challenges/sed-command-4)|Let's learn about the 'sed' command.|[bash](sed-command-4.sh)|Hard
['Sed' command #5](https://www.hackerrank.com/challenges/sed-command-5)|Let's learn about the 'sed' command.|[bash](sed-command-5.sh)|Hard
['Awk' - 1](https://www.hackerrank.com/challenges/awk-1)|Introduction to the 'awk' command in Linux.|[bash](awk-1.sh)|Medium
['Awk' - 2](https://www.hackerrank.com/challenges/awk-2)|Let's play around with 'awk'.|[bash](awk-2.sh)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > Looping with Numbers
# Let's experiment with 'For' loops
#
# https://www.hackerrank.com/challenges/bash-tutorials---looping-with-numbers/problem
#
for ((i=1;i<=50;i+=1))
do
echo $i
done | {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > More on Conditionals
# Three sides of a triangle are provided to you. Is the Triangle Scalene, Equilateral or Isosceles?
#
# https://www.hackerrank.com/challenges/bash-tutorials---more-on-conditionals/problem
#
read X
read Y
read Z
if [ $X -eq $Y -a $Y -eq $Z -a $Z -eq $X ] ; then
echo EQUILATERAL
elif [ $X -eq $Y -o $Y -eq $Z -o $Z -eq $X ] ; then
echo ISOSCELES
else
echo SCALENE
fi
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > Let's Echo
# Let's get started with the simplest Bash command: echo.
#
# https://www.hackerrank.com/challenges/bash-tutorials-lets-echo/problem
#
echo HELLO
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_shell(bash-tutorials---a-personalized-echo.sh)
add_hackerrank_shell(bash-tutorials---comparing-numbers.sh)
add_hackerrank_shell(bash-tutorials---looping-and-skipping.sh)
add_hackerrank_shell(bash-tutorials---looping-with-numbers.sh)
add_hackerrank_shell(bash-tutorials---the-world-of-numbers.sh)
add_hackerrank_shell(bash-tutorials-lets-echo.sh)
add_hackerrank_shell(bash-tutorials---getting-started-with-conditionals.sh)
add_hackerrank_shell(bash-tutorials---more-on-conditionals.sh)
add_hackerrank_shell(bash-tutorials---arithmetic-operations.sh)
add_hackerrank_shell(bash-tutorials---compute-the-average.sh)
add_hackerrank_shell(fractal-trees-all.sh)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > The World of Numbers
# Let's move on to playing with numbers in Bash.
#
# https://www.hackerrank.com/challenges/bash-tutorials---the-world-of-numbers/problem
#
read X
read Y
echo $((X+Y))
echo $((X-Y))
echo $((X*Y))
echo $((X/Y))
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > Getting started with conditionals
# -
#
# https://www.hackerrank.com/challenges/bash-tutorials---getting-started-with-conditionals/problem
#
read c
if [ "$c" = "y" -o "$c" = "Y" ]
then
echo YES
else
echo NO
fi
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > A Personalized Echo
# A very gentle on-boarding, to accepting input in Bash.
#
# https://www.hackerrank.com/challenges/bash-tutorials---a-personalized-echo/problem
#
read a
echo "Welcome $a"
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > Looping and Skipping
# Let's play with for loops, a little more. Let's skip numbers!
#
# https://www.hackerrank.com/challenges/bash-tutorials---looping-and-skipping/problem
#
for ((i=1; i<=99; i+=2)); do echo $i; done
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > Comparing Numbers
# Simple comparisons between numbers: Greater than, less than, equal to.
#
# https://www.hackerrank.com/challenges/bash-tutorials---comparing-numbers/problem
#
read X
read Y
[ $X -eq $Y ] && echo "X is equal to Y"
[ $X -lt $Y ] && echo "X is less than Y"
[ $X -gt $Y ] && echo "X is greater than Y"
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > Compute the Average
# Compute the average of a list of N numbers provided to you.
#
# https://www.hackerrank.com/challenges/bash-tutorials---compute-the-average/problem
#
# pas franchement le langage le plus adapté...
export LANG=C
read N
a=0
for i in $(seq $N); do
read x
a=$((a+x))
done
printf "%.3f" $(bc -l <<< "$a / $N")
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > Functions and Fractals - Recursive Trees - Bash!
# Create a Fractal Tree
#
# https://www.hackerrank.com/challenges/fractal-trees-all/problem
#
# un jour, peut-être, je réécrirai en bash ;-)
cat <<'EOF' > toto.py
ligne = ["_"] * 100
Y = []
for i in range(63):
Y.append(ligne[:])
def gen(y, x, n, iter):
for i in range(n):
Y[y - i - n][x - 1 - i] = '1'
Y[y - i - n][x + 1 + i] = '1'
for i in range(n):
Y[y - i][x] = '1'
if n > 1 and iter > 0:
gen(y - n * 2, x - n, n // 2, iter - 1)
gen(y - n * 2, x + n, n // 2, iter - 1)
gen(62, 49, 16, int(input()) - 1)
for i in Y:
print(''.join(i))
EOF
python3 toto.py
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Bash > Arithmetic Operations
# Math in shell scripts.
#
# https://www.hackerrank.com/challenges/bash-tutorials---arithmetic-operations/problem
#
# mais ce n'est certainement pas la solution attendue...
#python3 -c 'print("%.3f" % eval(input().replace("^","**")))'
# c'est plus vraisemblalement ça... dommage que scale=3 ne donne pas les bonnes décimales
export LANG=C
read a
printf "%.3f\n" $(echo $a | bc -l)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Linux Shell](https://www.hackerrank.com/domains/shell)
Bash and command-line tools can be very powerful. Test your Linux scripting skills.
#### [Bash](https://www.hackerrank.com/domains/shell/bash)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Let's Echo](https://www.hackerrank.com/challenges/bash-tutorials-lets-echo)|Let's get started with the simplest Bash command: echo.|[bash](bash-tutorials-lets-echo.sh)|Easy
[Looping and Skipping](https://www.hackerrank.com/challenges/bash-tutorials---looping-and-skipping)|Let's play with for loops, a little more. Let's skip numbers!|[bash](bash-tutorials---looping-and-skipping.sh)|Easy
[A Personalized Echo](https://www.hackerrank.com/challenges/bash-tutorials---a-personalized-echo)|A very gentle on-boarding, to accepting input in Bash.|[bash](bash-tutorials---a-personalized-echo.sh)|Easy
[Looping with Numbers](https://www.hackerrank.com/challenges/bash-tutorials---looping-with-numbers)|Let's experiment with 'For' loops|[bash](bash-tutorials---looping-with-numbers.sh)|Easy
[The World of Numbers](https://www.hackerrank.com/challenges/bash-tutorials---the-world-of-numbers)|Let's move on to playing with numbers in Bash.|[bash](bash-tutorials---the-world-of-numbers.sh)|Easy
[Comparing Numbers](https://www.hackerrank.com/challenges/bash-tutorials---comparing-numbers)|Simple comparisons between numbers: Greater than, less than, equal to.|[bash](bash-tutorials---comparing-numbers.sh)|Easy
[Getting started with conditionals](https://www.hackerrank.com/challenges/bash-tutorials---getting-started-with-conditionals)|-|[bash](bash-tutorials---getting-started-with-conditionals.sh)|Easy
[More on Conditionals](https://www.hackerrank.com/challenges/bash-tutorials---more-on-conditionals)|Three sides of a triangle are provided to you. Is the Triangle Scalene, Equilateral or Isosceles?|[bash](bash-tutorials---more-on-conditionals.sh)|Easy
[Arithmetic Operations](https://www.hackerrank.com/challenges/bash-tutorials---arithmetic-operations)|Math in shell scripts.|[bash](bash-tutorials---arithmetic-operations.sh)|Medium
[Compute the Average](https://www.hackerrank.com/challenges/bash-tutorials---compute-the-average)|Compute the average of a list of N numbers provided to you.|[bash](bash-tutorials---compute-the-average.sh)|Medium
[Functions and Fractals - Recursive Trees - Bash!](https://www.hackerrank.com/challenges/fractal-trees-all)|Create a Fractal Tree|[bash](fractal-trees-all.sh)|Hard
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #4
# Playing with the 'cut' command.
#
# https://www.hackerrank.com/challenges/text-processing-cut-4/problem
#
cut -b-4
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Tr' Command #3
#
#
# https://www.hackerrank.com/challenges/text-processing-tr-3/problem
#
tr -s ' ' ' '
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Paste - 1
# Getting started with the 'paste' command.
#
# https://www.hackerrank.com/challenges/paste-1/problem
#
paste -s -d';' -
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Uniq' Command #2
# Introduction to the 'uniq' command.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-2/problem
#
uniq -c | sed 's/^ *//'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #2
# Playing with the 'cut' command.
#
# https://www.hackerrank.com/challenges/text-processing-cut-2/problem
#
cut -b2,7
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #8
# Playing with the 'cut' command.
#
# https://www.hackerrank.com/challenges/text-processing-cut-8/problem
#
cut -d' ' -f1,2,3
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Tr' Command #2
# Introduction to the 'tr' command.
#
# https://www.hackerrank.com/challenges/text-processing-tr-2/problem
#
tr -d 'a-z'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Paste - 3
# Getting started with the 'paste' command.
#
# https://www.hackerrank.com/challenges/paste-3/problem
#
paste -s -
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #9
# Playing with the 'cut' command and TSV files.
#
# https://www.hackerrank.com/challenges/text-processing-cut-9/problem
#
cut -f2-
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #3
#
#
# https://www.hackerrank.com/challenges/text-processing-cut-3/problem
#
cut -b2-7
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Paste - 2
# Getting started with the 'paste' command.
#
# https://www.hackerrank.com/challenges/paste-2/problem
#
paste -d';' - - -
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Middle of a Text File
# Display lines from the middle of a text file
#
# https://www.hackerrank.com/challenges/text-processing-in-linux---the-middle-of-a-text-file/problem
#
sed '12,22p;d'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Tail of a Text File #2
# The 'tail' command.
#
# https://www.hackerrank.com/challenges/text-processing-tail-2/problem
#
tail -c20
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Tail of a Text File #1
# Introduction to the 'tail' command.
#
# https://www.hackerrank.com/challenges/text-processing-tail-1/problem
#
tail -20
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_shell(text-processing-cut-1.sh)
add_hackerrank_shell(paste-2.sh)
add_hackerrank_shell(text-processing-in-linux-the-uniq-command-4.sh)
add_hackerrank_shell(text-processing-in-linux-the-uniq-command-1.sh)
add_hackerrank_shell(text-processing-in-linux-the-uniq-command-2.sh)
add_hackerrank_shell(text-processing-in-linux-the-uniq-command-3.sh)
add_hackerrank_shell(text-processing-cut-2.sh)
add_hackerrank_shell(text-processing-cut-3.sh)
add_hackerrank_shell(text-processing-cut-4.sh)
add_hackerrank_shell(text-processing-cut-5.sh)
add_hackerrank_shell(text-processing-cut-6.sh)
add_hackerrank_shell(text-processing-cut-7.sh)
add_hackerrank_shell(text-processing-cut-8.sh)
add_hackerrank_shell(text-processing-cut-9.sh)
add_hackerrank_shell(text-processing-head-1.sh)
add_hackerrank_shell(text-processing-head-2.sh)
add_hackerrank_shell(text-processing-in-linux---the-middle-of-a-text-file.sh)
add_hackerrank_shell(text-processing-tail-1.sh)
add_hackerrank_shell(text-processing-tail-2.sh)
add_hackerrank_shell(text-processing-tr-1.sh)
add_hackerrank_shell(text-processing-tr-2.sh)
add_hackerrank_shell(text-processing-tr-3.sh)
add_hackerrank_shell(text-processing-sort-4.sh)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_hackerrank_shell(text-processing-sort-5.sh)
add_hackerrank_shell(text-processing-sort-6.sh)
add_hackerrank_shell(text-processing-sort-7.sh)
endif()
add_hackerrank_shell(paste-3.sh)
add_hackerrank_shell(paste-4.sh)
add_hackerrank_shell(paste-1.sh)
add_hackerrank_shell(text-processing-sort-1.sh)
add_hackerrank_shell(text-processing-sort-2.sh)
add_hackerrank_shell(text-processing-sort-3.sh)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Head of a Text File #1
# Introducing the 'head' command.
#
# https://www.hackerrank.com/challenges/text-processing-head-1/problem
#
head -20
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #1
# Playing with the 'cut' command.
#
# https://www.hackerrank.com/challenges/text-processing-cut-1/problem
#
cut -b3
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #6
# Playing with the 'cut' command.
#
# https://www.hackerrank.com/challenges/text-processing-cut-6/problem
#
cut -b13- | {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Uniq' Command #1
# Introduction to the 'uniq' command.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-1/problem
#
uniq
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Sort Command #5
# Playing around with the 'sort' command.
#
# https://www.hackerrank.com/challenges/text-processing-sort-5/problem
#
sort -r -n -k2 -t $'\t'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Sort Command #3
# Introducing the 'sort' command in Linux.
#
# https://www.hackerrank.com/challenges/text-processing-sort-3/problem
#
sort -n
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Paste - 4
# Getting started with the 'paste' command.
#
# https://www.hackerrank.com/challenges/paste-4/problem
#
paste - - -
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #5
# Playing with the 'cut' command.
#
# https://www.hackerrank.com/challenges/text-processing-cut-5/problem
#
cut -f1-3
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Sort Command #4
# Playing around with the 'sort' command.
#
# https://www.hackerrank.com/challenges/text-processing-sort-4/problem
#
sort -nr
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Sort Command #2
# Introducing the 'sort' command in Linux.
#
# https://www.hackerrank.com/challenges/text-processing-sort-2/problem
#
sort -r
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Cut #7
# Playing with the 'cut' command.
#
# https://www.hackerrank.com/challenges/text-processing-cut-7/problem
#
cut -d' ' -f4
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Sort Command #1
# Introducing the 'sort' command in Linux.
#
# https://www.hackerrank.com/challenges/text-processing-sort-1/problem
#
sort
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Tr' Command #1
# Introduction to the 'tr' command.
#
# https://www.hackerrank.com/challenges/text-processing-tr-1/problem
#
tr '()' '[]'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Uniq' command #3
# Let's learn about the 'uniq' command.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-3/problem
#
uniq -c -i | while read a b ; do
echo $a $b
done
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > Head of a Text File #2
# The 'head' command.
#
# https://www.hackerrank.com/challenges/text-processing-head-2/problem
#
head -c20
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Sort' command #6
# Let's learn about the 'sort' command.
#
# https://www.hackerrank.com/challenges/text-processing-sort-6/problem
#
sort -n -t$'\t' -k2
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Uniq' command #4
# Let's learn about the 'uniq' command.
#
# https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-4/problem
#
uniq -u
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Linux Shell](https://www.hackerrank.com/domains/shell)
Bash and command-line tools can be very powerful. Test your Linux scripting skills.
#### [Text Processing](https://www.hackerrank.com/domains/shell/textpro)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Cut #1](https://www.hackerrank.com/challenges/text-processing-cut-1)|Playing with the 'cut' command.|[bash](text-processing-cut-1.sh)|Easy
[Cut #2](https://www.hackerrank.com/challenges/text-processing-cut-2)|Playing with the 'cut' command.|[bash](text-processing-cut-2.sh)|Easy
[Cut #3](https://www.hackerrank.com/challenges/text-processing-cut-3)||[bash](text-processing-cut-3.sh)|Easy
[Cut #4](https://www.hackerrank.com/challenges/text-processing-cut-4)|Playing with the 'cut' command.|[bash](text-processing-cut-4.sh)|Easy
[Cut #5](https://www.hackerrank.com/challenges/text-processing-cut-5)|Playing with the 'cut' command.|[bash](text-processing-cut-5.sh)|Easy
[Cut #6](https://www.hackerrank.com/challenges/text-processing-cut-6)|Playing with the 'cut' command.|[bash](text-processing-cut-6.sh)|Easy
[Cut #7](https://www.hackerrank.com/challenges/text-processing-cut-7)|Playing with the 'cut' command.|[bash](text-processing-cut-7.sh)|Easy
[Cut #8](https://www.hackerrank.com/challenges/text-processing-cut-8)|Playing with the 'cut' command.|[bash](text-processing-cut-8.sh)|Easy
[Cut #9](https://www.hackerrank.com/challenges/text-processing-cut-9)|Playing with the 'cut' command and TSV files.|[bash](text-processing-cut-9.sh)|Easy
[Head of a Text File #1](https://www.hackerrank.com/challenges/text-processing-head-1)|Introducing the 'head' command.|[bash](text-processing-head-1.sh)|Easy
[Head of a Text File #2](https://www.hackerrank.com/challenges/text-processing-head-2)|The 'head' command.|[bash](text-processing-head-2.sh)|Easy
[Middle of a Text File](https://www.hackerrank.com/challenges/text-processing-in-linux---the-middle-of-a-text-file)|Display lines from the middle of a text file|[bash](text-processing-in-linux---the-middle-of-a-text-file.sh)|Easy
[Tail of a Text File #1](https://www.hackerrank.com/challenges/text-processing-tail-1)|Introduction to the 'tail' command.|[bash](text-processing-tail-1.sh)|Easy
[Tail of a Text File #2](https://www.hackerrank.com/challenges/text-processing-tail-2)|The 'tail' command.|[bash](text-processing-tail-2.sh)|Easy
['Tr' Command #1](https://www.hackerrank.com/challenges/text-processing-tr-1)|Introduction to the 'tr' command.|[bash](text-processing-tr-1.sh)|Easy
['Tr' Command #2](https://www.hackerrank.com/challenges/text-processing-tr-2)|Introduction to the 'tr' command.|[bash](text-processing-tr-2.sh)|Easy
['Tr' Command #3](https://www.hackerrank.com/challenges/text-processing-tr-3)||[bash](text-processing-tr-3.sh)|Easy
[Sort Command #1](https://www.hackerrank.com/challenges/text-processing-sort-1)|Introducing the 'sort' command in Linux.|[bash](text-processing-sort-1.sh)|Easy
[Sort Command #2](https://www.hackerrank.com/challenges/text-processing-sort-2)|Introducing the 'sort' command in Linux.|[bash](text-processing-sort-2.sh)|Easy
[Sort Command #3](https://www.hackerrank.com/challenges/text-processing-sort-3)|Introducing the 'sort' command in Linux.|[bash](text-processing-sort-3.sh)|Easy
[Sort Command #4](https://www.hackerrank.com/challenges/text-processing-sort-4)|Playing around with the 'sort' command.|[bash](text-processing-sort-4.sh)|Easy
[Sort Command #5](https://www.hackerrank.com/challenges/text-processing-sort-5)|Playing around with the 'sort' command.|[bash](text-processing-sort-5.sh)|Easy
['Sort' command #6](https://www.hackerrank.com/challenges/text-processing-sort-6)|Let's learn about the 'sort' command.|[bash](text-processing-sort-6.sh)|Easy
['Sort' command #7](https://www.hackerrank.com/challenges/text-processing-sort-7)|Let's learn about the 'sort' command.|[bash](text-processing-sort-7.sh)|Easy
['Uniq' Command #1](https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-1)|Introduction to the 'uniq' command.|[bash](text-processing-in-linux-the-uniq-command-1.sh)|Easy
['Uniq' Command #2](https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-2)|Introduction to the 'uniq' command.|[bash](text-processing-in-linux-the-uniq-command-2.sh)|Easy
['Uniq' command #3](https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-3)|Let's learn about the 'uniq' command.|[bash](text-processing-in-linux-the-uniq-command-3.sh)|Easy
['Uniq' command #4](https://www.hackerrank.com/challenges/text-processing-in-linux-the-uniq-command-4)|Let's learn about the 'uniq' command.|[bash](text-processing-in-linux-the-uniq-command-4.sh)|Easy
[Paste - 3](https://www.hackerrank.com/challenges/paste-3)|Getting started with the 'paste' command.|[bash](paste-3.sh)|Medium
[Paste - 4](https://www.hackerrank.com/challenges/paste-4)|Getting started with the 'paste' command.|[bash](paste-4.sh)|Medium
[Paste - 1](https://www.hackerrank.com/challenges/paste-1)|Getting started with the 'paste' command.|[bash](paste-1.sh)|Medium
[Paste - 2](https://www.hackerrank.com/challenges/paste-2)|Getting started with the 'paste' command.|[bash](paste-2.sh)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Linux Shell > Text Processing > 'Sort' command #7
# Let's learn about the 'sort' command.
#
# https://www.hackerrank.com/challenges/text-processing-sort-7/problem
#
sort -nr -k2 -t'|'
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_subdirectory(arrays)
add_subdirectory(dictionaries-hashmaps)
add_subdirectory(miscellaneous)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Interview Preparation Kit](https://www.hackerrank.com/interview/interview-preparation-kit)
#### [Arrays](https://www.hackerrank.com/interview/interview-preparation-kit/arrays/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[2D Array - DS](https://www.hackerrank.com/challenges/2d-array/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=arrays)|How to access and use 2d-arrays.|[Python](../data-structures/arrays/2d-array.py)|Easy
[Array Manipulation](https://www.hackerrank.com/challenges/crush/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=arrays)|Perform m operations on an array and print the maximum of the values.|[Python](../data-structures/arrays/crush.py)|Hard
[Arrays: Left Rotation](https://www.hackerrank.com/challenges/ctci-array-left-rotation/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=arrays)|Given an array and a number, d, perform d left rotations on the array.|[Python](../tutorials/cracking-the-coding-interview/ctci-array-left-rotation.py)|Easy
[Minimum Swaps 2](https://www.hackerrank.com/challenges/minimum-swaps-2/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=arrays)|Return the minimum number of swaps to sort the given array.|[Python](arrays/minimum-swaps-2.py)|Medium
[New Year Chaos](https://www.hackerrank.com/challenges/new-year-chaos/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=arrays)|Determine how many bribes took place to get a queue into its current state.|[Python](../algorithms/constructive-algorithms/new-year-chaos.py)|Medium
#### [Dictionaries and Hashmaps](https://www.hackerrank.com/interview/interview-preparation-kit/dictionaries-hashmaps/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Hash Tables: Ransom Note](https://www.hackerrank.com/challenges/ctci-ransom-note/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=dictionaries-hashmaps)|Given two sets of dictionaries, tell if one of them is a subset of the other.|[C++](../tutorials/cracking-the-coding-interview/ctci-ransom-note.cpp)|Easy
[Sherlock and Anagrams](https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=dictionaries-hashmaps)|Find the number of unordered anagramic pairs of substrings of a string.|[Python](../algorithms/strings/sherlock-and-anagrams.py)|Medium
[Two Strings](https://www.hackerrank.com/challenges/two-strings/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=dictionaries-hashmaps)|Given two strings, you find a common substring of non-zero length.|[Python](../algorithms/strings/two-strings.py)|Easy
#### [Sorting](https://www.hackerrank.com/interview/interview-preparation-kit/sorting/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Sorting: Bubble Sort](https://www.hackerrank.com/challenges/ctci-bubble-sort/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=sorting)|Find the minimum number of conditional checks taking place in Bubble Sort|[Python](../tutorials/cracking-the-coding-interview/ctci-bubble-sort.py)|Easy
[Sorting: Comparator](https://www.hackerrank.com/challenges/ctci-comparator-sorting/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=sorting)|Write a Comparator for sorting elements in an array.|[C++](../tutorials/cracking-the-coding-interview/ctci-comparator-sorting.cpp)|Medium
[Merge Sort: Counting Inversions](https://www.hackerrank.com/challenges/ctci-merge-sort/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=sorting)|How many shifts will it take to Merge Sort an array?|[Python](../tutorials/cracking-the-coding-interview/ctci-merge-sort.py)|Hard
#### [String Manipulation](https://www.hackerrank.com/interview/interview-preparation-kit/strings/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Alternating Characters ](https://www.hackerrank.com/challenges/alternating-characters/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=strings)|Calculate the minimum number of deletions required to convert a string into a string in which consecutive characters are different.|[Python](../algorithms/strings/alternating-characters.py)|Easy
[Common Child](https://www.hackerrank.com/challenges/common-child/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=strings)|Given two strings a and b of equal length, what's the longest string (s) that can be constructed such that s is a child to both a and b?|[C++](../algorithms/strings/common-child.cpp) [Python](../algorithms/strings/common-child.py)|Medium
[Strings: Making Anagrams](https://www.hackerrank.com/challenges/ctci-making-anagrams/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=strings)|How many characters should one delete to make two given strings anagrams of each other?|[Python](../tutorials/cracking-the-coding-interview/ctci-making-anagrams.py)|Easy
[Sherlock and the Valid String](https://www.hackerrank.com/challenges/sherlock-and-valid-string/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=strings)|Remove some characters from the string such that the new string's characters have the same frequency.|[Python](../algorithms/strings/sherlock-and-valid-string.py)|Medium
#### [Greedy Algorithms](https://www.hackerrank.com/interview/interview-preparation-kit/greedy-algorithms/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Minimum Absolute Difference in an Array](https://www.hackerrank.com/challenges/minimum-absolute-difference-in-an-array/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=greedy-algorithms)|Given a list of integers, calculate their differences and find the difference with the smallest absolute value.|[Python](../algorithms/greedy/minimum-absolute-difference-in-an-array.py)|Easy
#### [Search](https://www.hackerrank.com/interview/interview-preparation-kit/search/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Hash Tables: Ice Cream Parlor](https://www.hackerrank.com/challenges/ctci-ice-cream-parlor/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=search)|Help Sunny and Johnny spend all their money during each trip to the Ice Cream Parlor.|[Python](../tutorials/cracking-the-coding-interview/ctci-ice-cream-parlor.py)|Medium
[Pairs](https://www.hackerrank.com/challenges/pairs/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=search)|Given N numbers, count the total pairs of numbers that have a difference of K.|[Python](../algorithms/search/pairs.py)|Medium
#### [Stacks and Queues](https://www.hackerrank.com/interview/interview-preparation-kit/stacks-queues/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Balanced Brackets](https://www.hackerrank.com/challenges/balanced-brackets/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=stacks-queues)|Given a string containing three types of brackets, determine if it is balanced.|[Python](../data-structures/stacks/balanced-brackets.py)|Medium
[Queues: A Tale of Two Stacks](https://www.hackerrank.com/challenges/ctci-queue-using-two-stacks/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=stacks-queues)|Create a queue data structure using two stacks.|[C++](../tutorials/cracking-the-coding-interview/ctci-queue-using-two-stacks.cpp)|Medium
[Largest Rectangle ](https://www.hackerrank.com/challenges/largest-rectangle/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=stacks-queues)|Given n buildings, find the largest rectangular area possible by joining consecutive K buildings.|[Python](../data-structures/stacks/largest-rectangle.py)|Medium
#### [Graphs](https://www.hackerrank.com/interview/interview-preparation-kit/graphs/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[BFS: Shortest Reach in a Graph](https://www.hackerrank.com/challenges/ctci-bfs-shortest-reach/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=graphs)|Implement a Breadth First Search (BFS).|[C++](../tutorials/cracking-the-coding-interview/ctci-bfs-shortest-reach.cpp)|Hard
[DFS: Connected Cell in a Grid](https://www.hackerrank.com/challenges/ctci-connected-cell-in-a-grid/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=graphs)|Find the largest connected region in a 2D Matrix.|[C++](../tutorials/cracking-the-coding-interview/ctci-connected-cell-in-a-grid.cpp)|Hard
#### [Trees](https://www.hackerrank.com/interview/interview-preparation-kit/trees/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Binary Search Tree : Lowest Common Ancestor](https://www.hackerrank.com/challenges/binary-search-tree-lowest-common-ancestor/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=trees)|Given two nodes of a binary search tree, find the lowest common ancestor of these two nodes.|[C++](../data-structures/trees/binary-search-tree-lowest-common-ancestor.cpp)|Easy
[Trees: Is This a Binary Search Tree?](https://www.hackerrank.com/challenges/ctci-is-binary-search-tree/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=trees)|Given the root of a binary tree, determine if it's a binary search tree.|[Python](../tutorials/cracking-the-coding-interview/ctci-is-binary-search-tree.py)|Medium
[Tree: Height of a Binary Tree](https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=trees)|Given a binary tree, print its height.|[C++](../data-structures/trees/tree-height-of-a-binary-tree.cpp) [Python](../data-structures/trees/tree-height-of-a-binary-tree.py)|Easy
[Tree: Huffman Decoding ](https://www.hackerrank.com/challenges/tree-huffman-decoding/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=trees)|Given a Huffman tree and an encoded binary string, you have to print the original string.|[C++](../data-structures/trees/tree-huffman-decoding.cpp)|Medium
#### [Linked Lists](https://www.hackerrank.com/interview/interview-preparation-kit/linked-lists/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Linked Lists: Detect a Cycle](https://www.hackerrank.com/challenges/ctci-linked-list-cycle/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=linked-lists)|Given a pointer to the head of a linked list, determine whether the list has a cycle.|[C++](../tutorials/cracking-the-coding-interview/ctci-linked-list-cycle.cpp)|Easy
[Find Merge Point of Two Lists](https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=linked-lists)|Given two linked lists, find the node where they merge into one.|[C++](../data-structures/linked-lists/find-the-merge-point-of-two-joined-linked-lists.cpp)|Easy
[Insert a node at a specific position in a linked list](https://www.hackerrank.com/challenges/insert-a-node-at-a-specific-position-in-a-linked-list/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=linked-lists)|Insert a node at a specific position in a linked list.|[C++](../data-structures/linked-lists/insert-a-node-at-a-specific-position-in-a-linked-list.cpp)|Easy
[Inserting a Node Into a Sorted Doubly Linked List](https://www.hackerrank.com/challenges/insert-a-node-into-a-sorted-doubly-linked-list/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=linked-lists)|Create a node with a given value and insert it into a sorted doubly-linked list|[C++](../data-structures/linked-lists/insert-a-node-into-a-sorted-doubly-linked-list.cpp)|Easy
[Reverse a doubly linked list](https://www.hackerrank.com/challenges/reverse-a-doubly-linked-list/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=linked-lists)|Given the head node of a doubly linked list, reverse it.|[Python](../data-structures/linked-lists/reverse-a-doubly-linked-list.py)|Easy
#### [Recursion and Backtracking](https://www.hackerrank.com/interview/interview-preparation-kit/recursion-backtracking/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Recursion: Fibonacci Numbers](https://www.hackerrank.com/challenges/ctci-fibonacci-numbers/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=recursion-backtracking)|Compute the $n^{th}$ Fibonacci number.|[C++](../tutorials/cracking-the-coding-interview/ctci-fibonacci-numbers.cpp)|Easy
[Recursion: Davis' Staircase](https://www.hackerrank.com/challenges/ctci-recursive-staircase/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=recursion-backtracking)|Find the number of ways to get from the bottom of a staircase to the top if you can jump 1, 2, or 3 stairs at a time.|[C++](../tutorials/cracking-the-coding-interview/ctci-recursive-staircase.cpp)|Medium
#### [Miscellaneous](https://www.hackerrank.com/interview/interview-preparation-kit/miscellaneous/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Time Complexity: Primality](https://www.hackerrank.com/challenges/ctci-big-o/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=miscellaneous)|Determine whether or not a number is prime in optimal time.|[C++](../tutorials/cracking-the-coding-interview/ctci-big-o.cpp)|Medium
[Flipping bits](https://www.hackerrank.com/challenges/flipping-bits/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=miscellaneous)|Flip bits in its binary representation.|[C++](../algorithms/bit-manipulation/flipping-bits.cpp)|Easy
[Friend Circle Queries](https://www.hackerrank.com/challenges/friend-circle-queries/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=miscellaneous)|Process the queries and after each query print the number of people largest friend circle.|[Python](miscellaneous/friend-circle-queries.py)|Medium
[Maximum Xor](https://www.hackerrank.com/challenges/maximum-xor/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=miscellaneous)|Find the maximum xor value in the array.|[C++](miscellaneous/maximum-xor.cpp)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Interview Preparation Kit](https://www.hackerrank.com/interview/interview-preparation-kit)
#### [String Manipulation](https://www.hackerrank.com/interview/interview-preparation-kit/strings/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Alternating Characters ](https://www.hackerrank.com/challenges/alternating-characters/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=strings)|Calculate the minimum number of deletions required to convert a string into a string in which consecutive characters are different.|[Python](../../algorithms/strings/alternating-characters.py)|Easy
[Common Child](https://www.hackerrank.com/challenges/common-child/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=strings)|Given two strings a and b of equal length, what's the longest string (s) that can be constructed such that s is a child to both a and b?|[C++](../../algorithms/strings/common-child.cpp) [Python](../../algorithms/strings/common-child.py)|Medium
[Strings: Making Anagrams](https://www.hackerrank.com/challenges/ctci-making-anagrams/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=strings)|How many characters should one delete to make two given strings anagrams of each other?|[Python](../../tutorials/cracking-the-coding-interview/ctci-making-anagrams.py)|Easy
[Sherlock and the Valid String](https://www.hackerrank.com/challenges/sherlock-and-valid-string/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=strings)|Remove some characters from the string such that the new string's characters have the same frequency.|[Python](../../algorithms/strings/sherlock-and-valid-string.py)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Interview Preparation Kit](https://www.hackerrank.com/interview/interview-preparation-kit)
#### [Search](https://www.hackerrank.com/interview/interview-preparation-kit/search/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Hash Tables: Ice Cream Parlor](https://www.hackerrank.com/challenges/ctci-ice-cream-parlor/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=search)|Help Sunny and Johnny spend all their money during each trip to the Ice Cream Parlor.|[Python](../../tutorials/cracking-the-coding-interview/ctci-ice-cream-parlor.py)|Medium
[Pairs](https://www.hackerrank.com/challenges/pairs/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=search)|Given N numbers, count the total pairs of numbers that have a difference of K.|[Python](../../algorithms/search/pairs.py)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Interview Preparation Kit](https://www.hackerrank.com/interview/interview-preparation-kit)
#### [Recursion and Backtracking](https://www.hackerrank.com/interview/interview-preparation-kit/recursion-backtracking/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Recursion: Fibonacci Numbers](https://www.hackerrank.com/challenges/ctci-fibonacci-numbers/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=recursion-backtracking)|Compute the $n^{th}$ Fibonacci number.|[C++](../../tutorials/cracking-the-coding-interview/ctci-fibonacci-numbers.cpp)|Easy
[Recursion: Davis' Staircase](https://www.hackerrank.com/challenges/ctci-recursive-staircase/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=recursion-backtracking)|Find the number of ways to get from the bottom of a staircase to the top if you can jump 1, 2, or 3 stairs at a time.|[C++](../../tutorials/cracking-the-coding-interview/ctci-recursive-staircase.cpp)|Medium
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### [Interview Preparation Kit](https://www.hackerrank.com/interview/interview-preparation-kit)
#### [Sorting](https://www.hackerrank.com/interview/interview-preparation-kit/sorting/challenges)
Name | Preview | Code | Difficulty
---- | ------- | ---- | ----------
[Sorting: Bubble Sort](https://www.hackerrank.com/challenges/ctci-bubble-sort/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=sorting)|Find the minimum number of conditional checks taking place in Bubble Sort|[Python](../../tutorials/cracking-the-coding-interview/ctci-bubble-sort.py)|Easy
[Sorting: Comparator](https://www.hackerrank.com/challenges/ctci-comparator-sorting/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=sorting)|Write a Comparator for sorting elements in an array.|[C++](../../tutorials/cracking-the-coding-interview/ctci-comparator-sorting.cpp)|Medium
[Merge Sort: Counting Inversions](https://www.hackerrank.com/challenges/ctci-merge-sort/problem?h_l=playlist&slugs%5B%5D=interview&slugs%5B%5D=interview-preparation-kit&slugs%5B%5D=sorting)|How many shifts will it take to Merge Sort an array?|[Python](../../tutorials/cracking-the-coding-interview/ctci-merge-sort.py)|Hard
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Interview Preparation Kit > Miscellaneous > Friend Circle Queries
# Process the queries and after each query print the number of people largest friend circle.
#
# https://www.hackerrank.com/challenges/friend-circle-queries/problem?h_l=playlist&slugs%5B%5D%5B%5D=interview&slugs%5B%5D%5B%5D=interview-preparation-kit&slugs%5B%5D%5B%5D=miscellaneous
# challenge id: 71478
#
from collections import defaultdict
def solve(L, R):
ref = defaultdict(lambda: len(ref))
members = [[] for i in range(200000)]
groups = [0] * 200000
m = 2 # 2 is always the minimum group size
k = 0
for l, r in zip(L, R):
l = ref[l] # index (<200000) of person l
r = ref[r] # index of person r
a = groups[l] # group number of l
b = groups[r] # group number of r
if a == 0 and b == 0:
# new group
k += 1
groups[l] = k # l and r are belong to the same new group
groups[r] = k
members[k].append(l)
members[k].append(r)
elif a == 0:
# a new friend in the group
groups[l] = b
members[b].append(l) # l becomes friend with r' friends
m = max(m, len(members[b])) # update the max group size
elif b == 0:
# a new friend in the group
groups[r] = a
members[a].append(r) # r becomes friend with l' ones
m = max(m, len(members[a]))
elif a == b:
# already in the same group
pass
elif len(members[a]) > len(members[b]):
# merge of 2 groups of friends
members[a].extend(members[b]) # friends of r will be merged with l' ones
for i in members[b]:
groups[i] = a # update group number for the friends of l
members[b] = None # we not longer need this group (it was merged)
m = max(m, len(members[a]))
else:
# merge of 2 groups of friends
members[b].extend(members[a])
for i in members[a]:
groups[i] = b
members[a] = None
m = max(m, len(members[b]))
print(m)
q = int(input())
L = list(map(int, input().rstrip().split()))
R = list(map(int, input().rstrip().split()))
solve(L, R)
""" trivial and Time Limit Exceed solution
def solve(L, R):
groups = {}
m = 0
for l, r in zip(L, R):
u = set([l, r])
if l in groups: u |= groups[l]
if r in groups: u |= groups[r]
for i in u:
groups[i] = u
l = len(u)
if m < l: m = l
print(m)
"""
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
add_hackerrank_py(friend-circle-queries.py)
add_hackerrank(maximum-xor maximum-xor.cpp)
| {
"repo_name": "rene-d/hackerrank",
"stars": "65",
"repo_language": "Python",
"file_name": "README.md",
"mime_type": "text/plain"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.