Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Move(a, b, c, n):
- if(n == 1):
- print(a[1][-1], a[0], c[0], sep=' ')
- c[1].append(a[1][-1])
- a[1].pop()
- return
- Move(a, c, b, n-1)
- print(a[1][-1], a[0], c[0], sep=' ')
- c[1].append(a[1][-1])
- a[1].pop()
- Move(b, a, c, n-1)
- n = int(input())
- a, b, c = [1, [n-i for i in range(n)]], [2, []], [3, []]
- if(n % 2 == 1):
- b, c = c, b
- Move(a, b, c, n)
- a, c, b = c, b, a
- for i in range(n-1):
- Move(a, b, c, n-i-1)
- a, c = c, a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement