Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def closest_point(x_1, y_1, x_2, y_2):
- x_closest = x_1
- y_closest = y_1
- distance1 = math.sqrt((math.pow(x1, 2) + math.pow(y1, 2)))
- distance2 = math.sqrt((math.pow(x2, 2) + math.pow(y2, 2)))
- if int(distance1) > int(distance2):
- x_closest = x_2
- y_closest = y_2
- return x_closest, y_closest
- x1 = float(input())
- y1 = float(input())
- x2 = float(input())
- y2 = float(input())
- closest_point_x, closest_point_y = closest_point(x1, y1, x2, y2)
- print(f"({math.floor(closest_point_x)}, {math.floor(closest_point_y)})")
Add Comment
Please, Sign In to add comment