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 38976f6Copy full SHA for 38976f6
2024/day11/solutions.py
@@ -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