new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
31
Task/Anagrams/CoffeeScript/anagrams-1.coffee
Normal file
31
Task/Anagrams/CoffeeScript/anagrams-1.coffee
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
http = require 'http'
|
||||
|
||||
show_large_anagram_sets = (word_lst) ->
|
||||
anagrams = {}
|
||||
max_size = 0
|
||||
|
||||
for word in word_lst
|
||||
key = word.split('').sort().join('')
|
||||
anagrams[key] ?= []
|
||||
anagrams[key].push word
|
||||
size = anagrams[key].length
|
||||
max_size = size if size > max_size
|
||||
|
||||
for key, variations of anagrams
|
||||
if variations.length == max_size
|
||||
console.log variations.join ' '
|
||||
|
||||
get_word_list = (process) ->
|
||||
options =
|
||||
host: "www.puzzlers.org"
|
||||
path: "/pub/wordlists/unixdict.txt"
|
||||
|
||||
req = http.request options, (res) ->
|
||||
s = ''
|
||||
res.on 'data', (chunk) ->
|
||||
s += chunk
|
||||
res.on 'end', ->
|
||||
process s.split '\n'
|
||||
req.end()
|
||||
|
||||
get_word_list show_large_anagram_sets
|
||||
Loading…
Add table
Add a link
Reference in a new issue