Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def combine_anagrams(words)
- h = Hash[words.map {|x| [x.downcase.chars.sort.join, Array.new ]}]
- words.each { |x| h[x.downcase.chars.sort.join].push(x) }
- return h.values
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement