Initial setup (part 2)

This commit is contained in:
Pascal P. 2025-12-01 16:03:16 +01:00
commit bc388c31ff
4 changed files with 4138 additions and 0 deletions

4099
inputs/day01.txt Normal file

File diff suppressed because it is too large Load Diff

35
src/day1.py Normal file
View File

@ -0,0 +1,35 @@
from utils.load import get_input
def solve_part1():
count = 0
current = 50
data = get_input(1).splitlines()
#data = [ "L68", "L30", "R48", "L5", "R60", "L55", "L1", "L99", "R14", "L82" ]
for value in data:
previous_value = current
if value[0] == 'L':
current = (current - int(value[1:]) )
else:
current = (current + int(value[1:]) )
nb_rotation_zero = 0
if current > 0:
nb_rotation_zero = current // 100
current %= 100
elif current < 0:
nb_rotation_zero = 1 + abs(current) // 100
current = current + 100 * nb_rotation_zero
else:
nb_rotation_zero = 1
if previous_value == 0:
nb_rotation_zero = max(nb_rotation_zero - 1, 0)
count += nb_rotation_zero
print(f"{value} -> {current} (+{nb_rotation_zero}) (count: {count})")
print(count)
if __name__ == "__main__":
solve_part1()

Binary file not shown.

4
src/utils/load.py Normal file
View File

@ -0,0 +1,4 @@
from pathlib import Path
def get_input(day_number: int) -> str:
return Path(__file__).parents[2].joinpath("inputs", f"day{day_number:02}.txt").read_text(encoding="utf-8")