kernelthread.com

Icon

The Towers of Hanoi as an Icon program.

# # The Towers Of Hanoi # Icon # Copyright (C) 1998 Amit Singh. All Rights Reserved. # http://hanoi.kernelthread.com # procedure movedisk(f, t) write("move ", f, " --> ", t) end procedure dohanoi(n, f, t, u) if (n <= 1) then movedisk(f, t) else { dohanoi(n - 1, f, u, t) dohanoi(1, f, t, u) dohanoi(n - 1, u, t, f) } end procedure main(argv) if *argv == 1 then dohanoi(argv[1], 1, 3, 2) else write("usage: hanoi <n>") end

Download

hanoi.icn