Bicolor Towers of Hanoi

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram CDF Player or other Wolfram Language products.

Requires a Wolfram Notebook System

Edit on desktop, mobile and cloud with any Wolfram Language product.

The towers of Hanoi puzzle involves three vertical rods and a number of disks of unequal size with holes in their centers. The disks can slide down a rod to make a stack. The initial set up has all the disks on one rod, subject to the general rule 1:


1. No disk can ever be covered by a larger one.

2. You can move one disk at a time.

3. You can move a disk from the top of one stack to the top of another stack.

The object is to move all the disks to another stack.

The bicolor towers of Hanoi is a more complicated version: there are four rods and the original stack contains up to three pairs of disks of equal size but two different colors (here, blue and green). The object is to move all the disks to two separate stacks, each of one color. In this Demonstration, the solution requiring the smallest number of steps possible is shown.

Currently, there is no algorithm that gives the minimum number of steps needed to solve the problem. This Demonstration simulates the process for up to three pairs.


Contributed by: Brian Lin and Sarah Brand (June 2016)
Special thanks to the University of Illinois NetMath Program and the mathematics department at William Fremd High School, and especially to Mr. Grattoni.
Open content licensed under CC BY-NC-SA




[1] P. V. Chaugule, “Math and Fun with Algorithms: A Recursive Solution to Bicolor Towers of Hanoi Problem,” Recreational Mathematics Magazine, 4, 2015 pp. 37–48.

[2] D. W. Palmer, “Exploring Recursion with Variations on the Towers of Hanoi,” Journal of Computing Sciences in Colleges, 12(2), 1996 pp. 59–66.

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.