0% found this document useful (0 votes)
12 views22 pages

200 String Exercises

The document contains a list of 200 medium to hard C string manipulation exercises, each with a specific assignment name, expected file name, allowed functions, and a brief description of the task. Examples include reversing words while preserving spaces, capitalizing the first letter of each word, and checking for anagrams. The exercises are designed for practice without using dynamic memory allocation, focusing on standard stack-based operations.

Uploaded by

Ridoine Zak
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views22 pages

200 String Exercises

The document contains a list of 200 medium to hard C string manipulation exercises, each with a specific assignment name, expected file name, allowed functions, and a brief description of the task. Examples include reversing words while preserving spaces, capitalizing the first letter of each word, and checking for anagrams. The exercises are designed for practice without using dynamic memory allocation, focusing on standard stack-based operations.

Uploaded by

Ridoine Zak
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

// File: 200_string_manipulation_exercises // Description: 200 medium→hard C string-manipulation

exercises formatted like exam subjects. // NOTE: None of these exercises require malloc/calloc. Allowed
functions are limited to write/read/open/close and standard stack-based operations.

// ---------------------------------------------------------------------------- // 1) Assignment name :


rev_each_word_preserve_spaces // Expected files : rev_each_word_preserve_spaces.c // Allowed functions:
write, read // Version : 1 // -------------------------------------------------------------------------------- // Reverse characters of
every word but preserve original spacing exactly. // Example: " hello world " -> " olleh dlrow "

// ---------------------------------------------------------------------------- // 2) Assignment name : cap_first_letter_each_word //


Expected files : cap_first_letter_each_word.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Capitalize the first alphabetical character of each
word. Words separated by spaces/tabs.

// ---------------------------------------------------------------------------- // 3) Assignment name : swap_case_alphabetic //


Expected files : swap_case_alphabetic.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Swap case for every ASCII alphabetic character.
Preserve non-letters.

// ---------------------------------------------------------------------------- // 4) Assignment name :


remove_repeated_consecutive_chars // Expected files : remove_repeated_consecutive_chars.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Replace runs of
the same character with a single instance (e.g., "aaabb" -> "ab").

// ---------------------------------------------------------------------------- // 5) Assignment name : rotate_left_n_mod_len //


Expected files : rotate_left_n_mod_len.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Rotate string left by n (mod length). If no args,
print newline.

// ---------------------------------------------------------------------------- // 6) Assignment name : rotate_right_n_mod_len //


Expected files : rotate_right_n_mod_len.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Rotate string right by n (mod length).

// ---------------------------------------------------------------------------- // 7) Assignment name :


check_anagram_count_table // Expected files : check_anagram_count_table.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Check if two strings are anagrams
using a 256-byte frequency table (no sorting).

// ---------------------------------------------------------------------------- // 8) Assignment name :


replace_substring_non_overlapping // Expected files : replace_substring_non_overlapping.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Replace non-
overlapping occurrences of needle with replacement. Input: haystack needle replacement.

// ---------------------------------------------------------------------------- // 9) Assignment name :


remove_all_chars_with_multiple_occurrences // Expected files :
remove_all_chars_with_multiple_occurrences.c // Allowed functions: write // Version : 1 //

1
-------------------------------------------------------------------------------- // Remove characters that appear more than once in
the string (keep only chars with single occurrence).

// ---------------------------------------------------------------------------- // 10) Assignment name :


first_non_repeating_char_index // Expected files : first_non_repeating_char_index.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Print index (0-based) of first
non-repeating char or -1.

// ---------------------------------------------------------------------------- // 11) Assignment name :


count_words_custom_delims // Expected files : count_words_custom_delims.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Count words separated by any of
given delimiter chars (passed as second arg string).

// ---------------------------------------------------------------------------- // 12) Assignment name :


split_into_tokens_print_each // Expected files : split_into_tokens_print_each.c // Allowed functions: write,
read // Version : 1 // -------------------------------------------------------------------------------- // Split input on whitespace and
print one token per line. Do not use strtok.

// ---------------------------------------------------------------------------- // 13) Assignment name : reverse_vowels_inplace //


Expected files : reverse_vowels_inplace.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Reverse only vowels (a,e,i,o,u,A,E,I,O,U) in the
string, in place.

// ---------------------------------------------------------------------------- // 14) Assignment name :


palindrome_ignore_space_case_punc // Expected files : palindrome_ignore_space_case_punc.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Check palindrome
ignoring spaces, punctuation and case. Print "OK" or "KO".

// ---------------------------------------------------------------------------- // 15) Assignment name :


remove_word_whole_match // Expected files : remove_word_whole_match.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Remove exact whole-word
occurrences (match boundaries) of a target word.

// ---------------------------------------------------------------------------- // 16) Assignment name :


longest_and_second_longest_word // Expected files : longest_and_second_longest_word.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Print longest and
second-longest words from sentence. If tie, choose first occurrence.

// ---------------------------------------------------------------------------- // 17) Assignment name :


swap_first_and_last_chars_in_words // Expected files : swap_first_and_last_chars_in_words.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // For each word
swap its first and last characters. Single-letter words unchanged.

// ---------------------------------------------------------------------------- // 18) Assignment name :


reverse_word_order_preserve_spaces // Expected files : reverse_word_order_preserve_spaces.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Reverse order of
words while preserving spacing between words exactly as original.

2
// ---------------------------------------------------------------------------- // 19) Assignment name :
ascii_char_frequency_sorted // Expected files : ascii_char_frequency_sorted.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Print characters that appear along
with counts sorted by ASCII code ascending.

// ---------------------------------------------------------------------------- // 20) Assignment name : is_rotation_using_concat //


Expected files : is_rotation_using_concat.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Check if s2 is rotation of s1 by searching s2 in
s1+s1 without using dynamic alloc.

// ---------------------------------------------------------------------------- // 21) Assignment name :


dedup_consecutive_words // Expected files : dedup_consecutive_words.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Remove consecutive duplicate words
(e.g., "is is a test" -> "is a test").

// ---------------------------------------------------------------------------- // 22) Assignment name : alternate_merge_strings //


Expected files : alternate_merge_strings.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Merge two strings character by character. If
lengths differ, append remainder.

// ---------------------------------------------------------------------------- // 23) Assignment name : check_unique_chars_ascii //


Expected files : check_unique_chars_ascii.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Check if string has all unique ASCII characters
using fixed 256-byte array on stack.

// ---------------------------------------------------------------------------- // 24) Assignment name :


longest_repeated_nonoverlapping_substr // Expected files : longest_repeated_nonoverlapping_substr.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // Find
longest substring that appears at least twice without overlapping.

// ---------------------------------------------------------------------------- // 25) Assignment name : rle_encode_simple //


Expected files : rle_encode_simple.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Run-length encode consecutive identical chars
into c<count> (count as decimal).

// ---------------------------------------------------------------------------- // 26) Assignment name : rle_decode_simple //


Expected files : rle_decode_simple.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Decode a RLE encoded string where digits follow
letters (e.g., a3b2 -> aaabb).

// ---------------------------------------------------------------------------- // 27) Assignment name :


print_all_permutations_recursive // Expected files : print_all_permutations_recursive.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Print all permutations of up
to 8-char strings (use recursion and in-place swaps).

// ---------------------------------------------------------------------------- // 28) Assignment name :


list_all_palindromic_substrings_unique // Expected files : list_all_palindromic_substrings_unique.c // Allowed

3
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Print each
palindrome substring once, order not important.

// ---------------------------------------------------------------------------- // 29) Assignment name :


word_count_map_print_order // Expected files : word_count_map_print_order.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Count words and print "word:count"
in order of first appearance.

// ---------------------------------------------------------------------------- // 30) Assignment name :


remove_chars_present_in_second // Expected files : remove_chars_present_in_second.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Given two strings, remove
from first all characters that appear in second.

// ---------------------------------------------------------------------------- // 31) Assignment name : strcasecmp_simple //


Expected files : strcasecmp_simple.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Implement case-insensitive comparison printing 0
if equal, -1 or 1 otherwise.

// ---------------------------------------------------------------------------- // 32) Assignment name : strstr_index_first //


Expected files : strstr_index_first.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Print index of first occurrence of needle in
haystack or -1.

// ---------------------------------------------------------------------------- // 33) Assignment name : find_substr_within_n //


Expected files : find_substr_within_n.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Find needle inside first n characters of haystack;
print index or -1.

// ---------------------------------------------------------------------------- // 34) Assignment name :


reverse_string_recursion_only // Expected files : reverse_string_recursion_only.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Reverse a string using recursion only
(no loops).

// ---------------------------------------------------------------------------- // 35) Assignment name : to_kebab_case // Expected


files : to_kebab_case.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Convert string to kebab-case: lowercase, spaces
and underscores to hyphens, remove non-alphanum except hyphen.

// ---------------------------------------------------------------------------- // 36) Assignment name :


read_line_and_print_first_token // Expected files : read_line_and_print_first_token.c // Allowed functions:
read, write // Version : 1 // -------------------------------------------------------------------------------- // Read from stdin a line
and print the first whitespace-delimited token.

// ---------------------------------------------------------------------------- // 37) Assignment name : gnl_single_line_no_alloc //


Expected files : gnl_single_line_no_alloc.c // Allowed functions: read, write // Version : 1 //
-------------------------------------------------------------------------------- // Implement a single-call get-next-line-like function
reading up to newline using fixed stack buffer and print it.

4
// ---------------------------------------------------------------------------- // 38) Assignment name :
split_preserve_quoted_fields // Expected files : split_preserve_quoted_fields.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Split a line by spaces but keep
quoted tokens (single or double) intact; remove surrounding quotes.

// ---------------------------------------------------------------------------- // 39) Assignment name : parse_simple_shell_args //


Expected files : parse_simple_shell_args.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Tokenize a command-line string into args
handling quotes and backslash escapes.

// ---------------------------------------------------------------------------- // 40) Assignment name :


env_var_expand_from_set // Expected files : env_var_expand_from_set.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Expand occurrences of $VAR using
environment provided as key=value lines on stdin.

// ---------------------------------------------------------------------------- // 41) Assignment name : strip_c_style_comments //


Expected files : strip_c_style_comments.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Remove both // and / / comments from C source
read from stdin; handle string literals correctly.

// ---------------------------------------------------------------------------- // 42) Assignment name : validate_ipv4_strict //


Expected files : validate_ipv4_strict.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Strict IPv4 validation: four decimal numbers 0-255
separated by dots; no leading zeros unless zero.

// ---------------------------------------------------------------------------- // 43) Assignment name : validate_ipv6_basic //


Expected files : validate_ipv6_basic.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Basic IPv6 validation supporting :: abbreviation
and hex groups.

// ---------------------------------------------------------------------------- // 44) Assignment name :


normalize_unix_path_dot_dot // Expected files : normalize_unix_path_dot_dot.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Normalize path removing . and
resolving .. without reading filesystem.

// ---------------------------------------------------------------------------- // 45) Assignment name : wildcard_match_qm_star //


Expected files : wildcard_match_qm_star.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Implement pattern matching with ? and * (glob-
like). Print "YES" or "NO".

// ---------------------------------------------------------------------------- // 46) Assignment name : simple_dot_star_regex //


Expected files : simple_dot_star_regex.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Implement regex with . and * where * applies to
previous token; match full string.

// ---------------------------------------------------------------------------- // 47) Assignment name :


longest_common_substring_dynamic // Expected files : longest_common_substring_dynamic.c // Allowed

5
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Compute
LCSUBSTR of two strings using dynamic programming and print it.

// ---------------------------------------------------------------------------- // 48) Assignment name :


longest_common_subsequence_dp // Expected files : longest_common_subsequence_dp.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Compute LCS
(subsequence) and print one LCS.

// ---------------------------------------------------------------------------- // 49) Assignment name :


rolling_hash_rabin_karp_first_match // Expected files : rolling_hash_rabin_karp_first_match.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Use a rolling hash
to find first occurrence of a pattern. Avoid dynamic alloc.

// ---------------------------------------------------------------------------- // 50) Assignment name :


caesar_cipher_detect_and_decrypt // Expected files : caesar_cipher_detect_and_decrypt.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Given a ciphertext
with simple Caesar shift, try all shifts and print the most English-like candidate (score by vowels frequency).

// ---------------------------------------------------------------------------- // 51) Assignment name : one_edit_distance_check //


Expected files : one_edit_distance_check.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Check if two strings are one edit apart (insert/
delete/replace). Print "YES"/"NO".

// ---------------------------------------------------------------------------- // 52) Assignment name : base64_encode_cli //


Expected files : base64_encode_cli.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Base64 encode input argument and print result.
Use stack buffers only.

// ---------------------------------------------------------------------------- // 53) Assignment name : base64_decode_cli //


Expected files : base64_decode_cli.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Decode base64 from argument and print decoded
bytes as text.

// ---------------------------------------------------------------------------- // 54) Assignment name : url_percent_encode //


Expected files : url_percent_encode.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Percent-encode non-alphanumeric characters and
space as +.

// ---------------------------------------------------------------------------- // 55) Assignment name : url_percent_decode //


Expected files : url_percent_decode.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Decode %HH sequences and + into spaces. Invalid
% sequences make output unchanged.

// ---------------------------------------------------------------------------- // 56) Assignment name :


mini_printf_support_s_only // Expected files : mini_printf_support_s_only.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Implement a tiny printf supporting
only %s and plain text; read format and args.

6
// ---------------------------------------------------------------------------- // 57) Assignment name : mini_scanf_read_token //
Expected files : mini_scanf_read_token.c // Allowed functions: read, write // Version : 1 //
-------------------------------------------------------------------------------- // Read stdin and print first token (non-whitespace).

// ---------------------------------------------------------------------------- // 58) Assignment name :


parse_csv_line_respecting_quotes // Expected files : parse_csv_line_respecting_quotes.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Parse a CSV line handling
quoted fields that may contain commas and quotes.

// ---------------------------------------------------------------------------- // 59) Assignment name :


json_array_of_strings_parser // Expected files : json_array_of_strings_parser.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Parse a simple JSON array of strings
(no nested objects) and print one per line.

// ---------------------------------------------------------------------------- // 60) Assignment name : ini_key_value_parser //


Expected files : ini_key_value_parser.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Parse stdin INI-style lines and print key=value
pairs ignoring comments and section headers.

// ---------------------------------------------------------------------------- // 61) Assignment name :


balanced_brackets_multi_types // Expected files : balanced_brackets_multi_types.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Check balanced (), {}, [] in a
string; ignore characters inside quotes.

// ---------------------------------------------------------------------------- // 62) Assignment name :


remove_nested_parentheses_and_content // Expected files : remove_nested_parentheses_and_content.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // Remove
any nested parentheses content and the parentheses themselves.

// ---------------------------------------------------------------------------- // 63) Assignment name : infix_to_postfix_basic //


Expected files : infix_to_postfix_basic.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Convert infix expression with + - * / and
parentheses into RPN using stack on array.

// ---------------------------------------------------------------------------- // 64) Assignment name :


evaluate_postfix_integers // Expected files : evaluate_postfix_integers.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Evaluate a postfix integer expression
with space-separated tokens and print result.

// ---------------------------------------------------------------------------- // 65) Assignment name :


kmp_prefix_function_search // Expected files : kmp_prefix_function_search.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Implement KMP search using prefix
(pi) function to find first occurrence index.

// ---------------------------------------------------------------------------- // 66) Assignment name :


rabin_karp_modhash_search // Expected files : rabin_karp_modhash_search.c // Allowed functions: write //

7
Version : 1 // -------------------------------------------------------------------------------- // Implement Rabin-Karp with mod
prime rolling hash; print first index or -1.

// ---------------------------------------------------------------------------- // 67) Assignment name : autocomplete_prefix_list //


Expected files : autocomplete_prefix_list.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Read words from stdin and print those starting
with given prefix (argument).

// ---------------------------------------------------------------------------- // 68) Assignment name :


trie_insert_and_search_cli // Expected files : trie_insert_and_search_cli.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Implement a simple trie in static
arrays (no dynamic alloc) and provide insert/search demo.

// ---------------------------------------------------------------------------- // 69) Assignment name : suffix_array_naive //


Expected files : suffix_array_naive.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Build suffix array by sorting suffixes using
comparison that uses indices; print order of starting indices.

// ---------------------------------------------------------------------------- // 70) Assignment name :


suffix_trie_count_occurrences // Expected files : suffix_trie_count_occurrences.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Build a simple suffix-trie (limited size)
using stack arrays and count substring occurrences.

// ---------------------------------------------------------------------------- // 71) Assignment name :


levenshtein_distance_dp_print // Expected files : levenshtein_distance_dp_print.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Compute Levenshtein edit
distance and print integer result.

// ---------------------------------------------------------------------------- // 72) Assignment name :


ngram_similarity_percentage // Expected files : ngram_similarity_percentage.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Compute similarity between two
texts using k-grams (k provided) and print percent to 2 decimals.

// ---------------------------------------------------------------------------- // 73) Assignment name : suggest_spelling_top3 //


Expected files : suggest_spelling_top3.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Given dictionary on stdin and a word arg,
compute top 3 suggestions by edit distance.

// ---------------------------------------------------------------------------- // 74) Assignment name : word_wrap_greedy //


Expected files : word_wrap_greedy.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Wrap paragraph from stdin to max width N
preserving words, greedy algorithm.

// ---------------------------------------------------------------------------- // 75) Assignment name : justify_text_line_by_line //


Expected files : justify_text_line_by_line.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Full-justify text to width N distributing spaces
evenly.

8
// ---------------------------------------------------------------------------- // 76) Assignment name :
shell_like_tokenizer_pipes_redir // Expected files : shell_like_tokenizer_pipes_redir.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Tokenize shell line into
words, pipes '|' and redirections '>' '<' as separate tokens.

// ---------------------------------------------------------------------------- // 77) Assignment name :


parse_key_value_pairs_from_string // Expected files : parse_key_value_pairs_from_string.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Parse space-
separated KEY=VALUE pairs into lines key=value trimmed.

// ---------------------------------------------------------------------------- // 78) Assignment name : heredoc_simulation //


Expected files : heredoc_simulation.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Read stdin until a line matching delimiter arg
appears; print collected content.

// ---------------------------------------------------------------------------- // 79) Assignment name : safe_string_concat_stack //


Expected files : safe_string_concat_stack.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Concatenate up to many arguments into a stack-
allocated buffer with truncation and print.

// ---------------------------------------------------------------------------- // 80) Assignment name :


printf_width_precision_string_only // Expected files : printf_width_precision_string_only.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Implement width
and precision formatting for strings: %[Link] semantics.

// ---------------------------------------------------------------------------- // 81) Assignment name : utf8_codepoint_count //


Expected files : utf8_codepoint_count.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Count Unicode codepoints in a UTF-8 string; treat
invalid continuation bytes as replacement characters.

// ---------------------------------------------------------------------------- // 82) Assignment name : utf8_to_ascii_best_effort //


Expected files : utf8_to_ascii_best_effort.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Convert UTF-8 to ASCII replacing diacritics with
base letters where possible (e.g., é->e) otherwise '?'.

// ---------------------------------------------------------------------------- // 83) Assignment name :


boyer_moore_badchar_search // Expected files : boyer_moore_badchar_search.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Implement Boyer-Moore
search using bad-character heuristic only; print first index or -1.

// ---------------------------------------------------------------------------- // 84) Assignment name :


simple_diff_chars_context // Expected files : simple_diff_chars_context.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Show single-line diff between two
strings marking deletions with '-' and additions with '+' in short context.

// ---------------------------------------------------------------------------- // 85) Assignment name :


apply_simple_patch_hunks // Expected files : apply_simple_patch_hunks.c // Allowed functions: write //

9
Version : 1 // -------------------------------------------------------------------------------- // Apply very small unified-diff-style
hunks to base string from stdin and print patched text.

// ---------------------------------------------------------------------------- // 86) Assignment name :


grep_like_substring_search // Expected files : grep_like_substring_search.c // Allowed functions: write,
read // Version : 1 // -------------------------------------------------------------------------------- // Print lines from stdin
containing a given substring argument.

// ---------------------------------------------------------------------------- // 87) Assignment name : sed_substitute_simple //


Expected files : sed_substitute_simple.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Substitute first or all occurrences of a literal
pattern in a line; support 'g' flag for global.

// ---------------------------------------------------------------------------- // 88) Assignment name :


tokenize_simple_language // Expected files : tokenize_simple_language.c // Allowed functions: write, read //
Version : 1 // -------------------------------------------------------------------------------- // Tokenize a toy language (identifiers,
numbers, strings, operators) and print tokens with types.

// ---------------------------------------------------------------------------- // 89) Assignment name :


simple_lexer_with_positions // Expected files : simple_lexer_with_positions.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Produce tokens with line:col
positions for a tiny input language; print each token with its position.

// ---------------------------------------------------------------------------- // 90) Assignment name :


highlight_keywords_in_code // Expected files : highlight_keywords_in_code.c // Allowed functions: write,
read // Version : 1 // -------------------------------------------------------------------------------- // Read code from stdin and
wrap keywords (e.g., int, return) in markers [KW]...[/KW].

// ---------------------------------------------------------------------------- // 91) Assignment name :


markdown_heading_and_bold_to_html // Expected files : markdown_heading_and_bold_to_html.c // Allowed
functions: write, read // Version : 1 // -------------------------------------------------------------------------------- // Convert
simple markdown headings (#) and bold (text) to HTML fragments.

// ---------------------------------------------------------------------------- // 92) Assignment name :


strip_html_tags_and_decode_basic_entities // Expected files : strip_html_tags_and_decode_basic_entities.c //
Allowed functions: write, read // Version : 1 // -------------------------------------------------------------------------------- //
Remove HTML tags and decode & < > entities; print plain text.

// ---------------------------------------------------------------------------- // 93) Assignment name :


html_entity_decode_numeric_named // Expected files : html_entity_decode_numeric_named.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Decode numeric
(&#NNN;) and named ( , &) entities in input string.

// ---------------------------------------------------------------------------- // 94) Assignment name :


mini_text_buffer_commands // Expected files : mini_text_buffer_commands.c // Allowed functions: write,
read // Version : 1 // -------------------------------------------------------------------------------- // Implement simple buffer with
commands: I pos text, D pos len, P prints buffer.

10
// ---------------------------------------------------------------------------- // 95) Assignment name : split_keep_delimiters //
Expected files : split_keep_delimiters.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Split by delimiter but include delimiters as
separate tokens in output.

// ---------------------------------------------------------------------------- // 96) Assignment name :


detect_duplicate_words_anywhere // Expected files : detect_duplicate_words_anywhere.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Detect any
repeated word anywhere in sentence and print the first repeated one.

// ---------------------------------------------------------------------------- // 97) Assignment name :


find_longest_palindromic_substring_manacher // Expected files :
find_longest_palindromic_substring_manacher.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Implement Manacher's algorithm to find longest
palindromic substring and print it.

// ---------------------------------------------------------------------------- // 98) Assignment name :


detect_and_unescape_c_escapes // Expected files : detect_and_unescape_c_escapes.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Replace C-style escapes (\n,
\t, \xHH, \uHHHH) in a string argument with their actual characters.

// ---------------------------------------------------------------------------- // 99) Assignment name : escape_c_special_chars //


Expected files : escape_c_special_chars.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Convert control and special chars into C escape
sequences (e.g., newline -> \n) for printing.

// ---------------------------------------------------------------------------- // 100) Assignment name : longest_prefix_suffix //


Expected files : longest_prefix_suffix.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Find longest proper prefix of a string that is also a
suffix (border) and print length.

// ---------------------------------------------------------------------------- // 101) Assignment name :


compute_prefix_function_array // Expected files : compute_prefix_function_array.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Compute the KMP prefix-
function (pi array) for a string and print values space-separated.

// ---------------------------------------------------------------------------- // 102) Assignment name : rotate_words_by_k //


Expected files : rotate_words_by_k.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Rotate order of words by k positions (positive ->
right, negative -> left); preserve whitespace trimmed.

// ---------------------------------------------------------------------------- // 103) Assignment name :


find_all_anagrams_of_pattern // Expected files : find_all_anagrams_of_pattern.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Find all start indices where an
anagram of pattern appears in text.

11
// ---------------------------------------------------------------------------- // 104) Assignment name :
check_isomorphic_strings // Expected files : check_isomorphic_strings.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Check if two strings are isomorphic
(one-to-one char mapping) and print YES/NO.

// ---------------------------------------------------------------------------- // 105) Assignment name :


shortest_unique_substring_for_each_pos // Expected files : shortest_unique_substring_for_each_pos.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // For each
starting index in string, find shortest substring that does not appear elsewhere and print positions and
lengths.

// ---------------------------------------------------------------------------- // 106) Assignment name : strip_control_chars //


Expected files : strip_control_chars.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Remove ASCII control characters (0-31 except
newline/tab) from input and print result.

// ---------------------------------------------------------------------------- // 107) Assignment name : rotate_words_charwise //


Expected files : rotate_words_charwise.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // For each word rotate its characters by a given n;
non-word characters unchanged.

// ---------------------------------------------------------------------------- // 108) Assignment name :


merge_adjacent_numbers // Expected files : merge_adjacent_numbers.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Replace sequences where numbers
are separated only by spaces with a single number formed by concatenation.

// ---------------------------------------------------------------------------- // 109) Assignment name :


compress_whitespace_to_single_space // Expected files : compress_whitespace_to_single_space.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Replace any
sequence of whitespace with a single space and trim ends.

// ---------------------------------------------------------------------------- // 110) Assignment name : expand_tabs_to_spaces //


Expected files : expand_tabs_to_spaces.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Replace tab characters with spaces to reach next
tab stop (tab width provided as arg).

// ---------------------------------------------------------------------------- // 111) Assignment name :


collapse_spaces_preserve_leading // Expected files : collapse_spaces_preserve_leading.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Reduce multiple
internal spaces to single but preserve leading indentation.

// ---------------------------------------------------------------------------- // 112) Assignment name :


split_on_multiple_delims // Expected files : split_on_multiple_delims.c // Allowed functions: write // Version :
1 // -------------------------------------------------------------------------------- // Split using any char from delimiter string and
print tokens one per line.

12
// ---------------------------------------------------------------------------- // 113) Assignment name :
join_strings_with_separator // Expected files : join_strings_with_separator.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Join argv[1..n-1] with separator
argv[n] and print result using stack buffers.

// ---------------------------------------------------------------------------- // 114) Assignment name :


remove_prefix_if_present // Expected files : remove_prefix_if_present.c // Allowed functions: write // Version :
1 // -------------------------------------------------------------------------------- // Remove given prefix from string if present
and print resulting string.

// ---------------------------------------------------------------------------- // 115) Assignment name :


remove_suffix_if_present // Expected files : remove_suffix_if_present.c // Allowed functions: write // Version :
1 // -------------------------------------------------------------------------------- // Remove given suffix from string if present and
print result.

// ---------------------------------------------------------------------------- // 116) Assignment name :


compare_version_strings // Expected files : compare_version_strings.c // Allowed functions: write // Version :
1 // -------------------------------------------------------------------------------- // Compare dotted version strings "1.2.10" vs
"1.2.3" and print -1/0/1 accordingly.

// ---------------------------------------------------------------------------- // 117) Assignment name :


strip_duplicate_punctuation // Expected files : strip_duplicate_punctuation.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Replace repeated punctuation marks
with a single instance (e.g., "!!!" -> "!").

// ---------------------------------------------------------------------------- // 118) Assignment name :


annotate_word_positions // Expected files : annotate_word_positions.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Print each word followed by its start
index in the original string.

// ---------------------------------------------------------------------------- // 119) Assignment name :


find_substring_occurrence_counts // Expected files : find_substring_occurrence_counts.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Count non-
overlapping occurrences of a needle in a haystack and print count.

// ---------------------------------------------------------------------------- // 120) Assignment name :


find_overlapping_substring_occurrences // Expected files : find_overlapping_substring_occurrences.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // Count
overlapping occurrences of needle in haystack and print count.

// ---------------------------------------------------------------------------- // 121) Assignment name : is_subsequence //


Expected files : is_subsequence.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Check if s1 is a subsequence of s2; print YES/NO.

// ---------------------------------------------------------------------------- // 122) Assignment name :


normalize_unicode_whitespace // Expected files : normalize_unicode_whitespace.c // Allowed functions:

13
write // Version : 1 // -------------------------------------------------------------------------------- // Replace Unicode whitespace
characters with ASCII spaces and trim duplicates.

// ---------------------------------------------------------------------------- // 123) Assignment name : levenshtein_threshold //


Expected files : levenshtein_threshold.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Compute edit distance and only print YES if
distance <= threshold arg else NO.

// ---------------------------------------------------------------------------- // 124) Assignment name :


split_preserve_escape_sequences // Expected files : split_preserve_escape_sequences.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Split tokens by whitespace
but keep escaped spaces (\ ) inside tokens.

// ---------------------------------------------------------------------------- // 125) Assignment name :


remove_trailing_whitespace_lines // Expected files : remove_trailing_whitespace_lines.c // Allowed functions:
write, read // Version : 1 // -------------------------------------------------------------------------------- // Remove trailing
whitespace from every input line read from stdin and print.

// ---------------------------------------------------------------------------- // 126) Assignment name :


count_unique_words_case_insensitive // Expected files : count_unique_words_case_insensitive.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Count unique
words ignoring case and punctuation and print count.

// ---------------------------------------------------------------------------- // 127) Assignment name :


detect_repeated_character_runs // Expected files : detect_repeated_character_runs.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Find runs longer than given k
and print their character and positions.

// ---------------------------------------------------------------------------- // 128) Assignment name :


swap_adjacent_words_every_two // Expected files : swap_adjacent_words_every_two.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Swap words pairwise: "a b c d
e" -> "b a d c e".

// ---------------------------------------------------------------------------- // 129) Assignment name :


longest_alternating_char_substring // Expected files : longest_alternating_char_substring.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Find longest
substring where adjacent chars alternate between letters and digits or between cases.

// ---------------------------------------------------------------------------- // 130) Assignment name :


remove_accents_basic_map // Expected files : remove_accents_basic_map.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Map common accented Latin letters
to their ASCII equivalents (é->e, ñ->n) using static table.

// ---------------------------------------------------------------------------- // 131) Assignment name :


detect_duplicate_sentences // Expected files : detect_duplicate_sentences.c // Allowed functions: write,
read // Version : 1 // -------------------------------------------------------------------------------- // Read paragraphs and detect
identical sentences (ignoring punctuation and case).

14
// ---------------------------------------------------------------------------- // 132) Assignment name :
build_and_search_ngram_index // Expected files : build_and_search_ngram_index.c // Allowed functions:
write, read // Version : 1 // -------------------------------------------------------------------------------- // Build k-gram index of
stdin text (k arg) and print lines where a query k-gram appears.

// ---------------------------------------------------------------------------- // 133) Assignment name :


normalize_casefold_unicode_ascii_only // Expected files : normalize_casefold_unicode_ascii_only.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Case-fold ASCII
letters to lowercase; for non-ASCII leave unchanged or replaced by '?'.

// ---------------------------------------------------------------------------- // 134) Assignment name :


longest_run_of_same_type // Expected files : longest_run_of_same_type.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Find longest run of characters of
same class (lowercase, uppercase, digit, other) and print class and length.

// ---------------------------------------------------------------------------- // 135) Assignment name :


simple_supertags_extractor // Expected files : simple_supertags_extractor.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Extract and print all @mentions and
#hashtags from text preserving order.

// ---------------------------------------------------------------------------- // 136) Assignment name :


mask_sensitive_info_digits // Expected files : mask_sensitive_info_digits.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Replace sequences of digits longer
than N with asterisks of same length.

// ---------------------------------------------------------------------------- // 137) Assignment name :


detect_email_like_tokens // Expected files : detect_email_like_tokens.c // Allowed functions: write // Version :
1 // -------------------------------------------------------------------------------- // Find tokens that look like emails
(local@domain) and print them.

// ---------------------------------------------------------------------------- // 138) Assignment name :


normalize_phone_numbers_simple // Expected files : normalize_phone_numbers_simple.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Convert phone-like
digit sequences into normalized +country-area-local form using given rules.

// ---------------------------------------------------------------------------- // 139) Assignment name :


split_keep_quoted_commas_csv // Expected files : split_keep_quoted_commas_csv.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Parse CSV from stdin
preserving commas inside quotes and print fields per line.

// ---------------------------------------------------------------------------- // 140) Assignment name :


detect_and_remove_bom // Expected files : detect_and_remove_bom.c // Allowed functions: write, read //
Version : 1 // -------------------------------------------------------------------------------- // Detect UTF-8 BOM (0xEF,0xBB,0xBF)
at start of input and remove it before printing.

// ---------------------------------------------------------------------------- // 141) Assignment name :


flatten_multiple_lines_to_paragraphs // Expected files : flatten_multiple_lines_to_paragraphs.c // Allowed

15
functions: write, read // Version : 1 // -------------------------------------------------------------------------------- // Collapse
input lines into paragraphs separated by blank lines and print paragraphs on single lines.

// ---------------------------------------------------------------------------- // 142) Assignment name : extract_urls_basic //


Expected files : extract_urls_basic.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Find substrings starting with http:// or https://
until whitespace and print each URL.

// ---------------------------------------------------------------------------- // 143) Assignment name :


shorten_repeated_words_count // Expected files : shorten_repeated_words_count.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Replace N repeated
occurrences of a word with "word(xN)" notation.

// ---------------------------------------------------------------------------- // 144) Assignment name :


escape_regex_special_chars // Expected files : escape_regex_special_chars.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Given a literal string, produce a
version escaped for regex usage (escape . * ? + [ ] ( ) { } | ^ $ ).

// ---------------------------------------------------------------------------- // 145) Assignment name :


find_longest_substring_without_repeating_chars // Expected files :
find_longest_substring_without_repeating_chars.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Sliding-window algorithm to find length and
substring of the longest span without repeated chars.

// ---------------------------------------------------------------------------- // 146) Assignment name :


generate_all_combinations_of_chars_k // Expected files : generate_all_combinations_of_chars_k.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Print all k-length
combinations (with repetition) of given alphabet (arg) in lexicographic order.

// ---------------------------------------------------------------------------- // 147) Assignment name :


compress_common_prefixes_list // Expected files : compress_common_prefixes_list.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Given newline-separated list
of words, replace long common prefixes with prefix+"*" notation.

// ---------------------------------------------------------------------------- // 148) Assignment name :


split_into_sentences_basic // Expected files : split_into_sentences_basic.c // Allowed functions: write, read //
Version : 1 // -------------------------------------------------------------------------------- // Split text into sentences using .!?
followed by space/newline; print one sentence per line trimmed.

// ---------------------------------------------------------------------------- // 149) Assignment name :


detect_sentence_case_errors // Expected files : detect_sentence_case_errors.c // Allowed functions: write,
read // Version : 1 // -------------------------------------------------------------------------------- // Detect sentences not starting
with uppercase after splitting; print line numbers of errors.

// ---------------------------------------------------------------------------- // 150) Assignment name :


remove_duplicate_adjacent_punctuation // Expected files : remove_duplicate_adjacent_punctuation.c //

16
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // Convert
sequences like "!?!!" into single punctuation based on last char (choose last).

// ---------------------------------------------------------------------------- // 151) Assignment name :


find_min_window_substring_contains_all_chars // Expected files :
find_min_window_substring_contains_all_chars.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Given S and T, find minimal substring of S that
contains all chars of T (with counts) and print it.

// ---------------------------------------------------------------------------- // 152) Assignment name :


canonicalize_query_string_params // Expected files : canonicalize_query_string_params.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Given URL query
"b=2&a=1", sort params lexicographically and print canonical form.

// ---------------------------------------------------------------------------- // 153) Assignment name :


percent_encode_query_keys_values // Expected files : percent_encode_query_keys_values.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Percent-encode
keys and values of query string and print encoded query.

// ---------------------------------------------------------------------------- // 154) Assignment name :


canonicalize_unicode_nfd_to_nfc_like // Expected files : canonicalize_unicode_nfd_to_nfc_like.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Using a small
mapping table, normalize common decomposed sequences to composed forms for a subset of characters.

// ---------------------------------------------------------------------------- // 155) Assignment name :


detect_ambiguous_quoting_errors // Expected files : detect_ambiguous_quoting_errors.c // Allowed
functions: write, read // Version : 1 // -------------------------------------------------------------------------------- // Detect lines
in stdin where quotes are opened but not closed and print their line numbers.

// ---------------------------------------------------------------------------- // 156) Assignment name :


split_key_value_pairs_with_quotes // Expected files : split_key_value_pairs_with_quotes.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Split pairs like
key="value with spaces" into key and value respecting quotes.

// ---------------------------------------------------------------------------- // 157) Assignment name :


find_all_palindromic_pairs // Expected files : find_all_palindromic_pairs.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Given list of words, find pairs that
when concatenated form palindromes; print pairs indices.

// ---------------------------------------------------------------------------- // 158) Assignment name :


find_repeated_substring_k_times // Expected files : find_repeated_substring_k_times.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Find the substring that
repeats k times consecutively and print its start index and length.

// ---------------------------------------------------------------------------- // 159) Assignment name :


split_camel_case_to_words // Expected files : split_camel_case_to_words.c // Allowed functions: write //

17
Version : 1 // -------------------------------------------------------------------------------- // Convert CamelCase or camelCase
into space-separated words: "CamelCase" -> "Camel Case".

// ---------------------------------------------------------------------------- // 160) Assignment name : to_title_case // Expected


files : to_title_case.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Convert sentence to Title Case but preserve small
words (a, an, the) lowercase unless first word.

// ---------------------------------------------------------------------------- // 161) Assignment name :


longest_common_prefix_of_words // Expected files : longest_common_prefix_of_words.c // Allowed
functions: write // Version : 1 // -------------------------------------------------------------------------------- // Given list of words,
find longest common prefix among all and print it.

// ---------------------------------------------------------------------------- // 162) Assignment name :


rotate_matrix_of_chars_90deg // Expected files : rotate_matrix_of_chars_90deg.c // Allowed functions: write
// Version : 1 // -------------------------------------------------------------------------------- // Interpret stdin as fixed-width char
matrix and rotate it 90 degrees clockwise; print result.

// ---------------------------------------------------------------------------- // 163) Assignment name : snake_to_camel_case //


Expected files : snake_to_camel_case.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Convert snake_case to camelCase.

// ---------------------------------------------------------------------------- // 164) Assignment name :


detect_url_domain_counts // Expected files : detect_url_domain_counts.c // Allowed functions: write, read //
Version : 1 // -------------------------------------------------------------------------------- // Extract domains from URLs in stdin
and print counts per domain in arbitrary order.

// ---------------------------------------------------------------------------- // 165) Assignment name :


longest_common_subsequence_multiple // Expected files : longest_common_subsequence_multiple.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // Compute
an LCS among three strings and print one common subsequence.

// ---------------------------------------------------------------------------- // 166) Assignment name :


split_and_trim_each_token // Expected files : split_and_trim_each_token.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Split by comma and trim whitespace
around each token, print one per line.

// ---------------------------------------------------------------------------- // 167) Assignment name :


bracketed_expression_extractor // Expected files : bracketed_expression_extractor.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Extract top-level bracketed
expressions ([]) from string and print them.

// ---------------------------------------------------------------------------- // 168) Assignment name :


collapse_duplicate_words_case_insensitive // Expected files : collapse_duplicate_words_case_insensitive.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // Remove
duplicate words ignoring case preserving the first occurrence order.

18
// ---------------------------------------------------------------------------- // 169) Assignment name : fuzzy_search_simple //
Expected files : fuzzy_search_simple.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Find if pattern is present in text allowing up to k
mismatches; print first match index or -1.

// ---------------------------------------------------------------------------- // 170) Assignment name :


split_to_columns_by_width_preserve_words // Expected files :
split_to_columns_by_width_preserve_words.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Break paragraph into lines of max width N
without breaking words and print lines.

// ---------------------------------------------------------------------------- // 171) Assignment name :


mask_email_localpart_preserve_domain // Expected files : mask_email_localpart_preserve_domain.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // Replace
local part of email with first char and *** preserving domain (e.g., j***@[Link]).

// ---------------------------------------------------------------------------- // 172) Assignment name :


detect_repetition_pattern_period // Expected files : detect_repetition_pattern_period.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Detect smallest period p
such that string is made of repeated substring of length p; print p or -1.

// ---------------------------------------------------------------------------- // 173) Assignment name :


split_on_numeric_boundaries // Expected files : split_on_numeric_boundaries.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Split string into segments where
character type (digit vs non-digit) changes.

// ---------------------------------------------------------------------------- // 174) Assignment name :


canonical_email_localcase_lower // Expected files : canonical_email_localcase_lower.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Normalize email by
lowercasing domain but preserving local-case as provided; print canonical email.

// ---------------------------------------------------------------------------- // 175) Assignment name :


find_longest_substring_with_k_distinct_chars // Expected files :
find_longest_substring_with_k_distinct_chars.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Sliding-window to find longest substring
containing at most k distinct characters; print substring.

// ---------------------------------------------------------------------------- // 176) Assignment name :


extract_between_markers // Expected files : extract_between_markers.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Extract substring between two
marker strings (first occurrence) and print it.

// ---------------------------------------------------------------------------- // 177) Assignment name :


interleave_lines_from_two_inputs // Expected files : interleave_lines_from_two_inputs.c // Allowed functions:
write, read // Version : 1 // -------------------------------------------------------------------------------- // Read two files (or stdin
streams) and print lines alternately from each until both exhausted.

19
// ---------------------------------------------------------------------------- // 178) Assignment name :
split_and_number_paragraphs // Expected files : split_and_number_paragraphs.c // Allowed functions: write,
read // Version : 1 // -------------------------------------------------------------------------------- // Split text into paragraphs
separated by blank lines and print each with paragraph number.

// ---------------------------------------------------------------------------- // 179) Assignment name :


collapse_html_whitespace // Expected files : collapse_html_whitespace.c // Allowed functions: write, read //
Version : 1 // -------------------------------------------------------------------------------- // Collapse sequences of whitespace in
HTML text outside tags into single spaces and trim.

// ---------------------------------------------------------------------------- // 180) Assignment name :


is_palindrome_rotational // Expected files : is_palindrome_rotational.c // Allowed functions: write // Version :
1 // -------------------------------------------------------------------------------- // Check whether any rotation of string is a
palindrome; print YES/NO.

// ---------------------------------------------------------------------------- // 181) Assignment name :


find_suffix_with_max_overlap // Expected files : find_suffix_with_max_overlap.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // For two strings, find largest suffix of
s1 that is a prefix of s2 and print length.

// ---------------------------------------------------------------------------- // 182) Assignment name :


merge_sorted_word_lists_unique // Expected files : merge_sorted_word_lists_unique.c // Allowed functions:
write, read // Version : 1 // -------------------------------------------------------------------------------- // Merge two newline-
separated sorted word lists from stdin and print unique sorted union.

// ---------------------------------------------------------------------------- // 183) Assignment name :


find_overlap_concat_two_strings_minimal // Expected files : find_overlap_concat_two_strings_minimal.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // Find
minimal string that contains both inputs by overlapping suffix/prefix and print it.

// ---------------------------------------------------------------------------- // 184) Assignment name :


normalize_whitespace_and_case_for_comparison // Expected files :
normalize_whitespace_and_case_for_comparison.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Normalize two strings (lowercase, compress
whitespace) and print YES if equal else NO.

// ---------------------------------------------------------------------------- // 185) Assignment name : find_all_indexes_of_char //


Expected files : find_all_indexes_of_char.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Print all positions where a given char appears in
string, space-separated.

// ---------------------------------------------------------------------------- // 186) Assignment name : chunk_string_fixed_size //


Expected files : chunk_string_fixed_size.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Split string into fixed-size chunks N and print each
on new line; last chunk shorter allowed.

20
// ---------------------------------------------------------------------------- // 187) Assignment name :
find_common_suffixes_between_words // Expected files : find_common_suffixes_between_words.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // For list of
words, find and print common suffix of length >= K if exists.

// ---------------------------------------------------------------------------- // 188) Assignment name :


split_string_by_length_ranges // Expected files : split_string_by_length_ranges.c // Allowed functions: write //
Version : 1 // -------------------------------------------------------------------------------- // Given lengths a,b,c, split string into
substrings of those lengths in sequence; print parts.

// ---------------------------------------------------------------------------- // 189) Assignment name :


map_and_replace_words_from_list // Expected files : map_and_replace_words_from_list.c // Allowed
functions: write, read // Version : 1 // -------------------------------------------------------------------------------- // Read
mapping lines "old new" from stdin and replace words in input sentence accordingly.

// ---------------------------------------------------------------------------- // 190) Assignment name :


remove_html_comments // Expected files : remove_html_comments.c // Allowed functions: write, read //
Version : 1 // -------------------------------------------------------------------------------- // Remove <!-- ... --> comments from
HTML content maintaining surrounding text.

// ---------------------------------------------------------------------------- // 191) Assignment name :


generate_ngrams_and_count // Expected files : generate_ngrams_and_count.c // Allowed functions: write,
read // Version : 1 // -------------------------------------------------------------------------------- // Generate all n-grams of size k
from input text and print frequency of each n-gram.

// ---------------------------------------------------------------------------- // 192) Assignment name :


detect_and_fix_unbalanced_quotes_in_pairs // Expected files :
detect_and_fix_unbalanced_quotes_in_pairs.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Detect lines with odd number of quotes and
attempt to fix by appending closing quote; print fixed text.

// ---------------------------------------------------------------------------- // 193) Assignment name :


simple_sentiment_word_counter // Expected files : simple_sentiment_word_counter.c // Allowed functions:
write, read // Version : 1 // -------------------------------------------------------------------------------- // Given lists of positive
and negative words on stdin, count occurrences in text and print score = pos-neg.

// ---------------------------------------------------------------------------- // 194) Assignment name :


detect_embedded_base64_blocks // Expected files : detect_embedded_base64_blocks.c // Allowed functions:
write, read // Version : 1 // -------------------------------------------------------------------------------- // Scan text and detect
substrings that look like base64 blocks (length multiple of 4 and valid chars) and print them.

// ---------------------------------------------------------------------------- // 195) Assignment name :


word_shingles_similarity // Expected files : word_shingles_similarity.c // Allowed functions: write, read //
Version : 1 // -------------------------------------------------------------------------------- // Compute Jaccard similarity between
two texts using word shingles of size k and print percentage.

21
// ---------------------------------------------------------------------------- // 196) Assignment name :
find_first_longer_word_than_n // Expected files : find_first_longer_word_than_n.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Print first word in sentence
longer than N characters else print nothing/newline.

// ---------------------------------------------------------------------------- // 197) Assignment name :


remove_enclosed_by_delimiters // Expected files : remove_enclosed_by_delimiters.c // Allowed functions:
write // Version : 1 // -------------------------------------------------------------------------------- // Remove all text enclosed
between two delimiter characters (e.g., remove between '{' and '}') including nested occurrences if specified.

// ---------------------------------------------------------------------------- // 198) Assignment name :


rotate_characters_within_words_by_key // Expected files : rotate_characters_within_words_by_key.c //
Allowed functions: write // Version : 1 // -------------------------------------------------------------------------------- // For each
word, rotate its characters by value derived from a numeric key (key arg mod word length).

// ---------------------------------------------------------------------------- // 199) Assignment name : detect_url_safe_base64 //


Expected files : detect_url_safe_base64.c // Allowed functions: write, read // Version : 1 //
-------------------------------------------------------------------------------- // Detect and print URL-safe base64 substrings ("-"
and "_" used) and report start positions.

// ---------------------------------------------------------------------------- // 200) Assignment name :


build_compact_automaton_for_set_of_patterns // Expected files :
build_compact_automaton_for_set_of_patterns.c // Allowed functions: write // Version : 1 //
-------------------------------------------------------------------------------- // Build a small Aho-Corasick style automaton using
fixed-size arrays (no malloc) for a limited alphabet and use it to find occurrences of multiple patterns in text;
print matches as pattern:positions.

// ----------------------------------------------------------------------------

// End of 200 string-manipulation exercises. // All exercises are phrased to avoid dynamic allocation (malloc/
calloc) and to focus on pointer/stack/string algorithms.

22

You might also like