1
\$\begingroup\$

Challenge :

Sort the vowels (only vowels) in the given string .

Note :

  • Vowels are the following characters: A, E, I, O, U
  • Vowel sorting is cyclic i.e. After rearrangement the first vowel of sorted string goes where the original first vowel was

Input :

A string line, the original line (consisting of alphabets and white space only all of them in uppercase (save whitespace))


Output :

A sorted string, the given string with vowels sorted (All in uppercase)

Examples :

Input == STACK EXCHANGE

So the vowels are at index:

A -> 1
E -> 2
A -> 3
E -> 4

On pushing, indexes become:

A -> 1
A -> 2
E -> 3
E -> 4

∴ String will be: STACK AXCHENGE


Input == ZOMBIE BRAINZ

So the vowels are at index:

O -> 1
I -> 2
E -> 3
A -> 4
I -> 5

On pushing, indexes become:

A -> 1
E -> 2
I -> 3
I -> 4
O -> 5

∴ String will be: ZAMBEI BRIONZ


Note :

You will not change the indexes of constants (non-vowels) and white spaces. Only position of vowels will change.


Restriction :

This is so shortest code in bytes for each language wins


\$\endgroup\$
10
  • \$\begingroup\$ @ovs : You will find all vowels in the sentence re arrange them and then replace them with the new position. \$\endgroup\$ Apr 29, 2018 at 14:20
  • \$\begingroup\$ I don't quite understand. Are we supposed to move the vowels (and only the vowels) so that they end up in alphabetical order? Ex. UAEBOI -> AEIBOU \$\endgroup\$ Apr 29, 2018 at 14:21
  • \$\begingroup\$ @Scrooble: No , read the note at the end. Only change the position of vowels but do not change the position of constants. I will give an example \$\endgroup\$ Apr 29, 2018 at 14:22
  • 2
    \$\begingroup\$ @MuhammadSalman I'd call this "sorting" the vowels, not "pushing" them. I'd also remove the "1 position to the left" bit, if I understand properly. \$\endgroup\$ Apr 29, 2018 at 14:25
  • 2
    \$\begingroup\$ @Timtech, most of the solutions to the dupe target will be trivially modified for this challenge - sort lexicographically instead of randomly. \$\endgroup\$
    – Shaggy
    Apr 29, 2018 at 16:40

0

Browse other questions tagged or ask your own question.