Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created December 31, 2018 06:04
Show Gist options
  • Save havenwood/ab054057884e2abc6a1843d77100e704 to your computer and use it in GitHub Desktop.
Save havenwood/ab054057884e2abc6a1843d77100e704 to your computer and use it in GitHub Desktop.
A (silly) example for #ruby irc
VOWELS = (0..).step.lazy.select { |n| n.prime? && (n * 9 + 4).prime? }.map { |n| (n + 94).chr }.first(5).freeze
def ordered_vowel_words words
words.select do |word|
vowels = word.each_char.select { |char| VOWELS.include? char }
vowels.each_cons(2).all? { |a, b| a < b }
end
end
ordered_vowel_words ['hiya', 'okay', 'yerp', 'nope', 'aeiou']
#=> ["yerp", "aeiou"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment