A billboard display string is made of English letters (upper or lower case), digits, and the punctuation characters ., -, and _. To create a mirrored effect, only the letters are reversed among themselves; every non-letter character stays exactly where it is.
Concretely, read the letters left to right, reverse that sequence, and place them back into the positions that originally held letters, in order. Non-letter positions are untouched.
Line 1: a non-empty string made of the characters a-z, A-Z, 0-9, ., -, and _.
A single line: the transformed string.
Example 1
Input
ab-cd
Expected
dc-ba
Explanation
Letters a,b,c,d reverse to d,c,b,a and refill the letter slots, leaving '-' fixed: 'dc-ba'.
Example 2
Input
a1b2c3
Expected
c1b2a3
Explanation
Letters a,b,c reverse to c,b,a; digits stay in place, giving 'c1b2a3'.
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 →