Tower of Hanoi
Animated solution for Tower of Hanoi puzzle. The objective is to move all disks from one tower to another, according to the following constraints:
- 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 i.e. a disk can only be moved if it is the uppermost disk on a stack.
- No disk may be placed on top of a smaller disk.
The number of disks can be updated and the animation will be restarted.
Although the algorithm can eventually solve the puzzle for any given number, because it's complexity is O(2^n), for a given large number we wouldn't be alive to see the solution. So the maximum allowed number of disks is 10.
Full source code of the project can be found here.
comments powered by Disqus