]> Skullheadx's Git Forge - CCC.git/commitdiff
create S4 2022
authorSkullheadx <704277@pdsb.net>
Wed, 4 Jan 2023 02:43:59 +0000 (21:43 -0500)
committerSkullheadx <704277@pdsb.net>
Wed, 4 Jan 2023 02:43:59 +0000 (21:43 -0500)
.gitignore
.idea/CCC.iml
.idea/misc.xml
Main/Python/2022/S4.py [new file with mode: 0644]

index fd027b56c913e8a41ee35953af843dda54c1037a..bc2a419333d387f8de08c480938005fbb327df72 100644 (file)
@@ -4,3 +4,5 @@
 *.iml
 *.o
 *.exe
+.idea/CCC.iml
+.idea/misc.xml
index 49547220dac4729f530234e019a6bb3ebcc182e3..7efdecd328a17c536c884ecbc5c9748187a461a1 100644 (file)
@@ -5,7 +5,7 @@
       <excludeFolder url="file://$MODULE_DIR$/Main/venv" />
       <excludeFolder url="file://$MODULE_DIR$/venv" />
     </content>
-    <orderEntry type="jdk" jdkName="Python 3.10 (CCC)" jdkType="Python SDK" />
+    <orderEntry type="jdk" jdkName="Python 3.10 (venv)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
 </module>
\ No newline at end of file
index 2d0cc4fea785aa35326a09a32f4d4d1276d3e54f..a4652f355e26c43a58fbff0f10cd661868d00976 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (CCC)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (venv)" project-jdk-type="Python SDK" />
 </project>
\ No newline at end of file
diff --git a/Main/Python/2022/S4.py b/Main/Python/2022/S4.py
new file mode 100644 (file)
index 0000000..f401226
--- /dev/null
@@ -0,0 +1,65 @@
+from math import pi, cos, sin
+from itertools import permutations
+
+
+def in_triangle(ax, ay, bx, by, cx, cy):
+    px, py = r, r
+    try:
+        w1 = (ax * (cy - ay) + (py - ay) * (cx - ax) - px * (cy - ay)) / ((by - ay) * (cx - ax) - (bx - ax) * (cy - ay))
+        w2 = (py - ay - w1 * (by - ay)) / (cy - ay)
+    except:
+        return False
+
+    if w1 > 0 and w2 > 0 and w1 + w2 < 1:
+        return True
+    return False
+
+
+N, C = tuple(map(int, input().split()))
+r = C / (2 * pi)
+
+
+def to_coordinates(p):
+    angle = p / C * 2 * pi
+    return r * cos(angle) + r, r * sin(angle) + r
+
+
+temp = {i + 1: int(val) for i, val in enumerate(input().split())}
+P = {i:to_coordinates(temp[i]) for i in temp.keys()}
+
+seen = set()
+
+output = []
+for subset in permutations(P.keys(), 3):
+    # print(subset)
+    a, b, c = subset
+    ax, ay = P[a]
+    bx, by = P[b]
+    cx, cy = P[c]
+
+    if in_triangle(ax, ay, bx, by, cx, cy):
+        if subset not in seen:
+            output.append(subset)
+    else:
+        if subset in seen:
+            for s in permutations(subset, 3):
+                if s in output:
+                    output.remove(s)
+    for s in permutations(subset,3):
+        seen.add(s)
+
+
+def is_opposite(a,b):
+    print(a,b, C-1)
+    if abs(temp[a] - temp[b]) == C/2:
+        return True
+    return False
+
+for i in output:
+    for a,b in permutations(i, 2):
+        if is_opposite(a,b):
+            output.remove(i)
+            break
+
+
+print(len(output), output)