Article View: comp.text
Article #2566Re: Wanted: Tower of Hanoi Solution
From: Ed Blachman x4420
Date: Thu, 28 Feb 1991 23:39
Date: Thu, 28 Feb 1991 23:39
42 lines
1800 bytes
1800 bytes
In article <8564@exodus.Eng.Sun.COM> tut@cairo.Eng.Sun.COM (Bill "Bill" Tuthill) writes (tongue-in-cheek, I assume): > We have converted most of our documents from troff to FrameMaker, > but I am unable to convert this Tower of Hanoi program written > in troff. Could anyone supply the equivalent for FrameMaker or > Interleaf? Thanks in advance. > > ================ > .de T > .nr d \\$1-1 > .if \\nd .T \\nd \\$2 \\$4 \\$3 > Transfer ring \\$1 from tower \\$2 to tower \\$3. > .nr d \\$1-1 > .if \\nd .T \\nd \\$4 \\$3 \\$2 > .. > Initial state: \nR rings all on tower A; #1 on top. > .T \nR A B C > Done! Here is a way to do this with Interleaf 5: (defun tower (depth a b c) (if (/= 0 (dec depth)) (tower depth a c b)) (format t " Transfer ring ~D from tower ~C to tower ~C.~%" (1+ depth) a b) (if (/= 0 depth) (tower depth c b a))) (defun do-tower (depth) (format t "~%Initial state: ~D rings all on tower A; #1 on top.~%" depth) (tower depth #\A #\B #\C) (format t " Done!")) (do-tower 4) The animated version, in which you see little rings lift themselves off of one pole and drop themselves onto another, is doable, if (we hope you'd agree) understandably not quite as terse. We hope this was what you were looking for.... ;^) -- ed Ed Blachman edb@ileaf.com Paul English pme@ileaf.com
Technical Details
Message-ID:
<1991Feb28.233931.2615@HQ.Ileaf.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!dimacs.rutgers.edu!seismo!uunet!leafusa!edbReferences:
<8564@exodus.Eng.Sun.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!dimacs.rutgers.edu!seismo!uunet!leafusa!edb From: edb@HQ.Ileaf.COM (Ed Blachman x4420) Newsgroups: comp.text Subject: Re: Wanted: Tower of Hanoi Solution Message-ID: <1991Feb28.233931.2615@HQ.Ileaf.COM> Date: 28 Feb 91 23:39:31 GMT References: <8564@exodus.Eng.Sun.COM> Reply-To: edb@HQ.Ileaf.COM (Ed Blachman) Organization: Interleaf, Inc. Lines: 42