Skip to content

Commit 38976f6

Browse files
committed
Add solution to 2024-12-11
1 parent 1e24f66 commit 38976f6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

2024/day11/solutions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from collections import Counter
2+
3+
with open("input") as f:
4+
stones = Counter(map(int, f.read().split()))
5+
6+
for blinks in range(1, 76):
7+
new_stones = Counter()
8+
for n, num_stone in stones.items():
9+
if n == 0:
10+
new_stones[1] += num_stone
11+
elif len(s := str(n)) % 2 == 0:
12+
for m in s[: len(s) // 2], s[len(s) // 2 :]:
13+
new_stones[int(m)] += num_stone
14+
else:
15+
new_stones[2024 * n] += num_stone
16+
stones = new_stones
17+
if blinks in (25, 75):
18+
print(sum(new_stones.values()))

0 commit comments

Comments
 (0)