Guest User

Untitled

a guest
Jan 4th, 2025
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 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.     firstTriangleSide1 = math.fabs(co_a1 - co_a2)
  5.     firstTriangleSide2 = math.fabs(co_b1 - co_b2)
  6.     firstDist = math.hypot(firstTriangleSide1, firstTriangleSide2)
  7.  
  8.     secondTriangleSide1 = math.fabs(co_a3 - co_a4)
  9.     secondTriangleSide2 = math.fabs(co_b3 - co_b4)
  10.     secondDist = math.hypot(secondTriangleSide1, secondTriangleSide2)
  11.  
  12.     if firstDist >= secondDist :
  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 = float(input())
  26. co_y1 = float(input())
  27. co_x2 = float(input())
  28. co_y2 = float(input())
  29. co_x3 = float(input())
  30. co_y3 = float(input())
  31. co_x4 = float(input())
  32. co_y4 = float(input())
  33. print(result_coord(co_x1, co_y1, co_x2, co_y2, co_x3, co_y3, co_x4, co_y4))
  34.  
Advertisement
Add Comment
Please, Sign In to add comment