10
For reference as to what the tower of Hanoi is, either Google it or look on the Wikipedia page.
Your code should be able to do 2 things, and they are the following:
- Accept user input that specifies the number of discs at the starting point of the Hanoi tower
- Create output in a fashion of your choosing (so long as it is somehow logical) to show the solution to the tower puzzle.
An example of logical output would be the following (using a 4 disc start):
L1L2C1L1R-2R-1L1L2C1C-1R-2C1L1L2C1
L
represents the left peg, C
represents the center peg and R
represents the right peg and the numbers are how far to move the disk on that peg and in what direction. Positive numbers represent the number of pegs moving towards the rightmost peg (because the disks start on the leftmost peg).
The rules to tower of Hanoi are simple:
- Only one disk may be moved at a time.
- Each move consists of taking the upper disk from one of the pegs and sliding it onto another peg, on top of the other disks that may already be present on that peg.
- No disk may be placed on top of a smaller disk.
The disks start on the leftmost peg, largest on the bottom, smallest on the top, naturally.
Do we need to solve arbitrarily big towers, or is there some limit we can assume, like 10, 100, 1k, 1M discs? – user unknown – 2012-05-11T23:23:38.993
@userunknown if I were you, I wouldn't worry too much about extraordinarily large numbers, but I'll say that the highest number of disks that your program can handle should only be limited by the computer's memory capacity or its call stack limit (kind of the same thing I guess, since memory is a pretty general term). Don't let arbitrarily high numbers scare you when submitting your code, though; if your solution is creative but can only handle so many disks, I for one would still give you credit. – Carter Pape – 2012-05-12T01:43:04.560
Well, my idea was a pretty inefficient solving algorithm, and if the limit is, was the program can handle, it would be fine. But I had a look at the solutions so far, and realized, that I would play in a completely different league. – user unknown – 2012-05-12T01:48:21.173