ColdeGolf - Tower of Hanoi
Size: 262 (v4) submitted on 4/14/2007
def f(d)(0..2).find{|i|$a[i]&&$a[i][d.to_s]}end def m d,i,j k=(0..2).find{|k|k!=i&&k!=j} m(d-1,i,k)if d>1 puts"#{d} to #{"ABC"[j,1]}" m(d-1,k,j)if d>1 end $a=[];n=0 ($a<<chomp;n+=$_.size)while gets (1..n).map{|d|i=f d;j=d==n ?2:f(d+1);m d,i,j if i!=j}
Anatomy of Hanoi Golf:
Read stdin to an array "$a" of strings
$a<<chomp while gets
Find the total number of disks "n"
n+=$_.size
Helper functions
f(d): finds a peg where a disk "d" exists m(d,i,j): moves a disk "d" from a peg "i" to another peg "j"
Ruby Golfers as of 4/14/2007
-3rd adel 147 Ruby 8,775 (v2) -6th flagitious 159 Ruby 8,113 (v11) -9th rampion 219 Ruby 5,890 (v1)
Size 147, wow!