Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- queue = []
- actual_pos = 0
- target_pos = 0
- step = 5
- while True:
- p = input("Posición deseada: ")
- if p.isnumeric():
- queue.append(int(p))
- target_pos = queue[0]
- if target_pos > actual_pos:
- actual_pos += step
- if actual_pos > target_pos:
- actual_pos = target_pos
- elif target_pos < actual_pos:
- actual_pos -= step
- if actual_pos < target_pos:
- actual_pos = target_pos
- if target_pos == actual_pos:
- queue.pop(0)
- print(actual_pos, target_pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement