summaryrefslogtreecommitdiff
path: root/python-func/task10.py
blob: 8c548e1cd6e3a642585b320fb920445e4ae04dbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from math import sqrt


class Point:
    def __init__(self, x: float, y: float):
        self.x = x
        self.y = y


def dist(p1: Point, p2: Point) -> float:
    return sqrt((p2.x - p1.x) ** 2 + (p2.y - p1.y) ** 2)


def solve(points: list[Point]) -> int:
    cnt = 0
    for p1 in points:
        for p2 in points:
            for p3 in points:
                if p1 == p2 or p2 == p3 or p3 == p1:
                    continue

                a = dist(p1, p2)
                b = dist(p2, p3)
                c = dist(p3, p1)

                if a + b > c and a + c > b and b + c > a:
                    cnt += 1
    return cnt


n = int(input("Введите количество точек: "))
points = []
for i in range(n):
    x, y = map(float, input().split())
    p = Point(x, y)
    points.append(p)

res = solve(points)
print(f"Используя введённые точки можно создать {res} треугольников")