From: Skullheadx <704277@pdsb.net> Date: Wed, 4 Jan 2023 02:43:59 +0000 (-0500) Subject: create S4 2022 X-Git-Url: http://git.skullheadx.com/projects/tech/openbsd_html_css/post.html?a=commitdiff_plain;h=51e04c05ad335ef146538bb4fcddb7905faeab3e;p=CCC.git create S4 2022 --- diff --git a/.gitignore b/.gitignore index fd027b5..bc2a419 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ *.iml *.o *.exe +.idea/CCC.iml +.idea/misc.xml diff --git a/.idea/CCC.iml b/.idea/CCC.iml index 4954722..7efdecd 100644 --- a/.idea/CCC.iml +++ b/.idea/CCC.iml @@ -5,7 +5,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 2d0cc4f..a4652f3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/Main/Python/2022/S4.py b/Main/Python/2022/S4.py new file mode 100644 index 0000000..f401226 --- /dev/null +++ b/Main/Python/2022/S4.py @@ -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)