Skip to content

Instantly share code, notes, and snippets.

@jsomers
Last active October 13, 2015 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsomers/4237350 to your computer and use it in GitHub Desktop.
Save jsomers/4237350 to your computer and use it in GitHub Desktop.
Anagram circles
words = File.open("/usr/share/dict/words").read.split("\n").map(&:downcase)
anagram_index = words.inject(Hash.new {[]}) { |idx, word| idx[word.split("").sort] += [word]; idx }
p anagram_index.select {|_, v| v.length == 4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment