hanoi rotation implementation