AOC/2024/day11/part1.py
2024-12-13 11:39:41 +01:00

28 lines
623 B
Python

import math
text: str
with open("input.txt") as f:
text = f.read()
def blink(stones: list[int]):
new_stones: list[int] = []
for stone in stones:
tmp: str = str(stone)
length: int = len(tmp)
if (stone == 0):
new_stones.append(1)
elif (length % 2 == 0):
new_stones.append(int(tmp[0:length // 2]))
new_stones.append(int(tmp[length // 2:]))
else:
new_stones.append(stone * 2024)
return new_stones
stones = list(map(int, text.split(" ")))
for i in range(25):
stones = blink(stones)
print(i)
print(len(stones))