generated from public/aoc_template
day01
This commit is contained in:
parent
9b11bec788
commit
82ad1d0dbe
57
day01.py
Normal file
57
day01.py
Normal 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
4059
inputs/input1
Normal file
File diff suppressed because it is too large
Load Diff
10
inputs/input1_test
Normal file
10
inputs/input1_test
Normal file
@ -0,0 +1,10 @@
|
||||
L68
|
||||
L30
|
||||
R48
|
||||
L5
|
||||
R60
|
||||
L55
|
||||
L1
|
||||
L99
|
||||
R14
|
||||
L82
|
||||
@ -11,7 +11,7 @@ import webbrowser
|
||||
|
||||
YEAR = 2025
|
||||
CHARMS = {
|
||||
'Linux': '/usr/local/bin/charm',
|
||||
'Linux': '/home/pennywise/bin/pycharm',
|
||||
'Windows': r'C:\Users\pennywise\AppData\Local\JetBrains\Toolbox\scripts\pycharm.cmd'
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user