Java Reference
In-Depth Information
bother with graphics, so you should output a sequence of instructions that will
solve the problem. The number of disks is a parameter to the method.
Hint:
If you could move up
n-1
of the disks from the first post to the third post
using the second post as a spare, the last disk could be moved from the first
post to the second post. Then, by using the same technique (whatever that
may be), you can move the
n-1
disks from the third post to the second post,
using the first disk as a spare. There! You have the puzzle solved. You only have
to decide what the nonrecursive case is, what the recursive case is, and when to
output instructions to move the disks.