#!/usr/bin/env tclsh9.0 namespace import ::tcl::mathop::* proc prng {seed} { set seed [expr {(($seed << 6) ^ $seed) & 0xffffff}] set seed [expr {(($seed >> 5) ^ $seed) & 0xffffff}] expr {(($seed << 11) ^ $seed) & 0xffffff} } proc grind {n seed} { for {set i 0} {$i < $n} {incr i} { set seed [prng $seed] } return $seed } set total 0 while {[gets stdin line] >= 0} { if {$line eq ""} continue set n [grind 2000 $line] # puts "$line: $n" incr total $n } puts $total