Tower of Hanoi

The Rules

The objective of the puzzle is to move the entire stack of disks from the left to the right, in the minimum number of moves and obeying the following simple rules:

About the Game

The puzzle was invented by the French mathematician Édouard Lucas in 1883, although numerous myths regarding the ancient and mystical nature of the puzzle popped up almost immediately.

The three disk problem is simplest implementation. It is possible to play with much larger numbers of disks, even while still using only three pegs/towers. They just take a bit longer to solve/complete.

At its heart, this is really a mathematical problem - what is the minimum number of moves for X number of disks? But it makes for a nice little puzzle game, too.

More information on the mathematics behind this puzzle is available on WikiPedia.

About the App

This app was put together as an experiment to allow drag/drop functionality in a browser running on a touch device.

It uses Vue.js, and the Mouse Event and Touch Event Web APIs.

I've also written a blog post about getting this to work using vanilla Javascript.