From 3aec98af5bc3f1d1cef86586403a2a46a68049ca Mon Sep 17 00:00:00 2001 From: Starnakin Date: Fri, 13 Dec 2024 11:39:41 +0100 Subject: [PATCH] add: 2024/day11/part1 --- 2024/day11/part1.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 2024/day11/part1.py diff --git a/2024/day11/part1.py b/2024/day11/part1.py new file mode 100644 index 0000000..54ec248 --- /dev/null +++ b/2024/day11/part1.py @@ -0,0 +1,28 @@ +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)) \ No newline at end of file