Advertisement

Help - Hanoi!

Started by December 06, 2000 06:24 AM
5 comments, last by Robhog 24 years, 1 month ago
Hi. I''m in a bit of a jam (as usual). Anyone know where i can get some source code for the "Tower of Hanoi" (not a routine to solve it recursively, but code so ppl can actaully play it). C++ or (preferably) Visual Basic. Reply here, or mail prov_oni@yahoo.com Thanks (thanx!) Rob
Not cheating on your Maths homework are you?
Advertisement
I have that as an example in a VB book IIRC!

Visual Basic 5.0 from the Gound Up I think...

I'll have a look later...

[edit]
nope, not later, it was pretty easy to find. Have it here, including some VB source code. What way do I give it to you? (I have a scanner BTW... and yes, the drivers are installed and I know where the CD is )
[/edit]

Edited by - JonnyQuest on December 7, 2000 12:13:30 PM
~phil
Something completely unrelated to the actual topic (Towers of Hanoi game), but the solution for 5 rings:

Move odd numbered rings to the next highest pole, even to the next lowest pole. i.e. 1->2->3->1 or 3->2->1->3

1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1

That should do it.

MSN
FYI, solving the Towers of Hanoi problem with N discs requires a minimum of 2^N - 1 moves (where ^ is power in this case, not xor). E.g. moving only a single disc requires 1 move (dA 0->2), moving two discs requires 3 moves (dB 0->1, dA 0->2, dB 1->2), three discs 7 moves, 4 discs 15 moves, etc.
To make a playable TOH game shouldn''t be hard. Tell us where you''re getting stuck and then we''ll do what we can.
Advertisement
Hmm. tower of hanoi is a nice recursive problem - i''m programming a robotic arm to solve it using blocks.


Wyzfen

This topic is closed to new replies.

Advertisement