Solution for tower of hanoi