33 lines
813 B
Python
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)
|