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

Home > Algorithms
Towers of Hanoi (Posted on 2003-09-07) Difficulty: 3 of 5
You have three small poles and five hoops - XS, S, M, L, XL (as in extra small, small, medium, large and extra large). They are placed on pole 1 in order, with largest at the bottom.

You can move one hoop at a time, and the hoops you are not moving have to be on a pole. You also cannot place a hoop on top of a smaller one. How can you move the hoops so that they are in the same order as they are now, but on pole 3?

See The Solution Submitted by Lewis    
Rating: 3.0667 (15 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Question Recursion challenge | Comment 7 of 22 |
I am still trying induction so if I made a mistake in that last post, just tell me please! :)

I have another challenge: How could you use recursion in a program to print out a list of hoops when given the number x of how many hoops they are? (Refer to the hoops as A, B, C and so on to reduce counting the X before a S or L)

Sample out put when x=3:

Move A from 1 to 3
Move B from 1 to 2
Move A from 3 to 2
Move C from 1 to 3
Move A from 2 to 1
Move B from 2 to 3
Move A from 1 to 3
Edited on September 7, 2003, 2:47 pm
  Posted by Gamer on 2003-09-07 14:19:04
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
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