aoc24/day11/solution.py

26 lines
717 B
Python
Raw Normal View History

2024-12-11 07:22:39 +01:00
import sys
from tqdm import tqdm
def main(input):
input_list: list = input.split(" ")
for i in tqdm(range(25)):
new_stones = []
for num in input_list:
if num == '0':
new_stones.extend(["1"])
elif len(num) % 2 == 0:
half = len(num) // 2
left_half = str(int(num[:half]))
right_half = str(int(num[half:]))
new_stones.extend([left_half, right_half])
else:
new_stones.extend([str(int(num)*2024)])
input_list = new_stones
print(len(input_list))
if __name__ == "__main__":
input_text = sys.stdin.read().strip()
main(input_text)