fork(2) download
  1. def move(n, start, finish, temp):
  2. global count
  3. if n > 0:
  4. move(n - 1, start, temp, finish)
  5. print(n, start, finish)
  6. count += 1
  7. move(n - 1, temp, finish, start)
  8. count = 0
  9. n = int(input())
  10. move(n, 1, 3, 2)
  11. print(count)
Success #stdin #stdout 0.01s 9992KB
stdin
4
stdout
1 1 2
2 1 3
1 2 3
3 1 2
1 3 1
2 3 2
1 1 2
4 1 3
1 2 3
2 2 1
1 3 1
3 2 3
1 1 2
2 1 3
1 2 3
15