Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Anagrams/Tcl/anagrams.tcl
Normal file
24
Task/Anagrams/Tcl/anagrams.tcl
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package require Tcl 8.5
|
||||
package require http
|
||||
|
||||
set url http://wiki.puzzlers.org/pub/wordlists/unixdict.txt
|
||||
set response [http::geturl $url]
|
||||
set data [http::data $response]
|
||||
http::cleanup $response
|
||||
|
||||
set max 0
|
||||
array set anagrams {}
|
||||
|
||||
foreach line [split $data \n] {
|
||||
foreach word [split $line] {
|
||||
set anagram [join [lsort [split $word ""]] ""]
|
||||
lappend anagrams($anagram) $word
|
||||
set max [::tcl::mathfunc::max $max [llength $anagrams($anagram)]]
|
||||
}
|
||||
}
|
||||
|
||||
foreach key [array names anagrams] {
|
||||
if {[llength $anagrams($key)] == $max} {
|
||||
puts $anagrams($key)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue