Describe Tower of Hanoi

In the classic "Tower of Hanoi" game/puzzle, a stack of disks, sorted by size, appears (on the left). You must move these to another stack (on the right) one at a time.

However, you cannot place a larger disk on top of a smaller one, so you must move disks temporarily to another stack.

Keywords: Tower of Hanoi, puzzle, recursion

Use Hanoi

Tap i:Help to view this document as an embedded help book

Select a Move Method and/or Number of Disks. Tap Start.

You or Newton move disks until puzzle is solved, or you tap Stop.

Move Method

user: you move a disk via gesture -- draw a horizontal line between two stacks

jumpRect: Newton moves disks quickly between stacks

moveRect: Newton moves disks slowly between stacks

printMove: Newton prints disk moves to NTK or Sloup Inspector

userCheat: you move a disk via gesture, but can cheat by placing a larger disk on top of a smaller one

Number of Disks

The maximum number of disks allowed (from 9 to 17) depends on screen size and orientation. The number you choose depends on your patience (and Newton's battery life)

Moves: total expected moves until solution: 2n-1

Move: displays the current number of moves

Hanoi Versions

A NewtonScript version of Hanoi first appeared in 1995 as an example for registered Newt users. This version supports Stop by using an iterative algorithm (from Scheme code by Stancu Radu) instead of recursion.

Hanoi created with NewtDevEnv; it's 1.x/2.x compatible. Help book created from this HTML document by Newt's Cape.

Best permanent bookmark for this (and possible other) versions: http://www.kagi.com/weyer/#Hanoi

Version 1.1 (11 Mar 1998)

Distribute Hanoi

Hanoi is freeware, and may be distributed freely as long as all of the files are included and unmodified.

Hanoi source is available to registered NewtDevEnv users.

© Copyright 1995-2017, S. Weyer. All Rights Reserved Worldwide.