Zanjo_Betchi

W5A2 : Robot And The Charger

Aug 27th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. '''
  2. @Author: Zanjo
  3. @Date Of Creation: 27/08/18
  4. '''
  5.  
  6. import math
  7.  
  8.  
  9. def calculate_movements(x):
  10.     movements = {'UP': 0, 'DOWN': 0, 'RIGHT': 0, 'LEFT': 0}
  11.     for i in range(x):
  12.         n = input().split()
  13.         movements[n[0]] += int(n[1])
  14.     return movements
  15.  
  16.  
  17. x = int(input())
  18. movements = calculate_movements(x)
  19. resultant_y = movements['UP'] - movements['DOWN']
  20. resultant_x = movements['LEFT'] - movements['RIGHT']
  21. print(round(math.sqrt((resultant_x**2)+(resultant_y**2))), end="")
Add Comment
Please, Sign In to add comment