2025 day 1, ugly, lazy.

This commit is contained in:
Mikael CAPELLE
2025-12-03 17:31:03 +01:00
parent 279f6cdde2
commit b3ba0fee99
10 changed files with 4555 additions and 102 deletions

View File

View 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

View 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

View File

@@ -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()

File diff suppressed because it is too large Load Diff

View 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

View File

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

View 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