Skip to content

Commit 2eeb7fe

Browse files
committed
feat: 2024 day 25
1 parent bb9eb6b commit 2eeb7fe

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

2024/25.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from aoc import *
2+
from itertools import product
3+
4+
5+
def main(infi: str):
6+
locks = []
7+
keys = []
8+
for o in filerstrip(infi).split('\n\n'):
9+
lines = o.split('\n')
10+
flist = keys if lines[0] == '.....' else locks
11+
template = list(lines[0])
12+
heights = [0] * 5
13+
for height, l in enumerate(lines[1:]):
14+
for i, (a, b) in enumerate(zip(l, template)):
15+
if a != b:
16+
heights[i] = height if flist is locks else 5 - height
17+
template[i] = a
18+
flist.append(heights)
19+
return sum(
20+
1
21+
for k, l in product(keys, locks)
22+
if all(a + b <= 5 for a, b in zip(k, l))
23+
)
24+
25+
26+
DAY = 25
27+
FILE_TEST = f"{DAY}_testa.txt"
28+
# FILE_TEST = f"{DAY}_testb.txt"
29+
FILE_EXP = f"{DAY}_exp.txt"
30+
FILE = f"{DAY}.txt"
31+
# test_and_submit(main, FILE_TEST, FILE_EXP, FILE, DAY)
32+
# print(main(FILE_TEST))
33+
print(main(FILE))

README.org

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Personal Stats 2024
55
| Day | Time | Rank | Score | Time | Rank | Score |
66
|-----+----------+-------+-------+----------+-------+-------|
7+
| 25 | 00:22:37 | 2609 | 0 | 00:38:53 | 2948 | 0 |
78
| 23 | 00:24:26 | 2632 | 0 | 01:09:24 | 2938 | 0 |
89
| 22 | 00:07:06 | 766 | 0 | 05:23:29 | 7143 | 0 |
910
| 21 | >24h | 15115 | 0 | >24h | 11364 | 0 |

0 commit comments

Comments
 (0)