Last active
December 11, 2015 15:18
-
-
Save alxfv/4619894 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) | |
| output = {} | |
| words.each do |word| | |
| index = word.downcase.chars.sort.join | |
| output[index].is_a?(Array) ? output[index] << word : output[index] = [word] | |
| end | |
| output.values | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment