Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def calc_distance(horizontal, vertical):
- steps = 0
- while vertical != 0 and horizontal != 0:
- steps += 1
- vertical -= (vertical/abs(vertical))/2
- horizontal -= horizontal/abs(horizontal)
- if(vertical == 0):
- steps += abs(horizontal)
- elif(horizontal == 0):
- steps += abs(vertical)
- return steps
- vertical = 0
- horizontal = 0
- max_steps = 0
- dist = 0
- for move in movement:
- vertical += move[0]
- horizontal += move[1]
- dist = calc_distance(horizontal, vertical)
- if(dist > max_steps):
- max_steps = dist
- print("Coordinates (" + str(vertical) + ", " + str(horizontal) + ")")
- print("Steps: " + str(dist))
- print("Max steps: " + str(max_steps))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement