Tower of Hanoi
Math & Computing
Category: Math & Computing
In short
A puzzle in which you move a stack of disks of different sizes, smallest on top, from one peg to another, one disk at a time, following set rules.
The story
The French mathematician Édouard Lucas is said to have marketed it under a pen name in 1883. It came with a legend: in an Indian temple, monks are moving 64 golden disks, and when they finish, the world will end. Moving 64 disks takes at least 2⁶⁴ − 1 moves, which at one move per second would take about 585 billion years.
The lens
The universe is about 13.8 billion years old, so even if the legend is true, there’s no need to worry about the end of the world. In programming classes it’s almost always the example used to teach recursion: solving a big problem by breaking it into smaller problems of the same shape.
Drop it casually
“How many years will this move take if we follow every rule? Feels like I’m playing the Tower of Hanoi.”