Created
October 11, 2012 04:26
-
-
Save anonymous/3870161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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