Sign inSoon
Tools Contracts News Events Companies Calendar Salary Webmail Guides Power Games Docs Programs Radio

Tools › Games › Tower of Hanoi

Tower of Hanoi – the classic logic puzzle

Move the whole tower from the left peg to the right peg. Only one disc may be moved at a time, and a larger disc may never be placed on a smaller one. Choose 3 to 8 discs, try to reach the minimum number of moves and beat your own records.

Discs:
Moves: 0 / 7 Time: 0:00 Best: –

How to play

All discs start on the left peg, sorted with the largest at the bottom. Your goal is to move the whole tower to the right peg. Tap the peg you want to take the top disc from and then the peg you want to put it on – or drag the disc there. You may only move one disc at a time, only the top disc of a peg can be moved, and a disc may never lie on top of a smaller disc. An illegal move is rejected and the peg shakes. The counter shows your moves next to the minimum, the clock starts at your first move, and your best moves and time for each number of discs are saved in the browser.

The puzzle has a beautiful recursive solution. To move a tower of n discs from the left to the right peg, first move the n − 1 smaller discs to the middle peg, then move the largest disc to the right peg, and finally move the n − 1 discs from the middle peg on top of it. Moving n discs therefore takes twice as many moves as n − 1 discs plus one, which gives exactly 2n − 1 moves: 7 for 3 discs, 31 for 5 and 255 for 8. It is also the smallest possible number. There is a simple pattern too: every second move is made by the smallest disc, which always travels around the pegs in the same direction. Show solution animates the optimal solution from the position you are in.

The puzzle was invented by the French mathematician Édouard Lucas and published in 1883. It came with a legend about a temple where priests move 64 golden discs between three diamond needles, and the world will end when they are finished. With 64 discs the minimum is 264 − 1 = 18,446,744,073,709,551,615 moves – at one move per second that would take about 585 billion years. The Tower of Hanoi is often used to teach recursion in programming and to practise planning and working memory.

More games

→ 2048
→ Memory
→ Sudoku
→ Solitaire

Free and no account · The game runs entirely in your browser · About Metodai