Advertisement
DiYane

Longer line

Sep 20th, 2023
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. from math import floor
  2.  
  3. x1 = float(input())
  4. y1 = float(input())
  5. x2 = float(input())
  6. y2 = float(input())
  7. x3 = float(input())
  8. y3 = float(input())
  9. x4 = float(input())
  10. y4 = float(input())
  11.  
  12. def distance(_x1, _y1, _x2, _y2):
  13.     return (_x2-_x1)**2 + (_y2-_y1)**2
  14.  
  15. x1y1 = distance(x1, y1, 0, 0)
  16. x2y2 = distance(x2, y2, 0, 0)
  17. x3y3 = distance(x3, y3, 0, 0)
  18. x4y4 = distance(x4, y4, 0, 0)
  19.  
  20. line_1 = x1y1 + x2y2
  21. line_2 = x3y3 + x4y4
  22.  
  23. if line_1 >= line_2:
  24.     if x1y1 <= x2y2:
  25.         print(f'({floor(x1)}, {floor(y1)})({floor(x2)}, {floor(y2)})')
  26.     else:
  27.         print(f'({floor(x2)}, {floor(y2)})({floor(x1)}, {floor(y1)})')
  28. if line_1 < line_2:
  29.     if x3y3 <= x4y4:
  30.         print(f'({floor(x3)}, {floor(y3)})({floor(x4)}, {floor(y4)})')
  31.     else:
  32.         print(f'({floor(x4)}, {floor(y4)})({floor(x3)}, {floor(y3)})')
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement