usmiwka80

3. Longer Line

Dec 30th, 2024
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.03 KB | Software | 0 0
  1. import math
  2.  
  3.  
  4. def result_coord(co_a1, co_b1, co_a2, co_b2, co_a3, co_b3, co_a4, co_b4):
  5.     co_a1 = float(co_a1)
  6.     co_b1 = float(co_b1)
  7.     co_a2 = float(co_a2)
  8.     co_b2 = float(co_b2)
  9.     co_a3 = float(co_a3)
  10.     co_b3 = float(co_b3)
  11.     co_a4 = float(co_a4)
  12.     co_b4 = float(co_b4)
  13.     distance1 = math.hypot(co_a1 ** 2, co_b1 ** 2)
  14.     distance2 = math.hypot(co_a2 ** 2, co_b2 ** 2)
  15.     distance3 = math.hypot(co_a3 ** 2, co_b3 ** 2)
  16.     distance4 = math.hypot(co_a4 ** 2, co_b4 ** 2)
  17.     max_distance = max(distance1, distance2, distance3, distance4)
  18.     # distance4
  19.     if max_distance == distance4:
  20.         max_distance2 = max(distance1, distance2, distance3)
  21.         if max_distance2 == distance3:
  22.             if max_distance > max_distance2:
  23.                 return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a4)}, {math.floor(co_b4)})")
  24.             elif max_distance == max_distance2:
  25.                 if distance1 >= distance2:
  26.                     return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a3)}, "
  27.                                  f"{math.floor(co_b3)})")
  28.                 elif distance1 < distance2:
  29.                     return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a3)}, "
  30.                                  f"{math.floor(co_b3)})")
  31.         elif max_distance2 == distance2:
  32.             if max_distance > max_distance2:
  33.                 return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a4)}, {math.floor(co_b4)})")
  34.             elif max_distance == max_distance2:
  35.                 if distance1 >= distance3:
  36.                     return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a2)}, "
  37.                                  f"{math.floor(co_b2)})")
  38.                 elif distance1 < distance3:
  39.                     return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a2)}, "
  40.                                  f"{math.floor(co_b2)})")
  41.         elif max_distance2 == distance1:
  42.             if max_distance > max_distance2:
  43.                 return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a4)}, {math.floor(co_b4)})")
  44.             elif max_distance == max_distance2:
  45.                 if distance2 >= distance3:
  46.                     return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a1)}, "
  47.                                  f"{math.floor(co_b1)})")
  48.                 elif distance2 < distance3:
  49.                     return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a1)}, "
  50.                                  f"{math.floor(co_b1)})")
  51.     # distance3
  52.     elif max_distance == distance3:
  53.         max_distance2 = max(distance1, distance2, distance4)
  54.         if max_distance2 == distance4:
  55.             if max_distance > max_distance2:
  56.                 return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a3)}, {math.floor(co_b3)})")
  57.             elif max_distance == max_distance2:
  58.                 if distance1 >= distance2:
  59.                     return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a3)}, "
  60.                                  f"{math.floor(co_b3)})")
  61.                 elif distance1 < distance2:
  62.                     return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a3)}, "
  63.                                  f"{math.floor(co_b3)})")
  64.         elif max_distance2 == distance2:
  65.             if max_distance > max_distance2:
  66.                 return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a3)}, {math.floor(co_b3)})")
  67.             elif max_distance == max_distance2:
  68.                 if distance1 >= distance4:
  69.                     return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a2)}, "
  70.                                  f"{math.floor(co_b2)})")
  71.                 elif distance1 < distance4:
  72.                     return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a3)}, "
  73.                                  f"{math.floor(co_b3)})")
  74.         elif max_distance2 == distance1:
  75.             if max_distance > max_distance2:
  76.                 return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a3)}, {math.floor(co_b3)})")
  77.             elif max_distance == max_distance2:
  78.                 if distance2 >= distance4:
  79.                     return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a1)}, "
  80.                                  f"{math.floor(co_b1)})")
  81.                 elif distance2 < distance4:
  82.                     return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a1)}, "
  83.                                  f"{math.floor(co_b1)})")
  84.     # distance2
  85.     elif max_distance == distance2:
  86.         max_distance2 = max(distance1, distance3, distance4)
  87.         if max_distance2 == distance4:
  88.             if max_distance > max_distance2:
  89.                 return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a2)}, {math.floor(co_b2)})")
  90.             elif max_distance == max_distance2:
  91.                 if distance1 >= distance3:
  92.                     return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a2)}, "
  93.                                  f"{math.floor(co_b2)})")
  94.                 elif distance1 < distance3:
  95.                     return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a2)}, "
  96.                                  f"{math.floor(co_b2)})")
  97.         elif max_distance2 == distance3:
  98.             if max_distance > max_distance2:
  99.                 return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a2)}, {math.floor(co_b2)})")
  100.             elif max_distance == max_distance2:
  101.                 if distance1 >= distance4:
  102.                     return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a2)}, "
  103.                                  f"{math.floor(co_b2)})")
  104.                 elif distance1 < distance4:
  105.                     return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a2)}, "
  106.                                  f"{math.floor(co_b2)})")
  107.         elif max_distance2 == distance1:
  108.             if max_distance > max_distance2:
  109.                 return print(f"({math.floor(co_a1)}, {math.floor(co_b1)})({math.floor(co_a2)}, {math.floor(co_b2)})")
  110.             elif max_distance == max_distance2:
  111.                 if distance3 >= distance4:
  112.                     return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a1)}, "
  113.                                  f"{math.floor(co_b1)})")
  114.                 elif distance3 < distance4:
  115.                     return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a1)}, "
  116.                                  f"{math.floor(co_b1)})")
  117.     # distance1
  118.     elif max_distance == distance1:
  119.         max_distance2 = max(distance2, distance3, distance4)
  120.         if max_distance2 == distance4:
  121.             if max_distance > max_distance2:
  122.                 return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a1)}, {math.floor(co_b1)})")
  123.             elif max_distance == max_distance2:
  124.                 if distance2 >= distance3:
  125.                     return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a1)}, "
  126.                                  f"{math.floor(co_b1)})")
  127.                 elif distance2 < distance3:
  128.                     return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a1)}, "
  129.                                  f"{math.floor(co_b1)})")
  130.         elif max_distance2 == distance3:
  131.             if max_distance > max_distance2:
  132.                 return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a1)}, {math.floor(co_b1)})")
  133.             elif max_distance == max_distance2:
  134.                 if distance2 >= distance4:
  135.                     return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a1)}, "
  136.                                  f"{math.floor(co_b1)})")
  137.                 elif distance2 < distance4:
  138.                     return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a1)}, "
  139.                                  f"{math.floor(co_b1)})")
  140.         elif max_distance2 == distance2:
  141.             if max_distance > max_distance2:
  142.                 return print(f"({math.floor(co_a2)}, {math.floor(co_b2)})({math.floor(co_a1)}, {math.floor(co_b1)})")
  143.             elif max_distance == max_distance2:
  144.                 if distance3 >= distance4:
  145.                     return print(f"({math.floor(co_a3)}, {math.floor(co_b3)})({math.floor(co_a1)}, "
  146.                                  f"{math.floor(co_b1)})")
  147.                 elif distance3 < distance4:
  148.                     return print(f"({math.floor(co_a4)}, {math.floor(co_b4)})({math.floor(co_a1)}, "
  149.                                  f"{math.floor(co_b1)})")
  150.  
  151.  
  152. co_x1 = input()
  153. co_y1 = input()
  154. co_x2 = input()
  155. co_y2 = input()
  156. co_x3 = input()
  157. co_y3 = input()
  158. co_x4 = input()
  159. co_y4 = input()
  160. result_coord(co_x1, co_y1, co_x2, co_y2, co_x3, co_y3, co_x4, co_y4)
  161.  
Advertisement
Add Comment
Please, Sign In to add comment