+ 8
Sorted Hanoi Towers
# I need help with sorted hanoi tower (better python but I know other languages). # What even number disk to tower 2 # and other disk to tower 3 #? # this code sorted even number disk on second or third tower: def move(n, a1, a3): if n > 0: move(n-1, a1, 6 - a1 - a3) print(n, a1, a3) move(n-1, 6 - a1 - a3, a3) def movesort(n, a1, a3): if n > 1: move(n-1, a1, 6 - a1 - a3) print(n, a1, a3) if n > 3: move(n-3, 6 - a1 - a3, a1) if n > 2: print(n - 2, 6 - a1 - a3, a3) if n > 3: move(n-3, a1, 6 - a1 - a3) movesort(int(input()), 1, 3)
1 Respuesta
+ 2
i guess you can find hanoi tower in project euler