Search This Blog

Showing posts with label hanoi. Show all posts
Showing posts with label hanoi. Show all posts

C Program for Animated Solution of Tower of Hanoi Puzzle Problem

This is a c program to solve towers of Hanoi puzzle problem with graphical demonstration. This c program demonstrates solution for tower of Hanoi puzzle with given 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. The program lets you enter the number of disks. As the number of disks increase, the difficulty of puzzle also increase. 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. To win the puzzle you have to move all those disks from tower A (first tower) to tower C (third tower). But there are a few rules to solve the puzzle. They are: