An old temple inscription is a string of printable ASCII characters: letters (both upper- and lower-case), digits, punctuation, and spaces. Restoring the inscription requires taking only its vowel glyphs -- the characters 'a', 'e', 'i', 'o', 'u' and their upper-case forms 'A', 'E', 'I', 'O', 'U' -- and rearranging them among the positions that currently hold a vowel, so that, reading the string left to right, the vowel characters appear in non-decreasing order of their ASCII code point. Every character that is not a vowel keeps both its original position and its original value.
A single line containing the string s (it may contain leading, trailing, or repeated spaces, so the entire line must be read as given).
Print the resulting string on a single line.
Example 1
Input
Chant Of Ember, Rise!
Expected
ChEnt Of amber, Resi!
Explanation
The vowels, read left to right, are 'a' (Chant), 'O' (Of), 'E' and 'e' (Ember), 'i' and 'e' (Rise). Their ASCII values are E=69, O=79, a=97, e=101, e=101, i=105, so sorted non-decreasing they become E, O, a, e, e, i. Writing these back into the same six vowel positions (leaving 'C','h','n','t',' ','f',' ','m','b','r',',',' ','R','s','!' untouched) gives "ChEnt Of amber, Resi!".
Example 2
Input
Awaken, O Ancient Ember!
Expected
AwAkEn, O anceent embir!
Explanation
The vowels in order are A, a, e, O, A, i, e, E, e with ASCII values 65, 97, 101, 79, 65, 105, 101, 69, 101. Sorted non-decreasing: A, A, E, O, a, e, e, e, i. Placing these into the same nine vowel positions while every consonant, comma, space, and exclamation mark stays put gives "AwAkEn, O anceent embir!".
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 →