From 6b733982f9f240c1c97f1fa705bfbe4cd93c640e Mon Sep 17 00:00:00 2001 From: mhsn Date: Fri, 12 Sep 2025 20:20:58 +0100 Subject: simplify python file structure --- 2024/13/python/main.py | 38 -------------------------------------- 2024/13/python/pyproject.toml | 6 ------ 2 files changed, 44 deletions(-) delete mode 100644 2024/13/python/main.py delete mode 100644 2024/13/python/pyproject.toml (limited to '2024/13/python') diff --git a/2024/13/python/main.py b/2024/13/python/main.py deleted file mode 100644 index de31184..0000000 --- a/2024/13/python/main.py +++ /dev/null @@ -1,38 +0,0 @@ -import re -from fileinput import input -from itertools import batched - -lines = [line.strip() for line in input()] - - -re_button = r"Button [A|B]: X\+(\d+), Y\+(\d+)" -re_prize = r"Prize: X=(\d+), Y=(\d+)" - - -def solve(machine, gold): - m = re.fullmatch( - r"Button A: X\+(\d+), Y\+(\d+)Button B: X\+(\d+), Y\+(\d+)Prize: X=(\d+), Y=(\d+)", - "".join(machine), - ) - # 2x2 matrix solve - ax, ay, bx, by, px, py = map(int, m.groups()) - if gold: - px += 10000000000000 - py += 10000000000000 - det = ax * by - ay * bx - - A = (by * px - bx * py) / det - B = (-ay * px + ax * py) / det - - # Check solutions are ints - if abs(int(A) - A) < 1e-7 and abs(int(B) - B) < 1e-7: - return 3 * int(A) + int(B) - else: - return 0 - - -silver = sum(solve(b, False) for b in batched(lines, 4)) -gold = sum(solve(b, True) for b in batched(lines, 4)) - -print("silver:", silver) -print("gold:", gold) diff --git a/2024/13/python/pyproject.toml b/2024/13/python/pyproject.toml deleted file mode 100644 index aae82b9..0000000 --- a/2024/13/python/pyproject.toml +++ /dev/null @@ -1,6 +0,0 @@ -[project] -name = "aoc-2024-13" -version = "0.1.0" -description = "advent of code 2024-13" -requires-python = ">=3.13" -dependencies = [] -- cgit v1.2.3