## How to Filter a Number in C

The challenge The number has been mixed up with the text. Your goal is to retrieve the number from the text, can you return the number back to its original state? Task Your task is to return a number from a string. Details You will be given a string of numbers and letters mixed up, you have to return all the numbers in that string in the order they occur....

December 7, 2022 · 2 min · 313 words · Andrew

## How to Take a Ten Minute Walk in C

The challenge You live in the city of Cartesia where all roads are laid out in a perfect grid. You arrived ten minutes too early to an appointment, so you decided to take the opportunity to go for a short walk. The city provides its citizens with a Walk Generating App on their phones — everytime you press the button it sends you an array of one-letter strings representing directions to walk (eg....

December 6, 2022 · 3 min · 596 words · Andrew

## How to Count Stats of a String in C

The challenge You will be given a string and your task will be to return a list of ints detailing the count of uppercase letters, lowercase, numbers and special characters, as follows. Solve("*'&ABCDabcde12345") = [4,5,5,3]. --the order is: uppercase letters, lowercase, numbers and special characters. The solution in C Option 1: void count_char_types (const char *string, unsigned counts[4]) { char c; counts[0] = counts[1] = counts[2] = counts[3] = 0; while((c = *string++)) if(c >= 'A' && c <= 'Z') counts[0]++; else if(c >= 'a' && c <= 'z') counts[1]++; else if(c >= '0' && c <= '9') counts[2]++; else counts[3]++; } Option 2:...

December 5, 2022 · 2 min · 242 words · Andrew

## How to Convert a String to the NATO Phonetic Alphabet in C

The challenge You’ll have to translate a string to Pilot’s alphabet (NATO phonetic alphabet). Input: If, you can read? Output: India Foxtrot , Yankee Oscar Uniform Charlie Alfa November Romeo Echo Alfa Delta ? Note: There are preloaded dictionary you can use, named NATO The set of used punctuation is ,.!?. Punctuation should be kept in your return string, but spaces should not. Xray should not have a dash within. Every word and punctuation mark should be seperated by a space ‘ ‘....

December 4, 2022 · 2 min · 323 words · Andrew

## How to Add 1 to the Value of each Array in C

The challenge Given an array of integers of any length, return an array that has 1 added to the value represented by the array. the array can’t be empty only non-negative, single digit integers are allowed Return nil (or your language’s equivalent) for invalid inputs. Examples: Valid arrays [4, 3, 2, 5] would return [4, 3, 2, 6] [1, 2, 3, 9] would return [1, 2, 4, 0] [9, 9, 9, 9] would return [1, 0, 0, 0, 0]...

December 3, 2022 · 3 min · 538 words · Andrew

## How to Calculate the Sum of a Sequence in C

The challenge Your task is to make function, which returns the sum of a sequence of integers. The sequence is defined by 3 non-negative values: begin, end, step (inclusive). If begin value is greater than the end, function should returns **** Examples 2,2,2 --> 2 2,6,2 --> 12 (2 + 4 + 6) 1,5,1 --> 15 (1 + 2 + 3 + 4 + 5) 1,5,3 --> 5 (1 + 4) The solution in C Option 1:...

December 2, 2022 · 1 min · 187 words · Andrew

## How to Solve the Sum of Triangular Numbers in C

The challenge Your task is to return the sum of Triangular Numbers up-to-and-including the nth Triangular Number. Triangular Number: “any of the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc.” [01] 02 [03] 04 05 [06] 07 08 09 [10] 11 12 13 14 [15] 16 17 18 19 20 [21] e.g. If 4 is given: 1 + 3 + 6 + 10 = 20....

December 1, 2022 · 1 min · 190 words · Andrew

## How to Determine if a String Only Contains Unique Characters in C

The challenge Write a program to determine if a string contains only unique characters. Return true if it does and false otherwise. The string may contain any of the 128 ASCII characters. Characters are case-sensitive, e.g. ‘a’ and ‘A’ are considered different characters. The solution in C Option 1: int has_unique_chars(const char *str) { int mask[128]={0}; while (*str) if (++mask[*str++]>1) return 0; return 1; } Option 2: #include <limits.h> _Bool has_unique_chars(const char *str) { char hit[CHAR_MAX + 1] = {0}; while (*str) { if (*str < 0) { str++; continue; } if (hit[*str]) return 0; hit[*str++] = 1; } return 1; } Option 3:...

November 30, 2022 · 1 min · 184 words · Andrew

## How to Find the Maximum Multiple in C

The challenge Given a Divisor and a Bound , Find the largest integer N , Such That , Conditions : N is divisible by divisor N is less than or equal to bound N is greater than 0. Notes The parameters (divisor, bound) passed to the function are only positive values . It’s guaranteed that a divisor is Found .Input » Output Examples maxMultiple (2,7) ==> return (6) Explanation: (6) is divisible by (2) , (6) is less than or equal to bound (7) , and (6) is > 0 ....

November 29, 2022 · 2 min · 232 words · Andrew

## How to Assign a Digital Cypher in C

The challenge Digital Cypher assigns to each letter of the alphabet unique number. For example: a b c d e f g h i j k l m 1 2 3 4 5 6 7 8 9 10 11 12 13 n o p q r s t u v w x y z 14 15 16 17 18 19 20 21 22 23 24 25 26 Instead of letters in encrypted word we write the corresponding number, eg....

November 28, 2022 · 3 min · 551 words · Andrew