A Java code of the Original Tower of Hanoi, Adjacency Tower of Hanoi, and Exchange-Adjacency Tower of Hanoi used for a mathematical analysis of the most optimal method of solving the Tower of Hanoi and its variations.
The game starts with the disks placed on the left-most peg descending in size from bottom to top (Gregg and Orozco). The goal of such a game is to move all the disks onto the third peg decreasing in size within the minimum number of moves under 3 rules:
- Disks can only be moved one at a time
- Larger disks can’t go on top of smaller disks
- Only the disk on the top can be moved
New rules:
- Larger disks can’t go on top of smaller disks
- Only the smallest disk can move normally
- The other disks can only move by swapping places with the smallest disk
- The disks can only be moved or swapped when they’re on top of the stack
- Disks can only move if the destined location is adjacent to the current location of the disk
- Disks can only swap if the 2 disks are on adjacent pegs