summaryrefslogtreecommitdiff
path: root/2024/08/python/main.py
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-09-12 20:20:58 +0100
committermhsn <mail@mhsn.net>2025-09-12 20:36:09 +0100
commit6b733982f9f240c1c97f1fa705bfbe4cd93c640e (patch)
treedad623203c8bb40f372e0ea14479c2f564efda79 /2024/08/python/main.py
parent9299c4ef655b88eb8b571864c939c78b27f77723 (diff)
downloadaoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.tar.gz
aoc-6b733982f9f240c1c97f1fa705bfbe4cd93c640e.zip
simplify python file structure
Diffstat (limited to '2024/08/python/main.py')
-rw-r--r--2024/08/python/main.py49
1 files changed, 0 insertions, 49 deletions
diff --git a/2024/08/python/main.py b/2024/08/python/main.py
deleted file mode 100644
index c7bb47d..0000000
--- a/2024/08/python/main.py
+++ /dev/null
@@ -1,49 +0,0 @@
-from collections import defaultdict
-from fileinput import input
-from itertools import product
-
-antennas = defaultdict(set)
-x_max, y_max = 0, 0
-
-for idy, line in enumerate(input()):
- y_max = max(y_max, idy)
- for idx, c in enumerate(line.strip()):
- x_max = max(x_max, idx)
- if c == ".":
- continue
-
- antennas[c].add(complex(idx, idy))
-
-nodes = set()
-for vs in antennas.values():
- for v1, v2 in product(vs, vs):
- if v1 == v2:
- continue
- vec = v2 - v1
- nodes.add(v1 + 2 * vec)
- nodes.add(v2 - 2 * vec)
-
-nodes = {n for n in nodes if 0 <= n.real <= x_max and 0 <= n.imag <= y_max}
-
-gold_nodes = set()
-for vs in antennas.values():
- for v1, v2 in product(vs, vs):
- if v1 == v2:
- continue
- vec = v2 - v1
- start = v1
- while 0 <= start.real <= x_max and 0 <= start.imag <= y_max:
- gold_nodes.add(start)
- start += vec
-
- start = v2
- while 0 <= start.real <= x_max and 0 <= start.imag <= y_max:
- gold_nodes.add(start)
- start -= vec
-
-
-silver = len(nodes)
-gold = len(gold_nodes)
-
-print("silver:", silver)
-print("gold:", gold)