2025 day 1, ugly, lazy.
This commit is contained in:
0
src/holt59/aoc/2025/__init__.py
Normal file
0
src/holt59/aoc/2025/__init__.py
Normal file
42
src/holt59/aoc/2025/day1.py
Normal file
42
src/holt59/aoc/2025/day1.py
Normal file
@@ -0,0 +1,42 @@
|
||||
from collections import Counter
|
||||
from typing import Any, Iterator, Literal, cast
|
||||
|
||||
from ..base import BaseSolver
|
||||
|
||||
|
||||
class Solver(BaseSolver):
|
||||
def solve(self, input: str) -> Iterator[Any]:
|
||||
data = [
|
||||
(cast(Literal["R", "L"], row[0]), int(row[1:]))
|
||||
for row in input.splitlines()
|
||||
]
|
||||
|
||||
count, dial = 0, 50
|
||||
for sense, value in data:
|
||||
dial = (dial + (-1 if sense == "L" else 1) * value) % 100
|
||||
if dial == 0:
|
||||
count += 1
|
||||
|
||||
yield count
|
||||
|
||||
count, dial = 0, 50
|
||||
for sense, value in data:
|
||||
if dial == 0 and sense == "L":
|
||||
dial = dial - value + 100
|
||||
else:
|
||||
dial = dial + (-1 if sense == "L" else 1) * value
|
||||
|
||||
while dial < 0:
|
||||
count, dial = count + 1, dial + 100
|
||||
|
||||
if dial == 0:
|
||||
count += 1
|
||||
|
||||
while dial >= 100:
|
||||
count, dial = count + 1, dial - 100
|
||||
|
||||
self.logger.info(
|
||||
f"after {sense}{value:<3d} dial is at {dial:>2d}, count is {count}"
|
||||
)
|
||||
|
||||
yield count
|
||||
9
src/holt59/aoc/2025/day2.py
Normal file
9
src/holt59/aoc/2025/day2.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from typing import Any, Iterator
|
||||
|
||||
from ..base import BaseSolver
|
||||
|
||||
|
||||
class Solver(BaseSolver):
|
||||
def solve(self, input: str) -> Iterator[Any]:
|
||||
yield 0
|
||||
yield 0
|
||||
@@ -1,7 +1,6 @@
|
||||
import argparse
|
||||
import importlib
|
||||
import logging
|
||||
import logging.handlers
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -59,7 +58,7 @@ def main():
|
||||
default=None,
|
||||
help="input to use (override user and test)",
|
||||
)
|
||||
parser.add_argument("-y", "--year", type=int, help="year to run", default=2024)
|
||||
parser.add_argument("-y", "--year", type=int, help="year to run", default=2025)
|
||||
parser.add_argument("day", type=int, help="day to run")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
4387
src/holt59/aoc/inputs/holt59/2025/day1.txt
Normal file
4387
src/holt59/aoc/inputs/holt59/2025/day1.txt
Normal file
File diff suppressed because it is too large
Load Diff
1
src/holt59/aoc/inputs/holt59/2025/day2.txt
Normal file
1
src/holt59/aoc/inputs/holt59/2025/day2.txt
Normal file
@@ -0,0 +1 @@
|
||||
92916254-92945956,5454498003-5454580069,28-45,4615-7998,4747396917-4747534264,272993-389376,36290651-36423050,177-310,3246326-3418616,48-93,894714-949755,952007-1003147,3-16,632-1029,420-581,585519115-585673174,1041-1698,27443-39304,71589003-71823870,97-142,2790995-2837912,579556301-579617006,653443-674678,1515120817-1515176202,13504-20701,1896-3566,8359-13220,51924-98061,505196-638209,67070129-67263432,694648-751703,8892865662-8892912125
|
||||
10
src/holt59/aoc/inputs/tests/2025/day1.txt
Normal file
10
src/holt59/aoc/inputs/tests/2025/day1.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
L68
|
||||
L30
|
||||
R48
|
||||
L5
|
||||
R60
|
||||
L55
|
||||
L1
|
||||
L99
|
||||
R14
|
||||
L82
|
||||
3
src/holt59/aoc/inputs/tests/2025/day2.txt
Normal file
3
src/holt59/aoc/inputs/tests/2025/day2.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
11-22,95-115,998-1012,1188511880-1188511890,222220-222224,
|
||||
1698522-1698528,446443-446449,38593856-38593862,565653-565659,
|
||||
824824821-824824827,2121212118-2121212124
|
||||
Reference in New Issue
Block a user