summaryrefslogtreecommitdiff
path: root/python-func/task10.py
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-04-04 21:39:38 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-04-04 21:39:38 +0400
commite9208ade043f2304225d1e1150f57fa31aa49c28 (patch)
tree3e0707caa964c7c6470b3d1779ce0949d81fdee6 /python-func/task10.py
parentaf807d85ec70130dc1b28d82b454d11731f932ee (diff)
Добавил 8, 10, 11 задачи по питону
Diffstat (limited to 'python-func/task10.py')
-rw-r--r--python-func/task10.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/python-func/task10.py b/python-func/task10.py
new file mode 100644
index 0000000..8c548e1
--- /dev/null
+++ b/python-func/task10.py
@@ -0,0 +1,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} треугольников")
+