Skip to content

Instantly share code, notes, and snippets.

Created October 11, 2012 04:26
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 anonymous/3870161 to your computer and use it in GitHub Desktop.
Save anonymous/3870161 to your computer and use it in GitHub Desktop.
def combine_anagrams(words)
#Creating the anagrams
anagrams = words.group_by { |word| word.chars.sort }.values
return anagrams
end
#Failing statements
word_list = %w[B b]
#word_list = %w[Jello jello]
p combine_anagrams(word_list)
After Execution
[["'B'"], ["'b'"]]
[["'Jello'"], ["'jello'"]]
Expected Result:
[["B", "b"]]
[["JeLLo", "jello"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment