From 8e49f8b3d507d4fefecf504f3e08ce6a2c2021b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Engl=C3=B6f=20Ytterstr=C3=B6m?= Date: Sun, 23 Nov 2025 15:11:23 +0100 Subject: [PATCH] Solve 2022 day 2 pt 1-2 --- 2022-python/output/day_02.py | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 2022-python/output/day_02.py diff --git a/2022-python/output/day_02.py b/2022-python/output/day_02.py new file mode 100644 index 0000000..b58799e --- /dev/null +++ b/2022-python/output/day_02.py @@ -0,0 +1,40 @@ +def solve(data): + S1 = { + "A X": 1 + 3, + "A Y": 2 + 6, + "A Z": 3 + 0, + "B X": 1 + 0, + "B Y": 2 + 3, + "B Z": 3 + 6, + "C X": 1 + 6, + "C Y": 2 + 0, + "C Z": 3 + 3, + } + S2 = { + "A X": 3 + 0, + "A Y": 1 + 3, + "A Z": 2 + 6, + "B X": 1 + 0, + "B Y": 2 + 3, + "B Z": 3 + 6, + "C X": 2 + 0, + "C Y": 3 + 3, + "C Z": 1 + 6, + } + R = data.splitlines() + p1 = sum(S1[r] for r in R) + p2 = sum(S2[r] for r in R) + return p1, p2 + + +if __name__ == "__main__": + with open("./input/02.txt", "r") as f: + inp = f.read().strip() + + p1, p2 = solve(inp) + + print(p1) + print(p2) + + assert p1 == 12772 + assert p2 == 11618