#!/usr/bin/env tclsh set adapters [split [read stdin]] while {[lindex $adapters end] eq ""} {set adapters [lrange $adapters 0 end-1]} set adapters [lsort -integer $adapters] set adapters [linsert $adapters 0 0] lappend adapters [expr {3 + [lindex $adapters end]}] foreach i {1 2 3} {set n($i) 0} for {set i 0} {$i < [llength $adapters] - 1} {incr i} { set delta [expr {[lindex $adapters $i+1] - [lindex $adapters $i]}] incr n($delta) } parray n