1# Python towers of hanoi recursive
2def hanoiArray(n):
3
4 def move(n, start=1, end=3):
5 if n > 0:
6 ans.append(move(n-1, start, 6 - start - end))
7 pegs[end-1].append(pegs[start-1].pop())
8 move(n-1, 6 - start - end, end)
9 return str(pegs)
10
11 ans, pegs = [], [list(range(n, 0, -1)), [], []]
12 ans.append(move(n))
13 return '\n'.join(ans)