Report as inappropriate.
Tower of Hanoi:
The Tower of Hanoi, also known as the Tower of Brahma or Lucas' Tower, is a mathematical game or puzzle. It consists of three rods, and several disks of different sizes that slide on and off of the rods. You begin the puzzle with all the disks stacked in ascending order with largest on the bottom, on one of the rods, forming a conical shape. The goal of the puzzle is to move the entire stack of disks to another rod, following a few simple rules:
1. Only one disk can be moved at a time.
2. In every move, you may only take the top disk from a stack.
3. A larger disk cannot be placed on top of a smaller disk.
Using these rules makes for a simple yet interesting puzzle. Supposedly, the origin of the puzzle comes from a legend about Hindu priests. So the story goes, there was once an Indian temple which contained a large room with three large posts. On these posts were 64 giant, golden disks. According to the legend, they believed that when the last move of the puzzle was completed, the world would end. However, to complete this would require over 18 quintillion steps, a step consisting of moving the top ring from one post to another.
Type a number in the text field and press start to begin with that many rings on the far left 'rod'. I have chosen not to depict the rods, although there are only three possible locations for every 'ring', giving the appearance of invisible rods. Each ring is a random color every time. Hope you enjoy it! By the way, as danpost pointed out in the comments, the formula giving the minimum number of moves to complete the puzzle is ((2^n)-1), where n is the number of rings.
Credit to bourne for his GUI Components, the button and the textfield
I solved the tower of hanoi puzzle using recursion, where you reference a method from inside the method, although there are other ways to do it iteratively. I chose not to do this, as the recursive solution presented itself to me more clearly and before the iterative one did. If you would like to learn more about recursion and its applications, I highly recommend it, as it is a very useful skill to have.