Code Golf Saving Time

jdc 21-oct-2008 A Tcl solution to http://codegolf.com/saving-time

set O {1 7 16 25 34 43 46 40 31 22 13 4}
set C {8 o \n 4 o {} 7 o \n 0 {} \n 1 o {} 13 o \n 0 {} \n 0 o {} 15 o \n 0 {} \n 1 o {} 13 o \n 0 {} \n 4 o {} 7 o \n 8 o \n}
foreach t $argv {
    if {[regexp {0?(\d+):0?(\d+)} $t -> h m]} {
        set h [lindex $O [expr {($h%12)}]]
        set m [lindex $O [expr {($m/5)}]]
        if {$m==$h} { 
            set c [lreplace $C $m $m x] 
        } else {
            set c [lreplace $C $h $h h]
            set c [lreplace $c $m $m m]
        }
        foreach {s o b} $c { puts -nonewline [string repeat " " $s]$o$b }
    }
}

Example output:

% tclsh w.tcl 21:35
        o
    o       o

 o               o

h                o

 o               o

    m       o
        o

DKF: This can be shortened to (without final newline):

scan [gets stdin] %d:%d h m
regsub -all \\s+|. "oaosocowoeouooovoioxozom   r    n\n" \ {&} p
lset p [set h [expr $h%12*2]] h
lset p [set m [expr $m/5*2]] [expr $h-$m?"m":"x"]
puts [string map /\ $p {rr/nrzmrann xrrr snnimrrrcnn vrrr wnnromrenrru}]

(Note that the actual problem calls for the time to be supplied on stdin, not the command line.)