Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. queue = []
  2. actual_pos = 0
  3. target_pos = 0
  4. step = 5
  5.  
  6. while True:
  7. p = input("Posición deseada: ")
  8. if p.isnumeric():
  9. queue.append(int(p))
  10. target_pos = queue[0]
  11.  
  12. if target_pos > actual_pos:
  13. actual_pos += step
  14. if actual_pos > target_pos:
  15. actual_pos = target_pos
  16.  
  17. elif target_pos < actual_pos:
  18. actual_pos -= step
  19. if actual_pos < target_pos:
  20. actual_pos = target_pos
  21. if target_pos == actual_pos:
  22. queue.pop(0)
  23.  
  24. print(actual_pos, target_pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement