Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. def printM(A):
  2. for elem in A:
  3. print(*elem)
  4.  
  5.  
  6. kor = [0, 0]
  7. data = [kor]
  8. to = [0, 1]
  9. comands = list(input())
  10. k = 0
  11. for comand in comands:
  12. if comand == 'R':
  13. if to == [0,1]:
  14. to = [1,0]
  15. elif to == [1, 0]:
  16. to = [0, -1]
  17. elif to == [0, -1]:
  18. to = [-1, 0]
  19. elif to == [-1, 0]:
  20. to = [0, 1]
  21. elif comand == 'L':
  22. if to == [0,1]:
  23. to = [-1,0]
  24. elif to == [1, 0]:
  25. to = [0, 1]
  26. elif to == [0, -1]:
  27. to = [1, 0]
  28. elif to == [-1, 0]:
  29. to = [0, -1]
  30. elif comand == 'S':
  31. kor = [kor[0] + to[0], kor[1] + to[1]]
  32. k += 1
  33. if kor in data:
  34. print(k)
  35. break
  36. data.append(kor)
  37. else:
  38. print(-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement