/Original-Tower-of-Hanoi-and-Its-Variations

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.

Primary LanguageJava

Original-Tower-of-Hanoi-and-Its-Variations

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.

Original Tower of Hanoi

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:

  1. Disks can only be moved one at a time
  2. Larger disks can’t go on top of smaller disks
  3. Only the disk on the top can be moved

Adjacency Tower of Hanoi

Additional rules to the Original: The disk can only be moved to the adjacent rod of the rod that the disk is on.

Exchange-Adjacency Tower

New rules:

  1. Larger disks can’t go on top of smaller disks
  2. Only the smallest disk can move normally
  3. The other disks can only move by swapping places with the smallest disk
  4. The disks can only be moved or swapped when they’re on top of the stack
  5. Disks can only move if the destined location is adjacent to the current location of the disk
  6. Disks can only swap if the 2 disks are on adjacent pegs