Tower of Hanoi for teachers
An interactive board you can put on a course page or a slide: free, no ads, no sign-up, nothing to install.
Embed it
Paste this where your page accepts HTML (most learning platforms have an “HTML” or “embed”
option in their editor). Change disks=4 to the size you want, from 3 to 10. The height of 720 fits up to
6 disks with the solver controls open; use 840 for 7 to 10 disks.
<iframe src="https://playhanoi.com/embed?disks=4" title="Tower of Hanoi: interactive board" width="100%" height="720" style="border:0;max-width:760px" loading="lazy"></iframe>
<p><a href="https://playhanoi.com/">Tower of Hanoi</a> by Play Hanoi</p>
What your students will see
The board counts moves, shows the fewest possible, and tells the student how many moves are left from wherever they are. Shuffle makes a random position and Solve from here plays the shortest solution one move at a time, which you can pause and step through.
Options
| Setting | Values | Example |
|---|---|---|
disks | 3 to 10 (default 4) | /embed?disks=6 |
pegs | 3 or 4 (default 3) | /embed?disks=5&pegs=4 |
Anything else in the address is ignored, and a value out of range falls back to the default.
In class
- Before they start, ask for a guess at the fewest moves for 5 disks, then compare it with the number the board shows. The formula page derives it.
- Shuffle the board and have students predict how many moves are left, then press Solve from here and step through the solution.
-
Set
pegs=4and compare with three pegs. The four-peg page explains the method behind the numbers.
Good to know
- A link back is appreciated. The second line of the code above is a small credit; keep it or move it next to the board.
- Records and sound. A student’s best results are kept in their own browser. Some browsers do not allow a frame to keep anything; the board still works, it just does not remember. Sound is off until a student presses the speaker.
-
Some platforms remove frames. If the board does not appear, ask your platform administrator whether
embedded content from
playhanoi.comcan be allowed, or link to the page itself. - Keyboard and screen readers. Each peg is a button; with a peg focused, keys 1 to 4 pick up and put down disks.