day 11 part 1

main
magical 2024-12-11 05:12:00 +00:00
parent ad6279089f
commit 0e13af40c5
3 changed files with 42 additions and 0 deletions

1
day11/input 100644
View File

@ -0,0 +1 @@
6563348 67 395 0 6 4425 89567 739318

20
day11/sample1.in 100644
View File

@ -0,0 +1,20 @@
Initial arrangement:
125 17
After 1 blink:
253000 1 7
After 2 blinks:
253 0 2024 14168
After 3 blinks:
512072 1 20 24 28676032
After 4 blinks:
512 72 2024 2 0 2 4 2867 6032
After 5 blinks:
1036288 7 2 20 24 4048 1 4048 8096 28 67 60 32
After 6 blinks:
2097446912 14168 4048 2 0 2 4 40 48 2024 40 48 80 96 2 8 6 7 6 0 3 2

21
day11/sol.py 100644
View File

@ -0,0 +1,21 @@
def solve(file):
nums = file.read().split()
for i in range(25):
if len(nums) < 100:
print(i, nums)
new = []
for n in nums:
if n == '0':
new.append('1')
elif len(n)%2 == 0:
new.append(n[:len(n)//2])
new.append(n[len(n)//2:].lstrip('0') or '0')
else:
new.append(str(int(n)*2024))
nums = new
print(len(nums))
from io import StringIO
solve(StringIO("0 1 10 99 999"))
solve(open("input"))