All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Towers of Hanoi variation (Posted on 2005-05-03) Difficulty: 3 of 5
There are some poles, and on the first pole are some rings, each a different size. The sizes of the rings increases from the top to the bottom of the pole. The only allowable move is to take the top ring from any pole and place onto another pole. You cannot place a ring on top of another ring unless the other ring is exactly one size bigger. You can make as many moves as you like.

Your goal is to move all the rings onto the second pole, in the same order. What is the highest number of rings that can be moved when there are N poles? How can you move this many rings?

  Submitted by Tristan    
Rating: 4.0000 (4 votes)
Solution: (Hide)
To solve this problem, we will need a good algorithm to move as many possible hoops from one pole to another when there are N hoops.

In this algorithm, I define H(N) to be the maximum number of hoops that can be moved from pole 1 to pole 2 when there are N poles (including the first pole). F(N) is the maximum number of hoops that can be moved from pole 1 to pole 2 when there are indefinitely many extra hoops on pole 1 and N *empty* poles.

Algorithm for moving F(N) hoops:
1. There are indefinitely hoops on pole 1, and N+1 poles. Move F(N-1) hoops from pole 1 to pole 2.
2. Move F(N-2) hoops from pole 1 to pole 3.
3. Move F(N-3) hoops from pole 1 to pole 4.
4. Repeat this pattern until only the last pole is empty.
5. Move the last hoop from the first pole to the last pole. All steps previous to this one are repeated backwards, moving all the hoops onto the last pole instead of the first.

From this algorithm we determine that F(N) is equal to the sum F(N-1)+F(N-2)+F(N-3)+...+F(2)+F(1)+1. Since F(1) is trivially 1, F(N) must be 2(N-1).

The algorithm for moving H(N) is exactly the same, except we start with H(N) hoops and N poles. When the last hoop is moved to the last pole, pole 1 is empty and available to complete the steps. From this algorithm we determine that H(N) is equal to F(N-1)+F(N-2)+...+F(3)+F(2)+1. Since F(N) is a known function, H(N) is easily proven to be 2(N-1)-1.

Comments: ( You must be logged in to post comments.)
  Subject Author Date
Puzzle Thoughts K Sengupta2023-06-28 22:11:36
No SubjectArjun2007-09-08 12:14:11
my solution (someone back me up)cecil tucker2005-06-30 04:39:42
AdditionJurgen2005-05-05 18:58:12
No SubjectJurgen2005-05-05 18:22:31
Solutionre(3): solution (I think)Avin2005-05-03 19:43:48
re(2): solution (I think)Erik O.2005-05-03 18:20:50
SolutionSolutionLeming2005-05-03 18:20:21
re: solution (I think)Jer2005-05-03 17:53:32
SolutionMovement algorithm - spoiler?Erik O.2005-05-03 17:53:06
re: HanoiBruce Brantley2005-05-03 17:24:13
Hints/TipsHanoiBruce Brantley2005-05-03 17:07:48
On second thought...Jer2005-05-03 17:05:25
QuestionIs this problem asking what you think?Jer2005-05-03 17:02:45
Solutionsolution (I think)Erik O.2005-05-03 15:00:31
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (25)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information