diff --git a/2025/1/1_2.py b/2025/1/1_2.py new file mode 100644 index 0000000..4e675c9 --- /dev/null +++ b/2025/1/1_2.py @@ -0,0 +1,33 @@ +#!/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)