Postscript
The Towers of Hanoi as a Postscript program.
%!
% The Towers Of Hanoi
% Postscript
% Copyright (C) 2001 Amit Singh. All Rights Reserved.
% http://hanoi.kernelthread.com
%
% Choose some font
/Times-Roman findfont
32 scalefont
setfont
% How does a global dictionary work?
/ycounter 400 def
0 ycounter moveto
/movedisk
{%def
( move disk from ) print print ( ==> ) print print (\n) print
% I couldn't figure this out
%
% ( move ) show ( ==> ) show show
% /ycounter ycounter 40 sub def
% 0 ycounter moveto
%
} def
/hanoi
{%def
save
2 dict begin
/save_obj exch def
/n exch def % number of towers
/f exch def % "from" tower
/t exch def % "to" tower
/u exch def % "using" tower
n 1 eq { % if (n == 1)
t f movedisk
} {%else
t u f n 1 sub hanoi
t f movedisk
f t u n 1 sub hanoi
} ifelse
save_obj
end
restore
} bind def
(Tower 2) (Tower 3) (Tower 1) 3 hanoi
showpage
%quit