![]() Move n-1 discs from spare peg to target peg.Move last disc from source peg to target peg. ![]() ![]() Move n-1 discs from source peg to spare peg.Move disc 1 from spare peg to target pegįor n number of discs we can generalize the above strategy as follows,.Move disc 2 from source peg to target peg.Move disc 1 from source peg to spare peg.Let us look at the strategy of solving towers of Hanoi with just 2 discs. This puzzle can be concisely solved using recursion. For example, it would take 7(2 raised to 3 - 1) steps to move 3 discs from source peg to target peg. The number of steps required to move n discs from source page to target peg is (2 raised to n - 1). Interestingly if the moves are made at the rate of one move per second, it will take more than 500 billion years to solve the puzzle! Solving Towers of Hanoi Using Recursion Priests believed that when the last move of the puzzle is completed, world will end. One popular myth about towers of Hanoi suggests that there was a temple in India where priests worked on solving a 64 disc towers of Hanoi puzzle (known as tower of Brahma). A disc cannot be placed over a smaller discįrench mathematician Edouard Lucas invented towers of Hanoi in 1883.Each move consists of taking one disc from a peg and putting on top of another peg.The aim of the game is to move all the discs to a target peg with the same order using just a spare peg. The size of the discs are different and they are kept on the source peg with the smallest on the top and the biggest one on the bottom. Towers of Hanoi is a well known mathematical game/puzzle involving three pegs and a number of discs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |