Nimionese
Time limit1sMemory limit256 MB
Each word is rewritten by mapping its first letter to the nearest hard consonant, copying it over later hard consonants, and adding a vowel if it ends in one.
- Level
Easy3 of 10
- Topics
- String, Simulation
- Solved
- No attempts yet
Problem
The Nimions speak a funny form of language. Whichever word they try to say, and whichever language it comes from, it never comes out quite the same. A word from any language turns into Nimionese by these rules.
The hard consonants are b, c, d, g, k, n, p and t. A word is written as one or more syllables joined by the dash character -.
- Every Nimion word starts with a hard consonant, so replace the first letter of the word with the nearest hard consonant. Nearest means the smallest difference of alphabet positions, ignoring case, and a tie picks the letter closer to a. The new letter keeps the case of the letter it replaces. "Each" becomes "Dach".
- A hard consonant in any syllable after the first one sounds remarkably better as the consonant that now starts the word, so replace it. "Hip-po" becomes "Gip-go".
- No word ends in a hard consonant. Drop the dashes, and if the word still ends in a hard consonant, add ah, oh or uh at the end. Pick the vowel nearest that final hard consonant in the alphabet, rounding toward a on a tie. "Dog" becomes "Dogah" and "Hip" becomes "Gipoh".
Apply the rules in this order, to each word of the sentence on its own.
Input
The only line contains a sentence of 1 to 50 words and at most characters. A single space separates two words, and the dash character - separates the syllables inside a word.
Apart from the dashes, the sentence contains only lower-case and upper-case Latin letters, and only the first letter of a word can be upper-case.
Output
Print the sentence from the input translated to Nimionese, on one line, with a single space between two words. Remove every dash. The output fits within characters.