Skip to content

Instantly share code, notes, and snippets.

@epitron
Created December 6, 2015 12:13
Show Gist options
  • Save epitron/b63959fbdd6f401ba119 to your computer and use it in GitHub Desktop.
Save epitron/b63959fbdd6f401ba119 to your computer and use it in GitHub Desktop.
words = open("advent5.txt").each_line.map(&:strip)
doubles = /([a-z]{2}).*\1/
repeat = /([a-z])[a-z]\1/
nice = words.select { |s| s =~ doubles and s =~ repeat }
p nice.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment