Tower of Hanoi
An interesting game right?
If you don't know about this game, take a look here,
So to solve it (displaying the steps), carefully analyze what actually happens when you have one and two disks. Then try to recreate the scenario with 3 disks. Maybe you can find a recursive approach here, here's the code,
6.9 Tower of Hanoi (Recursion)
So, with recursion it's too short and feels simple right?
It's not this simple if you want to apply this thing with stack instead of recusion. A bit of trial and error perhaps?
6.10 Tower of Hanoi (Stack)
It's the iterative approach of the above code with stack,
Or, perhaps one even more minimal approach? (Taught to me by MH Nazmul)
Last updated
Was this helpful?