Guest User

Untitled

a guest
Nov 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. path = raw_input("Введіть шлях!")
  3.  
  4. x = 0
  5. y = 0
  6.  
  7. pt = []
  8. count = 0
  9.  
  10. class Position:
  11.  
  12. def __init__(self, x, y):
  13. self.x = x
  14. self.y = y
  15.  
  16. for p in path:
  17. c = str(p)
  18. if c == 'r':
  19. x = x + 1
  20. count = count + 1
  21. elif c == 'l':
  22. x = x - 1
  23. count = count + 1
  24. elif c == 'u':
  25. y = y + 1
  26. count = count + 1
  27. elif c == 'd':
  28. y = y - 1
  29. count = count + 1
  30. t = str(count)
  31. t = Position(x, y)
  32. print 'x', t.x
  33. print 'y', t.y
  34. for i in int(count):
  35. n = str(i)
  36. if n.x == t.x and n.y == t.y:
  37. break
  38.  
  39.  
  40. print count
  41.  
  42.  
  43. #if c in count[]:
  44. #print 'Fail'
Add Comment
Please, Sign In to add comment