summaryrefslogtreecommitdiff
path: root/2024/14/python.py
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2026-03-18 21:48:13 +0000
committermhsn <mail@mhsn.net>2026-03-18 21:48:13 +0000
commit86bac31392a76da84817eec020d2b84d099b3cc1 (patch)
treee2ee52db59b86b914d5b4bcceb19c9b5d899fff4 /2024/14/python.py
parent62fe361fc42dea75deaf7ac31c0ba6ba80e26a9c (diff)
downloadpuzzles-master.tar.gz
puzzles-master.zip
add other challenges supportHEADmaster
Diffstat (limited to '2024/14/python.py')
-rwxr-xr-x2024/14/python.py64
1 files changed, 0 insertions, 64 deletions
diff --git a/2024/14/python.py b/2024/14/python.py
deleted file mode 100755
index 2bb6cb4..0000000
--- a/2024/14/python.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python3
-
-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