+ 12

CHALLENGE: REARRANGE LETTERS 💻⌨️🖱️

Rearrange the letters of the given string so that the vowels and consonants are in the alternate position, and the string so formed must be lexicographic (in alphabetical order) the smallest. Ignore case sensitive. If the string can not be rearranged as desired (for example, in case that vowels=3 letters and consonants=7 letters), print "impossible" or... Examples: Input: sololearn Output: lalenoros Input: baloon Output: abolon Input: string Output: Impossible! All languages are welcome!

30th Nov 2017, 6:21 PM
LukArToDo
LukArToDo - avatar
19 Answers
30th Nov 2017, 7:24 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 27
i didn't made a code //btw here is my idea to do that firstly i will take the inputted string , then separate that string into two strings 1 of vowels & 1 of consonants if (no. of vowels are) <= (no. of consonants) then i will procede further , arrange letters of both strings alphabetically (str_vowels & str_consonants) , then place letters from these two strings in alternate manner in a different string s=""; //then output as s , & if "if condition" is false then output not possible //sorry for no code 😕
3rd Dec 2017, 7:23 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 22
my try on sunday ☺
30th Nov 2017, 7:31 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
30th Nov 2017, 6:22 PM
LukArToDo
LukArToDo - avatar
1st Dec 2017, 9:10 AM
David Akhihiero
David Akhihiero - avatar
+ 9
@Kartik Ignore case sensitive
1st Dec 2017, 11:15 AM
LukArToDo
LukArToDo - avatar
+ 8
When alternating the vowels and consonants, which should start (vowel or consonants).
30th Nov 2017, 6:47 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 7
@Justine If it is the same number of vowels and consonants, then start with the lexicographic smallest letter If the number of consonants is greater than the number of vowels, then you start with consonants. And vice versa.
30th Nov 2017, 6:56 PM
LukArToDo
LukArToDo - avatar
+ 6
Bookmark
30th Nov 2017, 7:34 PM
Louis
Louis - avatar
1st Dec 2017, 11:10 AM
Kartik
Kartik - avatar
+ 5
Here is my try. Thanks for the challenge, it was very fun and I learned a lot. https://code.sololearn.com/cT2wVPgz4rAs/?ref=app
1st Dec 2017, 6:50 PM
Bopzor
Bopzor - avatar
+ 4
Should this be case sensitive?
1st Dec 2017, 11:11 AM
Kartik
Kartik - avatar
+ 4
@LukArToDo Ok Updated!
1st Dec 2017, 11:27 AM
Kartik
Kartik - avatar
+ 4
@Edgeton Consonant
1st Dec 2017, 12:39 PM
Kartik
Kartik - avatar
1st Dec 2017, 4:10 PM
Edgeton
Edgeton - avatar
+ 3
I'm not familiar with the relevant English language convention here: Is 'y' a vowel or a consonant?
1st Dec 2017, 12:28 PM
Edgeton
Edgeton - avatar
3rd Dec 2017, 3:45 PM
Cuttek
Cuttek - avatar
7th Dec 2017, 2:46 PM
Я. ♨
Я. ♨ - avatar