new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
17
Task/Anagrams/Ruby/anagrams-1.rb
Normal file
17
Task/Anagrams/Ruby/anagrams-1.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
require 'open-uri'
|
||||
|
||||
anagram = Hash.new {|hash, key| hash[key] = []} # map sorted chars to anagrams
|
||||
|
||||
open('http://www.puzzlers.org/pub/wordlists/unixdict.txt') do |f|
|
||||
words = f.read.split
|
||||
for word in words
|
||||
anagram[word.split('').sort] << word
|
||||
end
|
||||
end
|
||||
|
||||
count = anagram.values.map {|ana| ana.length}.max
|
||||
anagram.each_value do |ana|
|
||||
if ana.length >= count
|
||||
p ana
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue