diff --git a/day11/input b/day11/input new file mode 100644 index 0000000..6162121 --- /dev/null +++ b/day11/input @@ -0,0 +1 @@ +6563348 67 395 0 6 4425 89567 739318 diff --git a/day11/sample1.in b/day11/sample1.in new file mode 100644 index 0000000..1606a87 --- /dev/null +++ b/day11/sample1.in @@ -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 diff --git a/day11/sol.py b/day11/sol.py new file mode 100644 index 0000000..f189ff9 --- /dev/null +++ b/day11/sol.py @@ -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"))