Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
more useful options
 
PerlMonks  

Re: Towers of Hanoi

by LeGo (Chaplain)
on Jul 23, 2001 at 21:26 UTC ( [id://99176]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Towers of Hanoi

I am curious as to if someone can help guide me in how to solve this or show me how to solve this. I am looking to be able to solve it with any number of variables. For example

perl hanoi.pl 4

If no variable was passed I would like for it to default to just 3. I am looking to just impress my friends. I am taking psy200. I am not sure how to begin to look at solving this. If the above was typed in at the command line I would like to see the following result.

A-B
A-C
B-C
A-B
C-A
C-B
A-B
A-C
B-C
B-A
C-A
B-C
A-B
A-C
B-C
DONE!!!!! Finished in 15 moves!!!!

This is more so illustrated at this site and also solved for 3-7. I am looking to solve for any number (or as many as possible). Any help in this would be awesome, as I am sure this will be a fun project.

Thanks,

LeGo

UPDATE: I found the solution above did work for me. It just needed the arguement passed in on command line. The answer was posted in more detail here. It would still be nice to be able to see how many moves it took...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://99176]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.