Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Anagrams/E/anagrams.e
Normal file
22
Task/Anagrams/E/anagrams.e
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
println("Downloading...")
|
||||
when (def wordText := <http://wiki.puzzlers.org/pub/wordlists/unixdict.txt> <- getText()) -> {
|
||||
def words := wordText.split("\n")
|
||||
|
||||
def storage := [].asMap().diverge()
|
||||
def anagramTable extends storage {
|
||||
to get(key) { return storage.fetch(key, fn { storage[key] := [].diverge() }) }
|
||||
}
|
||||
|
||||
println("Grouping...")
|
||||
var largestGroupSeen := 0
|
||||
for word in words {
|
||||
def anagramGroup := anagramTable[word.sort()]
|
||||
anagramGroup.push(word)
|
||||
largestGroupSeen max= anagramGroup.size()
|
||||
}
|
||||
|
||||
println("Selecting...")
|
||||
for _ => anagramGroup ? (anagramGroup.size() == mostSeen) in anagramTable {
|
||||
println(anagramGroup.snapshot())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue