Coding Challenge#5: Are we Alternate? (Code included) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 12

Coding Challenge#5: Are we Alternate? (Code included)

Are we alternate? (By: Jafca) Create a function isAlt() to validate whether a string of letters has alternate consonants and vowels. Vowels are a, e, i, o and u. e.g. isAlt("amazon") // true e.g. isAlt("cheeze") // false e.g. isAlt("banana") // true e.g. isAlt("ghost") // false https://code.sololearn.com/cHT29NRY4XF1/?ref=app

15th May 2017, 5:29 PM
Pixie
Pixie - avatar
32 Answers
+ 4
https://code.sololearn.com/c2aptyHnQ62S/?ref=app
15th May 2017, 5:46 PM
Tamás Barta
Tamás Barta - avatar
+ 7
A solution constructing a RegEx, should also work for any other set of non-meta characters: https://code.sololearn.com/cN9aWvujLzi4
15th May 2017, 8:24 PM
Tob
Tob - avatar
+ 7
https://code.sololearn.com/cPN2e1m380O9/?ref=app
15th May 2017, 10:57 PM
Hatsy Rei
Hatsy Rei - avatar
+ 6
@Tamas. Actually. Me too. For the original question by Jafca, I did not check explicitly for one letter inputs. Maybe I should have specified it in the question
16th May 2017, 8:48 AM
Pixie
Pixie - avatar
15th May 2017, 6:33 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 5
https://code.sololearn.com/cSqBLyNphJB0/?ref=app
15th May 2017, 6:46 PM
Riman Das
Riman Das - avatar
16th May 2017, 4:53 AM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 5
@pixie i have made the changes please have a look
16th May 2017, 5:46 AM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 5
what about single consonant char? should they also be true??
16th May 2017, 5:52 AM
Riman Das
Riman Das - avatar
+ 5
@pixie should 'b' also be true? or rule is only for vowels?
16th May 2017, 6:00 AM
Riman Das
Riman Das - avatar
+ 5
@Riman. Only for vowels
16th May 2017, 8:43 AM
Pixie
Pixie - avatar
+ 5
@Tamas. The output for 'b' should be false as there are no vowels in the input.
16th May 2017, 8:44 AM
Pixie
Pixie - avatar
+ 5
Me too, then. Maybe you should add the requirement that the word must contain a vowel in the description, as this is logically independent of the alternating rule.
16th May 2017, 8:55 AM
Tob
Tob - avatar
20th May 2017, 5:52 PM
Pixie
Pixie - avatar
15th May 2017, 5:54 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 4
A couple alternate approaches (flipping in the correct validator, and swapping all letters into a binary sequence): https://code.sololearn.com/cz2wjbzC74OH/?ref=app https://code.sololearn.com/cCn9v5CQ6T6w/?ref=app
15th May 2017, 8:04 PM
Kirk Schafer
Kirk Schafer - avatar
+ 4
Let me use this to shamelessly plug my own challenge. Cookies for every correct solution. ;) https://www.sololearn.com/Discuss/392289
15th May 2017, 11:55 PM
Tob
Tob - avatar
+ 4
@pixie i can't understand why?
16th May 2017, 4:59 AM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 4
@pixie there is not any consonant in a single letter 'a' so it is not alternate
16th May 2017, 5:00 AM
Vaibhav Sharma
Vaibhav Sharma - avatar
+ 4
@Pixie: then I misunderstood the problem
16th May 2017, 8:46 AM
Tamás Barta
Tamás Barta - avatar