Cut the knot: learn to enjoy mathematics
A math books store at a unique math study site. Shopping at the store helps maintain the site. Thank you.
Math & English enrichment at SchoolPlus-Online
HoodaMath: games and movies
Sites for teachers
Sites for parents
Terms of use
Awards
Interactive Activities

CTK Exchange
CTK Wiki Math
CTK Insights - a blog
Math Help

III Millennium Olympiad

Games & Puzzles
What Is What
Arithmetic/Algebra
Geometry
Probability
Outline Mathematics
Make an Identity
Book Reviews
Stories for Young
Eye Opener
Analog Gadgets
Inventor's Paradox
Did you know?...
Proofs
Math as Language
Things Impossible
Visual Illusions
My Logo
Math Poll
Cut The Knot!
MSET99 Talk
Other Math sites
Front Page
Movie shortcuts
Personal info
Privacy Policy

Guest book
News sites

Recommend this site

Games to relax

Sites for teachers
Sites for parents

Education & Parenting

Manifesto: what CTK is about Buying a book is a commitment to learning Table of content Things you can find on CTK Chronology of updates Email to Cut The Knot Recommend this page

Tower of Hanoi, the Hard Way

Kai Birger Nielsen from Denmark has observed that the rules of the Tower of Hanoi puzzle may be bent a little still leaving it amenable to the recursive analysis. In his own words,

 

The rules of the game don't prohibit silly moves like moving the little ring from one peg to another and then back again, i.e. wasting two moves, but if you want to solve the game with as few moves as possible you don't want to waste moves.

A variation of the game is to solve the game using as many moves as possible without returning to a previous configuration of the rings.


This applet requires Sun's Java VM 2 which your browser may perceive as a popup. Which it is not. If you want to see the applet work, visit Sun's website at http://www.java.com/en/download/index.jsp, download and install Java VM and enjoy the applet.


Buy this applet
What if applet does not run?

One way of doing this is:


Solve(N, Src, Aux, Dst)
    if N is 0 
      exit
    else
      Solve(N-1, Src, Aux, Dst)
      Move from Src to Aux
      Solve(N-1, Dst, Aux, Src)
      Move from Aux to Dst
      Solve(N-1, Src, Aux, Dst)

This uses 3n - 1 moves. You can describe any configuration of n rings on three pegs as an n-digit number with the digits 0, 1 and 2 and conversely you can convert any such n-digit number into a configuration of the n rings. Thus there are 3n different configurations and so you can at most use 3n - 1 different moves to move the pegs without repeating any configuration.

So we have just proved that this is indeed the best way of wasting time.


For n = 3, the sequence of moves appears as

  1. Move from Src to Aux
  2. Move from Aux to Dst
  3. Move from Src to Aux
  4. Move from Dst to Aux
  5. Move from Aux to Src
  6. Move from Aux to Dst
  7. Move from Src to Aux
  8. Move from Aux to Dst
  9. Move from Src to Aux
  10. Move from Dst to Aux
  11. Move from Aux to Src
  12. Move from Dst to Aux
  13. Move from Src to Aux
  14. Move from Aux to Dst
  15. Move from Aux to Src
  16. Move from Dst to Aux
  17. Move from Aux to Src
  18. Move from Aux to Dst
  19. Move from Src to Aux
  20. Move from Aux to Dst
  21. Move from Src to Aux
  22. Move from Dst to Aux
  23. Move from Aux to Src
  24. Move from Aux to Dst
  25. Move from Src to Aux
  26. Move from Aux to Dst
  1. Tower of Hanoi
  2. Tower of Hanoi, the Hard Way
  3. Bicolor Towers of Hanoi
  4. 3-Colors Tower of Hanoi
  5. 3-Colors Tower of Hanoi (Algorithm)
  6. Hanoing
  7. Sierpinski Gasket and Tower of Hanoi

Copyright © 1996-2009 Alexander Bogomolny

33061919Page copy protected against web site content infringement by Copyscape


Search:
Keywords:

Google
Web CTK