Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- @Author: Zanjo
- @Date Of Creation: 27/08/18
- '''
- import math
- def calculate_movements(x):
- movements = {'UP': 0, 'DOWN': 0, 'RIGHT': 0, 'LEFT': 0}
- for i in range(x):
- n = input().split()
- movements[n[0]] += int(n[1])
- return movements
- x = int(input())
- movements = calculate_movements(x)
- resultant_y = movements['UP'] - movements['DOWN']
- resultant_x = movements['LEFT'] - movements['RIGHT']
- print(round(math.sqrt((resultant_x**2)+(resultant_y**2))), end="")
Add Comment
Please, Sign In to add comment