This commit is contained in:
Ingy döt Net 2013-04-10 16:57:12 -07:00
parent 518da4a923
commit 764da6cbbb
6144 changed files with 83610 additions and 11 deletions

View file

@ -0,0 +1,16 @@
#!/usr/bin/tclsh8.6
package require Tcl 8.6 ;# For [lsort -stride] option
lappend auto_path . ;# Or wherever it is located
package require hailstone 1.0
# Construct a histogram of length frequencies
set histogram {}
for {set n 1} {$n < 100000} {incr n} {
dict incr histogram [llength [hailstone $n]]
}
# Identify the most common length by sorting...
set sortedHist [lsort -decreasing -stride 2 -index 1 $histogram]
lassign $sortedHist mostCommonLength freq
puts "most common length is $mostCommonLength, with frequency $freq"