Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Towers of Hanoi

by LeGo (Chaplain)
on Jul 24, 2001 at 01:26 UTC ( #99176=note: print w/ replies, xml ) Need Help??


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...


Comment on Re: Towers of Hanoi

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://99176]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-12-28 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls