111 exercises · 8 challenges passed
42 community
0/7 checkpoints validated
Exercises and challenges written for the community. Practice only: they award no XP.
replace_and_flip
Write a function named replace_and_flip that processes a string and prints the result to standard output using write. All allocated memory must be freed before returning. Rules: - A word is a sequence of non-space characters separated by spaces. - If total words < 9 or total words is even (including empty or space-only strings), print a copy of the string followed by " \n". - If total words >= 9 and odd: 1. Replace 2nd word occurrences with case-flipped 6th word. 2. Replace 6th word with original 2nd word. 3. Insert (total_words + 2) after the middle word. 4. Print transformed string followed by " \n".
identity
Write a function named `identity` that accepts a string `str`. The function must generate and print all numeric sequences of the exact same length as `str` that satisfy the identity matrix rule for `str`: - The digit at position `i` of the output sequence must strictly equal the total number of times the character `str[i]` appears anywhere inside that printed sequence itself. - The arithmetic sum of all digits in the sequence must be equal to the length of `str`. If `str` length is greater than 10, or if no valid sequence exists, the function must print nothing. Multiple valid sequences must be printed in ascending numerical order, each followed by a newline (`\n`).
Brought 6 learners in before Grademe opened