It is a Mathematical Puzzle , in which you take objects from the given tower to the destination Tower
Welcome to the Tower-Of-Hanoi-Solutions
TOH ( also called the Tower of Brahma or Lucas' Tower) is a mathematical Quiz.It consists of three rods and a number of disks of different sizes, which can slide onto any rod. So basically , The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, means making the conical shape ..
The Objective of TOH is to move the entire STACK to another rod
Following Rules
are to be followed
- One disks move at a time.
- Each move will consist of taking the upper disk from one of the stacks and placing it on the top of another stack or on an empty rod.
- No smaller disk placed below the bigger one.
We can find that in how many minimum moves of disks we can get the solution
Like for disks == 3 ,
We require minimum 7 moves to get the solution.
So the Formula is (2^n - 1)
where n : Number of the disks..
For program you must a basic Knowledge of :--
-
Recursive Function
-
Python
A recursive function is a function which either calls itself or is in a potential cycle of function calls. And a Immediate recursive function is that in which function calls itself directly
A recursive function has the following general form :--
ReturnType Function( Pass appropriate arguments ) {
if a simple case, return the simple value // base case / stopping condition
else call function with simpler version of problem }
For a recursive function to stop calling itself we require some type of stopping condition. If it is not the base case, then we simplify our computation using the general formula.
One can view this mathematically in a directed call graph.
void A() {
A();
return;
}
-
Here is the 'Demonstration' of the 'Tower Of Hanoi' , How it works
-
Take an example of 3 Disks
- Have questions in your mind about the TOH
- First run the code in the Python IDE
- then the Program asks you to take input of no. of disks
- Simply give input ..
- It will shoe you the result and the algorithm
- It also show that which disks you have to move and to which tower it has to move
Let's Become Friend