A desert caravan's scribes pass trade instructions between rival guilds using a private cipher, so that anyone overhearing the message cannot act on it. To encode a sentence, a scribe processes its words left to right, numbering them starting at 1. For a word that starts with a vowel ('a', 'e', 'i', 'o', 'u', in either case), the scribe leaves its letters exactly as they are. For a word that starts with a consonant, the scribe removes the first letter and appends it to the end of the word. After that rotation step (or lack of one), every word gets the fixed suffix "elp" appended, and then the letter 'p' is appended once for every position up to and including the word's own position — that is, 'p' repeated i times for the i-th word. The re-encoded words are written back out in their original order, separated by single spaces, forming the trade-code message.
A single line containing the sentence: one or more words separated by single spaces, with no leading or trailing spaces. Each word consists only of English letters (uppercase or lowercase).
A single line: the trade-code message, produced by applying the encoding above to every word of the input sentence in order, words separated by single spaces.
Example 1
Input
I love hiking
Expected
Ielpp ovelelppp ikinghelpppp
Explanation
"I" starts with a vowel so it stays "I", then gets "elp" and one 'p' (position 1): "Ielpp". "love" starts with consonant 'l', so it rotates to "ovel", then gets "elp" and two 'p's (position 2): "ovelelppp". "hiking" starts with consonant 'h', rotates to "ikingh", then gets "elp" and three 'p's (position 3): "ikinghelpppp". Joined: "Ielpp ovelelppp ikinghelpppp".
Example 2
Input
Echo Delta Foxtrot
Expected
Echoelpp eltaDelppp oxtrotFelpppp
Explanation
"Echo" starts with vowel 'E' so it stays "Echo", plus "elp" and one 'p': "Echoelpp". "Delta" starts with consonant 'D', rotates to "eltaD" (case preserved on the moved letter), plus "elp" and two 'p's: "eltaDelppp". "Foxtrot" starts with consonant 'F', rotates to "oxtrotF", plus "elp" and three 'p's: "oxtrotFelpppp". Joined: "Echoelpp eltaDelppp oxtrotFelpppp".
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →