Taigar2000

Task B

Oct 15th, 2020 (edited)
989
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def Move(a, b, c, n):
  2.     if(n == 1):
  3.         print(a[1][-1], a[0], c[0], sep=' ')
  4.         c[1].append(a[1][-1])
  5.         a[1].pop()
  6.         return
  7.     Move(a, c, b, n-1)
  8.     print(a[1][-1], a[0], c[0], sep=' ')
  9.     c[1].append(a[1][-1])
  10.     a[1].pop()
  11.     Move(b, a, c, n-1)
  12.  
  13. n = int(input())
  14. a, b, c = [1, [n-i for i in range(n)]], [2, []], [3, []]
  15. if(n % 2 == 1):
  16.     b, c = c, b
  17. Move(a, b, c, n)
  18. a, c, b = c, b, a
  19. for i in range(n-1):
  20.     Move(a, b, c, n-i-1)
  21.     a, c = c, a
  22.  
RAW Paste Data