Ordered Vowels

Write a method, ‘ordered_vowel_words(str)’ that takes a string of
lowercase words and returns a string with just the words containing
all their vowels (excluding “y”) in alphabetical order. Vowels may
be repeated (“afoot” is an ordered vowel word).

You will probably want a helper method, ‘ordered_vowel_word?(word)’
which returns true/false if a word’s vowels are ordered.

Solution:

screen-shot-2016-11-21-at-6-12-18-pm

Surprisingly, it’s the helper function that was the challenge in this problem.  The trick is to create an array of all the vowels in the alphabet (except “y”). To check if each word has its vowels in order, split the word into letters, and then use .include? to check if those letters are included in the vowel array.

Test Cases:

screen-shot-2016-11-21-at-6-15-29-pm

Advertisements
Ordered Vowels

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s