The shortest Path Algo(Simple) @ Dcoder

Problem: The Jones Trucking Company tracks the location of each of its trucks on a grid similar to an (x, y) plane. The home office is at location (0, 0). Read the coordinates of truck A and the coordinates of truck B and determine which is closer to the office.
Input: Input contains 4 space separated integers, first 2 are x,y for truck A, next are x,y for truck B.
Output: Output will be either A or B, bases on which one is closer to home office.
Constraints: The x-coordinate is in the range –20 .. 20. The y-coordinate is in the range –20 .. 20
Sample Input: 3 -2 -5 -3
Sample Output:
A

x1, y1, x2, y2 = map(int, input().split())
print('A' if (x1**2 + y1**2)**.5 < (x2**2 + y2**2)**.5 else 'B')
H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center