+ 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!
18 Antworten
+ 12
Here you go bruhh...
https://code.sololearn.com/cAaS5B4K35fv/?ref=app
+ 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 😕
+ 22
my try on sunday ☺
+ 11
For example :
https://code.sololearn.com/cZFgnBa3xhyA/?ref=app
+ 9
@Kartik
Ignore case sensitive
+ 8
When alternating the vowels and consonants, which should start (vowel or consonants).
+ 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.
+ 6
Bookmark
+ 5
Here's my try in 🐍
https://code.sololearn.com/c6x5cSbLwgH5/?ref=app
+ 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
+ 4
Should this be case sensitive?
+ 4
@LukArToDo
Ok
Updated!
+ 4
@Edgeton
Consonant
+ 4
+ 3
I'm not familiar with the relevant English language convention here:
Is 'y' a vowel or a consonant?
+ 3
here's mine ;)
https://code.sololearn.com/cXIWSpmOUl5J/?ref=app