Towr of Hanoi move the disc
I already created the solver for the tower of hanoi. But I wanted to make a simple presentation of how the solver is working by showing the movement of the box as shown below. The problem I'm facing is:
How to make the program move the disk from tower-to-tower.
How the program will know which disk is the top, mid and bottom disk.
How the program will know which disk should go first to the other tower etc.....
Code:
void hanoi( int disc_num , int source, int using, int dest )
{
if( disc_num != 0 )
{
hanoi( disc_num - 1 , source, dest, using );
//printf( "Move the place from %d to %d\n", source, dest );
disk_to_move( source, using, dest );
hanoi( disc_num - 1 , using, source, dest );
}
}
Code:
║ ║ ║
╔══════╗ ║ ║
╚══════╝ ║ ║
╔════════╗ ║ ║
╚════════╝ ║ ║
╔══════════════╗ ║ ║
╚══════════════╝ ║ ║
═════════════════════════════════════════════════════════