Advertisement
ivanshir

Untitled

Jul 7th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.49 KB | None | 0 0
  1. from itertools import product
  2. import math
  3.  
  4. def compare(a, b):
  5.     return abs(a - b) < 10 ** -6
  6.  
  7. def vector(x1, y1, x2, y2):
  8.     return math.sqrt((x2 - x1) ** 2 + (y2 -y1) ** 2)
  9.  
  10. def test(x1, y1, x2, y2, x3, y3):
  11.     a = vector(x1, y1, x2, y2)
  12.     b = vector(x2, y2, x3, y3)
  13.     c = vector(x3, y3, x1, y1)
  14.     if a < b + c and b < a + c and c < b + a:
  15.         if compare(a, b) and compare(b, c) and compare(c, a):
  16.             return "ISOSCELES TRIANGLE" + " " + str(a)
  17.         else:
  18.             if compare(a, b) or compare(b, c) or compare(c, a):
  19.                 if not compare(a, b):
  20.                     return "EQUILATERAL TRIANGLE" + " " + str(min(a, b)) + " " + str(max(a, b))
  21.                 else:
  22.                     return "EQUILATERAL TRIANGLE" + " " + str(min(b, c)) + " " + str(max(b, c))
  23.             else:
  24.                 return "SIMPLE TRIANGLE" + " " + str(a) + " " + str(b) + " " + str(c)
  25.     else:
  26.         return "NOT TRIANGLE"
  27.  
  28. k =  int(input())
  29. mapX = []
  30. mapY = []
  31. comb = []
  32. count = 0
  33. while count != k:
  34.     count += 1
  35.     x, y = input().split(" ")
  36.     mapX.append(float(x))
  37.     mapY.append(float(y))
  38. a = 0
  39. b = 0
  40. c = 0
  41. for a, b, c in product(range(k+1), range(k+1), range(k+1)):
  42.     if (not (a == b or b == c or a == c)) and a != 0 and b !=0 and c != 0:
  43.         if a < b and b < c:
  44.             a -= 1
  45.             b -= 1
  46.             c -= 1
  47.             result = test(mapX[a], mapY[a], mapX[b], mapY[b], mapX[c], mapY[c])
  48.             print(a+1, b+1, c+1, "-", result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement