Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 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: "wiki.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
|
||||
7
Task/Anagrams/CoffeeScript/anagrams-2.coffee
Normal file
7
Task/Anagrams/CoffeeScript/anagrams-2.coffee
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
> coffee anagrams.coffee
|
||||
[ 'abel', 'able', 'bale', 'bela', 'elba' ]
|
||||
[ 'alger', 'glare', 'lager', 'large', 'regal' ]
|
||||
[ 'angel', 'angle', 'galen', 'glean', 'lange' ]
|
||||
[ 'caret', 'carte', 'cater', 'crate', 'trace' ]
|
||||
[ 'elan', 'lane', 'lean', 'lena', 'neal' ]
|
||||
[ 'evil', 'levi', 'live', 'veil', 'vile' ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue