advent_of_code/2025/1/1_2.py
2025-12-02 02:35:16 +01:00

33 lines
813 B
Python

#!/usr/bin/env python
# 2025 - Advent Of Code 1 - part 2
# file = 'input_example.txt'
file = 'input.txt'
dial = 50
count = 0
with open(file, encoding="utf-8") as f:
for line in f.readlines():
direction = line[0]
distance = int(line[1:])
if direction == 'L':
if dial == 0:
was_zero = 0
else:
was_zero = 1
dial -= distance
if dial <= 0:
count += abs(int(dial / 100)) + was_zero
print(f'Left {distance=} {dial=} {count=}')
elif direction == 'R':
dial += distance
if dial > 99:
count += int(dial / 100)
print(f'Right {distance=} {dial=} {count=}')
dial = dial % 100
# print(f'{dial=}')
print(count)