Jump to content

Anagrams: Difference between revisions

No edit summary
Line 297:
<ruby>require 'open-uri'
 
anagram = Hash.new {|hash, key| hash[key] = []} # map sorted chars to anagrams
words = open('http://www.puzzlers.org/pub/wordlists/unixdict.txt').read.split
 
anagram = Hash.new {|hash, key| hash[key] = []}
words = open('http://www.puzzlers.org/pub/wordlists/unixdict.txt').read.split do |f|
for word in words
words = f.read.split
anagram[word.split('').sort] << word
for word in words
end
anagram[word.split('').sort] << word
end
end
 
count = anagram.values.map {|ana| ana.length}.max
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.