![]() The legend goes that young priests of a Hindu temple were tasked with moving discs of pure gold according to the rules of the puzzle – except that their Tower contained not 5 but 64 discs, and it was said that when they completed the task, the world would end. Interestingly, this formula can lead us back to the Tower of Hanoi’s supposed mythological roots. If it had four discs, it would require only 15 steps – and for three discs, only 7. ![]() Therefore, solving the puzzle would take a minimum of 31 steps. So, if the tower had five discs, the formula would be 2⁵-1, which is 31. In this formula, S is the number of steps, and N is the number of discs. This can be written in algebraic form: S = 2 N-1 The more discs that the puzzle contains, the more steps it will take – rising exponentially, in fact. Ultimately, it involves constructing and reconstructing progressively larger ‘towers’, until the bottom disc can be moved to the third pole and the rest of the tower constructed upon it, as the text box explains in mathematical terms (See ‘Solving the Tower of Hanoi through recursion’ on the third page). The Tower of Hanoi can be solved using recursion too, which helps mathematicians find the way to solve the puzzle in the fewest number of steps possible. You then repeat this process, dividing the pile into two twenties, two tens, and so on, until you narrow it down to the one coin. You can select the lighter pile and discard the other forty coins all at once. A faster way would be to divide the pile into two piles of forty and weigh these two piles against one another. To find this lighter coin, one solution would be to weigh and compare two coins at a time to see if there is any difference in weight – but this method would take ages. All the coins weigh the same, apart from one that weighs slightly less. For instance, imagine you have eighty coins and a set of balance scales. “Recursion is the extremely useful idea of solving a large problem by reducing it to smaller instances of the same problem,” says Dan. Professor Dan Romik, of the University of California, Davis, has investigated the Tower of Hanoi and, despite the puzzle’s apparent simplicity, has shown that it continues to yield new surprises. However, underlying the puzzle are some key mathematical ideas – even if we might not appreciate them when solving it. This puzzle quickly reached fame as the brainteaser now known as the Tower of Hanoi.ĭespite it seeming initially perplexing, in truth the Tower of Hanoi is a problem that even amateur puzzlers can solve with a bit of lateral thinking. However, the catch is, a larger disc can never sit on top of a smaller disc. The aim is to move the tower, one disc at a time, over to the right-hand pole. There are three poles in a row, the one on the left containing a series of discs of decreasing size, with the other two, empty. This is because the system has to keep track of future states as per the depth used.In 1883, a French mathematician named Édouard Lucas came up with an intriguing scenario. However, its memory intensive, proportional to the depth value used. I observed that the depth-first approach improves the overall efficiency of reaching the final state. Return dF so that evaluation can be done at depth-1 level.Pick the move(state) with minimum cost(dF).Loop over all the possible next moves(states) for the current state.Idea is to traverse a path for a defined number of steps(depth) to confirm that it’s the best move. ![]() Hill Climbing with the depth-first approach In order to get around the local optima, I propose the usage of depth-first approach. However, the path chosen may lead to higher cost(more steps) later.Īnalogues to entering a valley after climbing a small hill. The algorithm decides the next move(state) based on immediate distance(cost), assuming that the small improvement now is the best way to reach the final state. It’s one of the major drawbacks of this algorithm.Īnother drawback which is highly documented is local optima. As the vacant tile can only be filled by its neighbors, Hill climbing sometimes gets locked and couldn’t find any solution. If true, then it skips the move and picks the next best move. It also checks if the new state after the move was already observed. Hill climbing evaluates the possible next moves and picks the one which has the least distance. However, tile 8 is 1 move away from its final position. Since tiles 1 to 7 are already in its correct position, they don’t need to be moved. So in case of 3x3 Slide Puzzle we have: Final State: 1 2 3 4 5 6 7 8 Consider Current State: 1 2 3 4 5 6 7 8Įvaluation Function dF calculates the sum of the moves required for each tile to reach its final state. Evaluation function at step 3 calculates the distance of the current state from the final state.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |