We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1e24f66 commit 2e175deCopy full SHA for 2e175de
2024/day11/solutions.py
@@ -0,0 +1,19 @@
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
+ mid, rem = divmod(len(s := str(n)), 2)
10
+ if n == 0:
11
+ new_stones[1] += num_stone
12
+ elif rem == 0:
13
+ for m in s[:mid], s[mid:]:
14
+ new_stones[int(m)] += num_stone
15
+ else:
16
+ new_stones[2024 * n] += num_stone
17
+ stones = new_stones
18
+ if blinks in (25, 75):
19
+ print(sum(new_stones.values()))
0 commit comments