Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated imports #81

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading