

Moving the smallest disk from peg SOURCE to TARGET as our first step has not shown to be successful.We have already used the maximal number of moves, i.e. Now we can see that we have moved the tower of size 2 to the peg AUX, but the target had been peg TARGET. Now, we have to move the smallest disk again, because we don't want to move the largest disk back to SOURCE again. So the only move which makes sense is moving the other disk, i.e. Now there are two choices: We can move this disk again, either back to the SOURCE peg, which obviously doesn't make sense, or we could move it to AUX, which doesn't make sense either, because we could have moved there as our first step.


There are two possibilities to move the first disk, the disk on top of the stack of SOURCE: We can move this disk either to TARGET or to AUX. Let's look now at a tower with size 2, i.e. The solution for a tower with just one disk is straightforward: We will move the one disk on the SOURCE tower to the TARGET tower and we are finished. Before we examine the case with 3 disks, as it is depicted in the image on the right side, we will have a look at towers of size 1 (i.e. The pole in the middle (we will call it AUX) is needed as an auxiliary stack to deposit disks temporarily. Playing around to Find a Solution From the formula above, we know that we need 7 moves to move a tower of size 3 from the most left rod (let's call it SOURCE to the most right tower (TARGET). The number of moves necessary to move a tower with n disks can be calculated as: 2 n - 1

But one rule has to be applied: a large disk can never be placed on top of a smaller one. The priests, if the legend is about a temple, or the monks, if it is about a monastery, have to move this stack from one of the three poles to another one. each disk on the pole a little smaller than the one beneath it. The disks are of different sizes, and they are put on top of each other, according to their size, i.e. There is an old legend about a temple or monastery, which contains three poles. Enjoying this page? We offer live Python training courses covering the content of this site.
