]> Skullheadx's Git Forge - CCC.git/commitdiff
Update S4.py
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Wed, 4 Jan 2023 03:14:20 +0000 (22:14 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Wed, 4 Jan 2023 03:14:20 +0000 (22:14 -0500)
Main/Python/2022/S4.py

index f4012266bbc5ff432e5a384ee39e22a9daa264c5..6169efa0e5c99bca7d4f50afb073df79c13cbc4e 100644 (file)
@@ -25,13 +25,12 @@ def to_coordinates(p):
 
 
 temp = {i + 1: int(val) for i, val in enumerate(input().split())}
-P = {i:to_coordinates(temp[i]) for i in temp.keys()}
+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]
@@ -40,26 +39,25 @@ for subset in permutations(P.keys(), 3):
     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):
+    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:
+def is_opposite(a, b):
+    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
+
+def is_good(i):
+    for a, b in permutations(i, 2):
+        if is_opposite(a, b):
+            return False
+    return True
 
 
-print(len(output), output)
+new_output = []
+for i in output:
+    if is_good(i):
+        new_output.append(i)
+print(len(new_output))