Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:18 14 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Towers of Hanoi Puzzle

Author Message
William Leue
Guru

Joined: 03/07/2020
Location: United States
Posts: 405
Posted: 04:56pm 20 Aug 2020
Copy link to clipboard 
Print this post

Attached is a ZIP file for the Towers of Hanoi puzzle, a CMM2 MMBasic program I recently completed.

The Towers of Hanoi puzzle consists of three towers the first of which holds a number of disks of steadily decreasing size, just like a kid's stacker toy.

The object of the puzzle is to move the disks from the first (left-hand) tower to the center tower. But, there are two restrictions:

 a) You can only move one disk at a time
 b) At all stages of the solution, you can NEVER have a larger disk on top
      of a smaller disk.

Persons familiar with the puzzle know that for N disks, the solution that uses the fewest number of moves is 2 raised to the Nth power, minus one.

This program lets you select the number of disks from 3 to 12, choose an automatic solution which can be single-stepped, or a manual solution where you move the disks yourself. The program will tell you when you succeeded and if you used only the minimum number of moves.

Enjoy!
-Bill

Hanoi.zip
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025