Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2012 23:34
Show Gist options
  • Save anonymous/1968900 to your computer and use it in GitHub Desktop.
Save anonymous/1968900 to your computer and use it in GitHub Desktop.
def combine_anagrams(words)
results = []
words.each do |word|
results << words.select { |w| word.split(//).sort == w.split(//).sort }
end
results.uniq
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment