Search This Blog

Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

Java Program to Solve Tower of Hanoi Puzzle Problem

This is a java program to solve towers of hanoi puzzle problem. This simple java program gives solution for tower of hanoi problem with any number of disks. Tower of Hanoi is a mathematical game or puzzle. It is also called tower of brahma or Lucas' tower. There are three towers (or rods) and a number of disks of different diameters. Initially, The disks have hole at center so that it can slide on to the rods. Initially all disks are stacked on the first tower, say tower A, such that no disk is placed over a smaller disk. The goal or objective is to move all these disks from tower A (first tower) to tower C (third tower). But you should obey the following rules. The rules of towers of hanoi puzzle are: