Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. ss = []
  2.  
  3. def vb(x, y, s=0):
  4. if s == 2:
  5. ss.append(str(y) + str(x))
  6.  
  7. else:
  8. if x > 1 and y > 2:
  9. vb(x - 1, y - 2, s+ 1)
  10. if x > 2 and y > 1:
  11. vb(x - 2, y - 1, s + 1)
  12.  
  13. if x < 8 and y > 2:
  14. vb(x + 1, y - 2, s + 1)
  15. if x < 7 and y > 1:
  16. vb(x + 2, y - 1, s + 1)
  17.  
  18. if x < 7 and y < 8:
  19. vb(x + 2, y + 1, s + 1)
  20. if x < 8 and y < 7:
  21. vb(x + 1, y + 2, s + 1)
  22.  
  23. if x > 1 and y < 7:
  24. vb(x - 1, y + 2, s + 1)
  25. if x > 2 and y < 8:
  26. vb(x - 2, y + 1, s + 1)
  27.  
  28.  
  29.  
  30.  
  31. f=input()
  32. g = input()
  33. g = int(g)
  34. f = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8}[f]
  35. vb(f, g)
  36. ss = ['12345678'[int(i[1]) - 1] +' '+ i[0] for i in sorted(set(ss), key=lambda i: int(i))]
  37.  
  38.  
  39. for i in ss:
  40. print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement