Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
15 lines (13 sloc) 273 Bytes
class String
def sort_letters
self.downcase.split(%r{\s*}).sort.join
end
end
def combine_anagrams(words)
anagrams = []
words.each do |word|
anagram = words.select {|w| w.sort_letters == word.sort_letters }
anagrams << anagram
end
anagrams.uniq
end