DuolingoOA #3
Replace Nth Consonant
Estimated EasyJudge-ready
Topics (AI-labelled)Strings
Replace every n-th English consonant in message with the next consonant in alphabetical order; preserve case and leave all other characters unchanged. In the source example output CodeTignam, the uppercase T conflicts with the original lowercase s, the case-preservation rule, and the explanation; this site corrects it to Codetignam according to the written rules and the explanation.
Input
Two lines of input: the first line is message (1..200000 ASCII characters, without newlines); the second line is an integer n (1≤n≤200000). Only ASCII A-Z/a-z take part in the consonant check; the vowels are a, e, i, o, u, and y is treated as a consonant; all other ASCII characters are kept as is.
Output
Output the entire transformed message line.
Example 1
Input:
Codesignal
3
Output:
Codetignam
Example 2
Input:
bdf
1
Output:
cfg
Example 3
Input:
xyz
1
Output:
yzb
Editorial
Loading solution…