Detour: The Towers of Hanoi

Let’s demonstrate the Towers of Hanoi problem and an approach to solve it.

The Towers of Hanoi puzzle consists of three vertical pegs and a number of disks of different sizes, each with a hole in its center so that it fits on the pegs. The disks are initially stacked on the left peg (peg 1) so that disks increase in size from the top down. The puzzle is played by moving one disk at a time between pegs, with the goal of moving all disks from the left peg (peg 1) to the right peg (peg 3). However, you’re not allowed to place a disk on top of a smaller disk.

Get hands-on with 1200+ tech skills courses.