diff --git a/py/aoc2024/day5.py b/py/aoc2024/day5.py index d204d58..32387ac 100644 --- a/py/aoc2024/day5.py +++ b/py/aoc2024/day5.py @@ -2,7 +2,7 @@ Day 5: Print Queue """ -from typing import Callable, Iterable, List, Set, Tuple +from typing import Callable, Iterable SAMPLE_INPUT = """ 47|53 @@ -36,7 +36,7 @@ """ -def _parse(data: str) -> Tuple[Set[Tuple[int, int]], List[List[int]]]: +def _parse(data: str) -> tuple[set[tuple[int, int]], list[list[int]]]: (deps, updates) = data.split("\n\n") deps = { tuple(int(page) for page in line.split("|")) @@ -76,7 +76,7 @@ def part2(data: str) -> int: ) -def _partial_sorted[T](iterable: Iterable[T], ok: Callable[[T, T], bool]) -> List[T]: +def _partial_sorted[T](iterable: Iterable[T], ok: Callable[[T, T], bool]) -> list[T]: output = list(iterable) i = 0 while i < len(output): diff --git a/py/aoc2024/day6.py b/py/aoc2024/day6.py index 6f17d9b..577869c 100644 --- a/py/aoc2024/day6.py +++ b/py/aoc2024/day6.py @@ -4,7 +4,7 @@ from functools import partial from multiprocessing import Pool -from typing import Generator, Iterable, Set, Tuple +from typing import Generator, Iterable SAMPLE_INPUT = """ ....#..... @@ -20,7 +20,7 @@ """ -def _parse(data: str) -> Tuple[Tuple[int, int], Tuple[int, int], Set[Tuple[int, int]]]: +def _parse(data: str) -> tuple[tuple[int, int], tuple[int, int], set[tuple[int, int]]]: obstructions = [] for y, line in enumerate(filter(None, data.splitlines())): for x, char in enumerate(line): @@ -33,10 +33,10 @@ def _parse(data: str) -> Tuple[Tuple[int, int], Tuple[int, int], Set[Tuple[int, def _visit( - initial_pos: Tuple[int, int], - max_bounds: Tuple[int, int], - obstructions: Iterable[Tuple[int, int]], -) -> Generator[Tuple[int, int], None, Set[Tuple[int, int]]]: + initial_pos: tuple[int, int], + max_bounds: tuple[int, int], + obstructions: Iterable[tuple[int, int]], +) -> Generator[tuple[int, int], None, set[tuple[int, int]]]: y, x = initial_pos dy, dx = -1, 0 max_y, max_x = max_bounds @@ -55,10 +55,10 @@ def _visit( def _part1( - initial_pos: Tuple[int, int], - max_bounds: Tuple[int, int], - obstructions: Iterable[Tuple[int, int]], -) -> Set[Tuple[int, int]]: + initial_pos: tuple[int, int], + max_bounds: tuple[int, int], + obstructions: Iterable[tuple[int, int]], +) -> set[tuple[int, int]]: visitor = _visit(initial_pos, max_bounds, obstructions) while True: try: @@ -77,9 +77,9 @@ def part1(data: str) -> int: def _part2( - initial_pos: Tuple[int, int], - max_bounds: Tuple[int, int], - obstructions: Iterable[Tuple[int, int]], + initial_pos: tuple[int, int], + max_bounds: tuple[int, int], + obstructions: Iterable[tuple[int, int]], ) -> bool: visited = set() for key in _visit(initial_pos, max_bounds, obstructions):