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:
- Only one disk can be moved at a time.
- Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack or on an empty peg.
- No larger disk may be placed on top of a smaller disk.
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.