Python Towers of Hanoi рекурсив
# Python towers of hanoi recursive
def hanoiArray(n):
def move(n, start=1, end=3):
if n > 0:
ans.append(move(n-1, start, 6 - start - end))
pegs[end-1].append(pegs[start-1].pop())
move(n-1, 6 - start - end, end)
return str(pegs)
ans, pegs = [], [list(range(n, 0, -1)), [], []]
ans.append(move(n))
return '\n'.join(ans)
Mackerel