This commit is contained in:
Stefan Harmuth 2025-12-01 06:39:22 +01:00
parent 9b11bec788
commit 82ad1d0dbe
4 changed files with 4127 additions and 1 deletions

57
day01.py Normal file
View File

@ -0,0 +1,57 @@
from tools.aoc import AOCDay
from typing import Any, Generator
class Day(AOCDay):
inputs = [
[
(3, "input1_test"),
(997, "input1"),
],
[
(6, "input1_test"),
(5978, "input1"),
]
]
def parse_input(self) -> Generator[tuple[Any, int], Any, None]:
for line in self.getInput():
yield line[0], int(line[1:])
def part1(self) -> Any:
dial = 50
ans = 0
for rotation, clicks in self.parse_input():
if rotation == "L":
dial = (dial - clicks) % 100
else:
dial = (dial + clicks) % 100
ans += (dial == 0)
return ans
def part2(self) -> Any:
dial = 50
ans = 0
for rotation, clicks in self.parse_input():
ans += clicks // 100
clicks %= 100
if rotation == "L":
if clicks >= dial and dial != 0:
ans += 1
dial = (dial - clicks) % 100
else:
if clicks >= 100 - dial and dial != 0:
ans += 1
dial = (dial + clicks) % 100
return ans
if __name__ == '__main__':
day = Day(2025, 1)
day.run(verbose=True)

4059
inputs/input1 Normal file

File diff suppressed because it is too large Load Diff

10
inputs/input1_test Normal file
View File

@ -0,0 +1,10 @@
L68
L30
R48
L5
R60
L55
L1
L99
R14
L82

View File

@ -11,7 +11,7 @@ import webbrowser
YEAR = 2025 YEAR = 2025
CHARMS = { CHARMS = {
'Linux': '/usr/local/bin/charm', 'Linux': '/home/pennywise/bin/pycharm',
'Windows': r'C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd' 'Windows': r'C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd'
} }