This is a more complex game. You should be able to solve it in 31 moves, or 2N-1, where N is the number of disks.

You can look at the java source code here: src/TowerOfHanoi.java