diff options
author | mhsn <mail@mhsn.net> | 2025-09-12 20:20:58 +0100 |
---|---|---|
committer | mhsn <mail@mhsn.net> | 2025-09-12 20:36:09 +0100 |
commit | 6b733982f9f240c1c97f1fa705bfbe4cd93c640e (patch) | |
tree | dad623203c8bb40f372e0ea14479c2f564efda79 /2024/14/python | |
parent | 9299c4ef655b88eb8b571864c939c78b27f77723 (diff) | |
download | aoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.tar.gz aoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.zip |
simplify python file structure
Diffstat (limited to '2024/14/python')
-rw-r--r-- | 2024/14/python/main.py | 62 | ||||
-rw-r--r-- | 2024/14/python/pyproject.toml | 6 |
2 files changed, 0 insertions, 68 deletions
diff --git a/2024/14/python/main.py b/2024/14/python/main.py deleted file mode 100644 index ebfe29c..0000000 --- a/2024/14/python/main.py +++ /dev/null @@ -1,62 +0,0 @@ -import re -from fileinput import input -from itertools import groupby -from math import prod - -XMAX, YMAX = 11, 7 # for test -XMAX, YMAX = 101, 103 # for aoc - -robots = [ - re.fullmatch(r"p=(\d+),(\d+) v=(-?\d+),(-?\d+)", line.strip()).groups() - for line in input() -] -robots = [ - (complex(int(px), int(py)), complex(int(vx), int(vy))) for px, py, vx, vy in robots -] - - -def move(p, v, s): - e = p + v * s - return complex(e.real % XMAX, e.imag % YMAX) - - -def quad(x): - return (x.real < XMAX // 2, x.imag < YMAX // 2) - - -def is_quad(x): - return x.real != XMAX // 2 and x.imag != YMAX // 2 - - -def draw(s): - print(f"Seconds passed: {s}") - moved = {move(p, v, s) for p, v in robots} - for x in range(XMAX): - for y in range(YMAX): - print( - "#" if complex(x, y) in moved else " ", - end="", - ) - print() - print("-" * XMAX) - - -moved = groupby( - sorted( - filter(is_quad, (move(p, v, 100) for p, v in robots)), - key=quad, - ), - quad, -) - - -silver = prod(sum(1 for _ in k) for _, k in moved) -gold = 0 - -print("silver:", silver) -print("gold:", gold) - -s = 0 -while s < 10_000: - draw(s) - s += 1 diff --git a/2024/14/python/pyproject.toml b/2024/14/python/pyproject.toml deleted file mode 100644 index 45527a8..0000000 --- a/2024/14/python/pyproject.toml +++ /dev/null @@ -1,6 +0,0 @@ -[project] -name = "aoc-2024-14" -version = "0.1.0" -description = "advent of code 2024-14" -requires-python = ">=3.13" -dependencies = [] |