🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: a.bsu.programming
Article #86749

Re: Towers of Hanoi (nonrecursive)

#86749
From: Stephen Judd
Date: Fri, 10 Oct 1997 00:00
22 lines
2027 bytes
In article <slrn63rl1l.3l2.martijnb@mud.stack.nl>,
Martijn van Buul <martijnb@stack.nl> wrote:
>It occurred to me that MidNight wrote:
>> One day, "Chris Lomont" <clomont@omni.cc.purdue.edu> decided to write:
>> >What, is this a homework assignment?
>> 
>> Sounds like it to me.  I've been wondering how to do it, but never had
>> the time to figure it out, so this is pretty interesting.
>
>I always thought that "Towers of Hanoi" was one of the best examples
>for a coding task to be quite easy using recursion, and a pain in
>the ass when done iterative..

for i=1 to 2^n
   if i is odd then move the smallest disk clockwise
   else make the only other possible move.
od

(That Spectrum vs. C64 stuff was useful after all :)

-S
Technical Details
Message-ID: <61lsje$gn6@news.acns.nwu.edu>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <61etj1$4eu@dfw-ixnews3.ix.netcom.com> <61h5i2$roo@mozo.cc.purdue.edu> <61k124$sda$1@walter.acs.nmu.edu> <slrn63rl1l.3l2.martijnb@mud.stack.nl>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fe306,5b0c24fabb02a1d7
X-Google-Attributes: gidfe306,public
X-Google-Thread: f5380,5b0c24fabb02a1d7
X-Google-Attributes: gidf5380,public
X-Google-Thread: 108717,5b0c24fabb02a1d7
X-Google-Attributes: gid108717,public
X-Google-Thread: ff2b1,5b0c24fabb02a1d7
X-Google-Attributes: gidff2b1,public
X-Google-Thread: 125116,5b0c24fabb02a1d7
X-Google-Attributes: gid125116,public
X-Google-Thread: 107d8b,5b0c24fabb02a1d7
X-Google-Attributes: gid107d8b,public
X-Google-Thread: ffead,5b0c24fabb02a1d7
X-Google-Attributes: gidffead,public
X-Google-Thread: 105753,5b0c24fabb02a1d7
X-Google-Attributes: gid105753,public
From: judd@merle.acns.nwu.edu (Stephen Judd)
Subject: Re: Towers of Hanoi  (nonrecursive)
Date: 1997/10/10
Message-ID: <61lsje$gn6@news.acns.nwu.edu>
X-Deja-AN: 279314477
References: <61etj1$4eu@dfw-ixnews3.ix.netcom.com> <61h5i2$roo@mozo.cc.purdue.edu> <61k124$sda$1@walter.acs.nmu.edu> <slrn63rl1l.3l2.martijnb@mud.stack.nl>
Organization: Northwestern University, Evanston, IL
Reply-To: sjudd@nwu.edu (Stephen Judd)
Newsgroups: a.bsu.programming,adass.iraf.programming,comp.programming,comp.sys.be.help,comp.sys.be.programmer,comp.sys.cbm,netcom.programmers,rec.games.programmer