Tower of Hanoi by pooq

x=c()
f=function(n,a,b,c)if(n){f(n-1,a,c,b);cat(a);x<<-c(x,c);f(n-1,b,a,c)}
f(scan("stdin"),"A","B","C")
cat("
",x,sep="")

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page