Skip to content

Commit

Permalink
Remove deprecated imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ephemient committed Dec 10, 2024
1 parent f5d9c16 commit 7a761a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions py/aoc2024/day5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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("|"))
Expand Down Expand Up @@ -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):
Expand Down
26 changes: 13 additions & 13 deletions py/aoc2024/day6.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
....#.....
Expand All @@ -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):
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 7a761a9

Please sign in to comment.