Created
October 28, 2013 19:36
-
-
Save hauntedhost/7203157 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write a method ordered_vowel_words that takes a string of lowercase words | |
# and returns a string with just the words containing all their vowels | |
# (excluding "y") in alphabetical order | |
def ordered_vowel_words(words) | |
vowels = %w(a e i o u) | |
ordered = [] | |
words.split(" ").each do |word| | |
word_vowels = word.chars.select { |char| vowels.include? char } # amends = ae, complicated = oiae | |
ordered << word if word_vowels == word_vowels.sort | |
end | |
ordered.join(" ") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment