Advertisement
Guest User

Untitled

a guest
Jan 4th, 2025
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. import math
  2.  
  3. def result_coord(co_a1, co_b1, co_a2, co_b2, co_a3, co_b3, co_a4, co_b4):
  4.     p1 = [co_a1, co_b1]
  5.     q1 = [co_a2, co_b2]
  6.     p2 = [co_a3, co_b3]
  7.     q2 = [co_a4, co_b4]
  8.  
  9.     dist1 = math.dist(p1, q1)
  10.     dist2 = math.dist(p2, q2)
  11.  
  12.     if dist1 >= dist2 :
  13.         distToCenter1 = math.hypot(co_a1, co_b1)
  14.         distToCenter2 = math.hypot(co_a2, co_b2)
  15.         result = f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a2)}, {math.floor(co_b2)})" \
  16.             if distToCenter1 <= distToCenter2 else f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a1)}, {math.floor(co_b1)})"
  17.     else:
  18.         distToCenter1 = math.hypot(co_a3, co_b3)
  19.         distToCenter2 = math.hypot(co_a4, co_b4)
  20.         result = f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a4)}, {math.floor(co_b4)})" \
  21.             if distToCenter1 <= distToCenter2 else f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a3)}, {math.floor(co_b3)})"
  22.  
  23.     return result
  24.  
  25. co_x1, co_y1, co_x2, co_y2, co_x3, co_y3, co_x4, co_y4 = float(input()),\
  26.     float(input()), float(input()), float(input()), float(input()), float(input()), float(input()), float(input())
  27. print(result_coord(co_x1, co_y1, co_x2, co_y2, co_x3, co_y3, co_x4, co_y4))
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement