From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Wed, 4 Jan 2023 03:14:20 +0000 (-0500) Subject: Update S4.py X-Git-Url: http://git.skullheadx.com/nixos/static/gitweb.js?a=commitdiff_plain;h=22d8aac9c80a2bc05163fdef6bfd1481023b7f12;p=CCC.git Update S4.py --- diff --git a/Main/Python/2022/S4.py b/Main/Python/2022/S4.py index f401226..6169efa 100644 --- a/Main/Python/2022/S4.py +++ b/Main/Python/2022/S4.py @@ -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))