add: 2024/day11/part1
This commit is contained in:
parent
dd7eae1ba6
commit
3aec98af5b
28
2024/day11/part1.py
Normal file
28
2024/day11/part1.py
Normal file
@ -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))
|
Loading…
Reference in New Issue
Block a user