Skip to content

Instantly share code, notes, and snippets.

@hauntedhost
Created October 28, 2013 19:36
Show Gist options
  • Save hauntedhost/7203157 to your computer and use it in GitHub Desktop.
Save hauntedhost/7203157 to your computer and use it in GitHub Desktop.
# 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