6 kyu
Vowel-consonant lexicon
303 of 608KenKamau
Description:
If we alternate the vowels and consonants in the string "have"
, we get the following list, arranged alphabetically:
['ahev', 'aveh', 'ehav', 'evah', 'have', 'heva', 'vahe', 'veha']
. These are the only possibilities in which vowels and consonants are alternated. The first element, ahev
, is alphabetically lowest.
Given a string:
- alternate the vowels and consonants and return the lexicographically lowest element in the list
- If any two or more vowels or consonants must follow each other, return
"failed"
- if the number of vowels and consonants are equal, the first letter of the result must be a vowel.
Examples:
solve("codewars") = "failed". However you alternate vowels and consonants, two consonants must follow each other
solve("oruder") = "edorur"
solve("orudere") = "ederoru". This is the only option that allows you to alternate vowels & consonants.
Vowels will be any of "aeiou". Input will be a lowercase string, no spaces. See test cases for more examples.
Good luck!
If you like this Kata, please try:
Strings
Arrays
Algorithms
Similar Kata:
Stats:
Created | Sep 30, 2017 |
Published | Oct 1, 2017 |
Warriors Trained | 1386 |
Total Skips | 27 |
Total Code Submissions | 2279 |
Total Times Completed | 608 |
Python Completions | 303 |
JavaScript Completions | 231 |
Haskell Completions | 34 |
Ruby Completions | 41 |
C Completions | 32 |
Total Stars | 66 |
% of votes with a positive feedback rating | 92% of 194 |
Total "Very Satisfied" Votes | 166 |
Total "Somewhat Satisfied" Votes | 24 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 10 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |