diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000..b9fb3f3 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +profile=black diff --git a/2019/d03/ex2/ex2.py b/2019/d03/ex2/ex2.py index 077f2e3..a0abfac 100755 --- a/2019/d03/ex2/ex2.py +++ b/2019/d03/ex2/ex2.py @@ -2,7 +2,7 @@ import sys from fractions import Fraction -from typing import List, NamedTuple, Optional +from typing import Dict, List, NamedTuple, Optional class Point(NamedTuple): diff --git a/2019/d04/ex1/ex1.py b/2019/d04/ex1/ex1.py index 49bb589..460b7d8 100755 --- a/2019/d04/ex1/ex1.py +++ b/2019/d04/ex1/ex1.py @@ -7,7 +7,7 @@ def is_valid_password(p: int) -> bool: digits = str(p) def has_adjacent_digit(): - for a, b in zip(digits, digits[1:]): + for (a, b) in zip(digits, digits[1:]): if a == b: return True return False diff --git a/2019/d04/ex2/ex2.py b/2019/d04/ex2/ex2.py index a54ccfe..883abf9 100755 --- a/2019/d04/ex2/ex2.py +++ b/2019/d04/ex2/ex2.py @@ -8,7 +8,7 @@ def is_valid_password(p: int) -> bool: def has_unique_adjacent_digit(): counts = {d: 0 for d in range(10)} - for a, b in zip(digits, digits[1:]): + for (a, b) in zip(digits, digits[1:]): if a == b: counts[int(a)] += 1 return any(count == 1 for count in counts.values()) diff --git a/2019/d05/ex1/ex1.py b/2019/d05/ex1/ex1.py index fe46167..09dac02 100755 --- a/2019/d05/ex1/ex1.py +++ b/2019/d05/ex1/ex1.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +import sys +from copy import deepcopy from enum import IntEnum from typing import List, NamedTuple diff --git a/2019/d07/ex2/ex2.py b/2019/d07/ex2/ex2.py index 8f5e209..c239eaa 100755 --- a/2019/d07/ex2/ex2.py +++ b/2019/d07/ex2/ex2.py @@ -5,7 +5,7 @@ import sys from copy import deepcopy from dataclasses import dataclass, field from enum import IntEnum -from typing import List, NamedTuple +from typing import Callable, List, NamedTuple class ParameterMode(IntEnum): diff --git a/2019/d09/ex1/ex1.py b/2019/d09/ex1/ex1.py index 9a2df1e..6f54dec 100755 --- a/2019/d09/ex1/ex1.py +++ b/2019/d09/ex1/ex1.py @@ -1,10 +1,11 @@ #!/usr/bin/env python +import itertools import sys from copy import deepcopy from dataclasses import dataclass, field from enum import IntEnum -from typing import List, NamedTuple +from typing import Callable, List, NamedTuple class ParameterMode(IntEnum): diff --git a/2019/d09/ex2/ex2.py b/2019/d09/ex2/ex2.py index 7c8be67..598f628 100755 --- a/2019/d09/ex2/ex2.py +++ b/2019/d09/ex2/ex2.py @@ -1,10 +1,11 @@ #!/usr/bin/env python +import itertools import sys from copy import deepcopy from dataclasses import dataclass, field from enum import IntEnum -from typing import List, NamedTuple +from typing import Callable, List, NamedTuple class ParameterMode(IntEnum): diff --git a/2019/d10/ex2/ex2.py b/2019/d10/ex2/ex2.py index 480234e..60f115a 100755 --- a/2019/d10/ex2/ex2.py +++ b/2019/d10/ex2/ex2.py @@ -4,6 +4,7 @@ import sys from cmath import phase from itertools import groupby from math import gcd, pi +from pprint import pprint from typing import NamedTuple, Set, Tuple diff --git a/2019/d13/ex1/ex1.py b/2019/d13/ex1/ex1.py index 924ffb7..1bf7e8c 100755 --- a/2019/d13/ex1/ex1.py +++ b/2019/d13/ex1/ex1.py @@ -3,7 +3,7 @@ import sys from dataclasses import dataclass, field from enum import IntEnum -from typing import Iterable, List, NamedTuple, Tuple, TypeVar +from typing import Dict, Iterable, List, NamedTuple, Tuple, TypeVar class ParameterMode(IntEnum): diff --git a/2019/d13/ex2/ex2.py b/2019/d13/ex2/ex2.py index af0d24f..9fb669f 100755 --- a/2019/d13/ex2/ex2.py +++ b/2019/d13/ex2/ex2.py @@ -3,7 +3,7 @@ import sys from dataclasses import dataclass, field from enum import IntEnum -from typing import Iterable, List, NamedTuple, Tuple, TypeVar +from typing import Dict, Iterable, List, NamedTuple, Tuple, TypeVar class ParameterMode(IntEnum): diff --git a/2019/d16/ex2/ex2.py b/2019/d16/ex2/ex2.py index 317d157..a13a0bf 100755 --- a/2019/d16/ex2/ex2.py +++ b/2019/d16/ex2/ex2.py @@ -2,6 +2,8 @@ import sys from functools import reduce +from itertools import chain, cycle +from typing import Iterable, List def main() -> None: diff --git a/2019/d19/ex2/ex2.py b/2019/d19/ex2/ex2.py index 8dd132c..138e45b 100755 --- a/2019/d19/ex2/ex2.py +++ b/2019/d19/ex2/ex2.py @@ -4,7 +4,7 @@ import sys from copy import deepcopy from dataclasses import dataclass, field from enum import IntEnum -from typing import List, NamedTuple +from typing import Iterator, List, NamedTuple, Tuple class ParameterMode(IntEnum): diff --git a/2020/d07/ex2/ex2.py b/2020/d07/ex2/ex2.py index a955087..107d737 100755 --- a/2020/d07/ex2/ex2.py +++ b/2020/d07/ex2/ex2.py @@ -2,6 +2,8 @@ import re import sys +from collections import defaultdict +from copy import deepcopy from dataclasses import dataclass from typing import Dict, List, Set, Tuple diff --git a/2020/d17/ex1/ex1.py b/2020/d17/ex1/ex1.py index 03bf46b..dd9efee 100755 --- a/2020/d17/ex1/ex1.py +++ b/2020/d17/ex1/ex1.py @@ -41,6 +41,7 @@ def update(grid: Grid) -> Grid: def solve(grid: Grid) -> int: + for __ in range(6): grid = update(grid) diff --git a/2020/d17/ex2/ex2.py b/2020/d17/ex2/ex2.py index ba979a1..8589288 100755 --- a/2020/d17/ex2/ex2.py +++ b/2020/d17/ex2/ex2.py @@ -41,6 +41,7 @@ def update(grid: Grid) -> Grid: def solve(grid: Grid) -> int: + for __ in range(6): grid = update(grid) diff --git a/2020/d18/ex2/ex2.py b/2020/d18/ex2/ex2.py index a83161c..94f13ed 100755 --- a/2020/d18/ex2/ex2.py +++ b/2020/d18/ex2/ex2.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import sys -from typing import List +from typing import Callable, Dict, List """ E : T [ * T ]* diff --git a/2020/d20/ex2/ex2.py b/2020/d20/ex2/ex2.py index c9e06a7..e923806 100755 --- a/2020/d20/ex2/ex2.py +++ b/2020/d20/ex2/ex2.py @@ -5,6 +5,7 @@ import itertools import math import sys from collections import defaultdict +from copy import deepcopy from typing import Dict, Iterator, List, Set, Tuple Tile = List[List[str]] diff --git a/2020/d23/ex1/ex1.py b/2020/d23/ex1/ex1.py index 2d7ff20..faae133 100755 --- a/2020/d23/ex1/ex1.py +++ b/2020/d23/ex1/ex1.py @@ -2,7 +2,7 @@ import itertools import sys -from typing import List +from typing import List, Tuple def solve(circle: List[int]) -> int: diff --git a/2020/d23/ex2/ex2.py b/2020/d23/ex2/ex2.py index 8993dcb..90c8c81 100755 --- a/2020/d23/ex2/ex2.py +++ b/2020/d23/ex2/ex2.py @@ -2,7 +2,7 @@ import itertools import sys -from typing import List +from typing import List, Tuple def solve(circle: List[int]) -> int: diff --git a/2020/d24/ex2/ex2.py b/2020/d24/ex2/ex2.py index ef749f9..17728b2 100755 --- a/2020/d24/ex2/ex2.py +++ b/2020/d24/ex2/ex2.py @@ -3,6 +3,7 @@ import itertools import sys from collections import defaultdict +from copy import deepcopy from typing import Dict, Iterator, List, Tuple Offset = Tuple[int, int] diff --git a/2021/d01/ex1/ex1.py b/2021/d01/ex1/ex1.py index 3853ce4..24cc5d1 100755 --- a/2021/d01/ex1/ex1.py +++ b/2021/d01/ex1/ex1.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import List diff --git a/2021/d02/ex1/ex1.py b/2021/d02/ex1/ex1.py index f891b43..f28dd77 100755 --- a/2021/d02/ex1/ex1.py +++ b/2021/d02/ex1/ex1.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import List diff --git a/2021/d02/ex2/ex2.py b/2021/d02/ex2/ex2.py index 8843639..b48215c 100755 --- a/2021/d02/ex2/ex2.py +++ b/2021/d02/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import List diff --git a/2021/d03/ex1/ex1.py b/2021/d03/ex1/ex1.py index 7519004..ed2eeb7 100755 --- a/2021/d03/ex1/ex1.py +++ b/2021/d03/ex1/ex1.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import List diff --git a/2021/d03/ex2/ex2.py b/2021/d03/ex2/ex2.py index acf0ff2..9c6515b 100755 --- a/2021/d03/ex2/ex2.py +++ b/2021/d03/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from copy import deepcopy from typing import List diff --git a/2021/d06/ex1/ex1.py b/2021/d06/ex1/ex1.py index 65abb44..5eec9ce 100755 --- a/2021/d06/ex1/ex1.py +++ b/2021/d06/ex1/ex1.py @@ -3,6 +3,7 @@ import itertools import sys from collections import Counter +from dataclasses import dataclass from typing import Iterator, List, TypeVar T = TypeVar("T") diff --git a/2021/d06/ex2/ex2.py b/2021/d06/ex2/ex2.py index bb40805..2e64423 100755 --- a/2021/d06/ex2/ex2.py +++ b/2021/d06/ex2/ex2.py @@ -3,6 +3,7 @@ import itertools import sys from collections import Counter +from dataclasses import dataclass from typing import Iterator, List, TypeVar T = TypeVar("T") diff --git a/2021/d07/ex1/ex1.py b/2021/d07/ex1/ex1.py index 2b8a8a9..4205009 100755 --- a/2021/d07/ex1/ex1.py +++ b/2021/d07/ex1/ex1.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import List diff --git a/2021/d07/ex2/ex2.py b/2021/d07/ex2/ex2.py index 8eec5ef..56b818c 100755 --- a/2021/d07/ex2/ex2.py +++ b/2021/d07/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from math import ceil, floor from typing import List diff --git a/2021/d08/ex2/ex2.py b/2021/d08/ex2/ex2.py index c22b23b..1553e29 100755 --- a/2021/d08/ex2/ex2.py +++ b/2021/d08/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from dataclasses import dataclass from typing import Dict, List, Set diff --git a/2021/d09/ex1/ex1.py b/2021/d09/ex1/ex1.py index e84e893..cf7d7d6 100755 --- a/2021/d09/ex1/ex1.py +++ b/2021/d09/ex1/ex1.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import Iterator, List, Tuple diff --git a/2021/d09/ex2/ex2.py b/2021/d09/ex2/ex2.py index 0311995..451883a 100755 --- a/2021/d09/ex2/ex2.py +++ b/2021/d09/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import Iterator, List, Tuple diff --git a/2021/d10/ex1/ex1.py b/2021/d10/ex1/ex1.py index 6770222..4667d43 100755 --- a/2021/d10/ex1/ex1.py +++ b/2021/d10/ex1/ex1.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import List, Optional, cast diff --git a/2021/d10/ex2/ex2.py b/2021/d10/ex2/ex2.py index d100b0f..27de8ac 100755 --- a/2021/d10/ex2/ex2.py +++ b/2021/d10/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from typing import Iterator, List, Optional diff --git a/2021/d11/ex1/ex1.py b/2021/d11/ex1/ex1.py index c6bf0be..19669b3 100755 --- a/2021/d11/ex1/ex1.py +++ b/2021/d11/ex1/ex1.py @@ -2,6 +2,7 @@ import itertools import sys +from copy import deepcopy from typing import Iterator, List, Set, Tuple Grid = List[List[int]] @@ -38,7 +39,7 @@ def solve(input: List[str]) -> int: # Second step, do flashes has_flashed: Set[Point] = set() while len(flashes := (excited(levels) - has_flashed)) > 0: - for i, j in flashes: + for (i, j) in flashes: has_flashed.add((i, j)) for x, y in neighbours_of((i, j)): levels[x][y] += 1 diff --git a/2021/d11/ex2/ex2.py b/2021/d11/ex2/ex2.py index 8f95f55..0dee9eb 100755 --- a/2021/d11/ex2/ex2.py +++ b/2021/d11/ex2/ex2.py @@ -2,6 +2,7 @@ import itertools import sys +from copy import deepcopy from typing import Iterator, List, Set, Tuple Grid = List[List[int]] @@ -38,7 +39,7 @@ def solve(input: List[str]) -> int: # Second step, do flashes has_flashed: Set[Point] = set() while len(flashes := (excited(levels) - has_flashed)) > 0: - for i, j in flashes: + for (i, j) in flashes: has_flashed.add((i, j)) for x, y in neighbours_of((i, j)): levels[x][y] += 1 diff --git a/2021/d12/ex1/ex1.py b/2021/d12/ex1/ex1.py index 6108876..4d0cacf 100755 --- a/2021/d12/ex1/ex1.py +++ b/2021/d12/ex1/ex1.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from collections import defaultdict from typing import Dict, List, Set @@ -11,7 +12,7 @@ def solve(input: List[str]) -> int: def parse() -> Map: res: Map = defaultdict(set) - for start, to in map(lambda s: s.split("-"), input): + for (start, to) in map(lambda s: s.split("-"), input): res[start].add(to) res[to].add(start) diff --git a/2021/d12/ex2/ex2.py b/2021/d12/ex2/ex2.py index b30d9b8..69d9aa9 100755 --- a/2021/d12/ex2/ex2.py +++ b/2021/d12/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import itertools import sys from collections import defaultdict from typing import Dict, List, Set @@ -11,7 +12,7 @@ def solve(input: List[str]) -> int: def parse() -> Map: res: Map = defaultdict(set) - for start, to in map(lambda s: s.split("-"), input): + for (start, to) in map(lambda s: s.split("-"), input): res[start].add(to) res[to].add(start) diff --git a/2021/d15/ex1/ex1.py b/2021/d15/ex1/ex1.py index 4399aba..d7c5e88 100755 --- a/2021/d15/ex1/ex1.py +++ b/2021/d15/ex1/ex1.py @@ -1,8 +1,9 @@ #!/usr/bin/env python import heapq +import itertools import sys -from typing import Iterator, List, NamedTuple, Set +from typing import Iterator, List, NamedTuple, Set, Tuple class Point(NamedTuple): diff --git a/2021/d15/ex2/ex2.py b/2021/d15/ex2/ex2.py index c2bbd30..0fa89b8 100755 --- a/2021/d15/ex2/ex2.py +++ b/2021/d15/ex2/ex2.py @@ -1,8 +1,9 @@ #!/usr/bin/env python import heapq +import itertools import sys -from typing import Iterator, List, NamedTuple, Set +from typing import Iterator, List, NamedTuple, Set, Tuple class Point(NamedTuple): diff --git a/2021/d16/ex1/ex1.py b/2021/d16/ex1/ex1.py index 1978196..d65fec5 100755 --- a/2021/d16/ex1/ex1.py +++ b/2021/d16/ex1/ex1.py @@ -5,7 +5,7 @@ import functools import itertools import sys from dataclasses import dataclass -from typing import Iterable, Iterator, List, Tuple +from typing import Iterable, Iterator, List, Tuple, TypeVar RawPacket = List[bool] diff --git a/2021/d16/ex2/ex2.py b/2021/d16/ex2/ex2.py index bb9ad4e..7ecb73a 100755 --- a/2021/d16/ex2/ex2.py +++ b/2021/d16/ex2/ex2.py @@ -6,7 +6,7 @@ import itertools import math import sys from dataclasses import dataclass -from typing import Callable, Dict, Iterable, Iterator, List, Tuple +from typing import Callable, Dict, Iterable, Iterator, List, Tuple, TypeVar RawPacket = List[bool] diff --git a/2021/d17/ex1/ex1.py b/2021/d17/ex1/ex1.py index 00bbca2..d58a72e 100755 --- a/2021/d17/ex1/ex1.py +++ b/2021/d17/ex1/ex1.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import itertools +import math import sys from typing import Iterator, List, NamedTuple diff --git a/2021/d17/ex2/ex2.py b/2021/d17/ex2/ex2.py index bc7dab1..e2beb9a 100755 --- a/2021/d17/ex2/ex2.py +++ b/2021/d17/ex2/ex2.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +import itertools +import math import sys from typing import Iterator, List, NamedTuple diff --git a/2021/d18/ex2/ex2.py b/2021/d18/ex2/ex2.py index c0a37a7..56c8d48 100755 --- a/2021/d18/ex2/ex2.py +++ b/2021/d18/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import functools import itertools import sys from copy import deepcopy diff --git a/2021/d19/ex1/ex1.py b/2021/d19/ex1/ex1.py index e42af3c..922e709 100755 --- a/2021/d19/ex1/ex1.py +++ b/2021/d19/ex1/ex1.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import functools import itertools import sys from dataclasses import dataclass diff --git a/2021/d19/ex2/ex2.py b/2021/d19/ex2/ex2.py index ff4f6ad..1ad850a 100755 --- a/2021/d19/ex2/ex2.py +++ b/2021/d19/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import functools import itertools import sys from dataclasses import dataclass diff --git a/2021/d22/ex1/ex1.py b/2021/d22/ex1/ex1.py index dac1513..662dd49 100755 --- a/2021/d22/ex1/ex1.py +++ b/2021/d22/ex1/ex1.py @@ -3,7 +3,7 @@ import functools import itertools import sys -from typing import List, NamedTuple, Optional, Set, Tuple +from typing import Iterator, List, NamedTuple, Optional, Set, Tuple, cast class Point(NamedTuple): diff --git a/2021/d22/ex2/ex2.py b/2021/d22/ex2/ex2.py index 3c7d2c5..4753b54 100755 --- a/2021/d22/ex2/ex2.py +++ b/2021/d22/ex2/ex2.py @@ -3,7 +3,7 @@ import functools import itertools import sys -from typing import List, NamedTuple, Optional, Set, Tuple +from typing import Iterator, List, NamedTuple, Optional, Set, Tuple, cast class Point(NamedTuple): diff --git a/2021/d23/ex1/ex1.py b/2021/d23/ex1/ex1.py index 0b99d71..4d585cd 100755 --- a/2021/d23/ex1/ex1.py +++ b/2021/d23/ex1/ex1.py @@ -3,7 +3,7 @@ import enum import functools import sys -from typing import Iterator, List, NamedTuple, Optional, Tuple +from typing import Iterator, List, NamedTuple, Optional, Tuple, cast class Point(NamedTuple): diff --git a/2021/d23/ex2/ex2.py b/2021/d23/ex2/ex2.py index 8c077d9..1ea1d8f 100755 --- a/2021/d23/ex2/ex2.py +++ b/2021/d23/ex2/ex2.py @@ -3,7 +3,7 @@ import enum import functools import sys -from typing import Iterator, List, NamedTuple, Optional, Tuple +from typing import Iterator, List, NamedTuple, Optional, Tuple, cast class Point(NamedTuple): diff --git a/2021/d25/ex1/ex1.py b/2021/d25/ex1/ex1.py index 5d6f612..76fbe54 100755 --- a/2021/d25/ex1/ex1.py +++ b/2021/d25/ex1/ex1.py @@ -1,8 +1,9 @@ #!/usr/bin/env python +import enum import itertools import sys -from typing import List, NamedTuple, Set +from typing import Iterable, Iterator, List, NamedTuple, Set class Point(NamedTuple): @@ -60,13 +61,11 @@ def solve(input: List[str]) -> int: for x in range(map.dimensions.x): print( "".join( - ( - "v" - if Point(x, y) in map.south - else ">" - if Point(x, y) in map.east - else "." - ) + "v" + if Point(x, y) in map.south + else ">" + if Point(x, y) in map.east + else "." for y in range(map.dimensions.y) ) ) diff --git a/2022/d07/ex1/ex1.py b/2022/d07/ex1/ex1.py index fcd28d4..43e49f1 100755 --- a/2022/d07/ex1/ex1.py +++ b/2022/d07/ex1/ex1.py @@ -8,6 +8,7 @@ FileSystem = dict[str, Union[int, "FileSystem"]] def solve(input: list[str]) -> int: def build_tree(input: list[str], i: int = 0) -> tuple[FileSystem, int]: + fs: FileSystem = {} while i < len(input): diff --git a/2022/d07/ex2/ex2.py b/2022/d07/ex2/ex2.py index 6a6d447..9886cf0 100755 --- a/2022/d07/ex2/ex2.py +++ b/2022/d07/ex2/ex2.py @@ -8,6 +8,7 @@ FileSystem = dict[str, Union[int, "FileSystem"]] def solve(input: list[str]) -> int: def build_tree(input: list[str], i: int = 0) -> tuple[FileSystem, int]: + fs: FileSystem = {} while i < len(input): diff --git a/2022/d12/ex1/ex1.py b/2022/d12/ex1/ex1.py index 3e78cfc..9e1c372 100755 --- a/2022/d12/ex1/ex1.py +++ b/2022/d12/ex1/ex1.py @@ -20,7 +20,7 @@ class HeightMap: def reachable_neighbours(self, p: Point) -> Iterator[Point]: reachable_height = self.heights[p.x][p.y] + 1 - for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)): + for (dx, dy) in ((-1, 0), (1, 0), (0, -1), (0, 1)): x, y = p.x + dx, p.y + dy if x < 0 or x >= len(self.heights): continue diff --git a/2022/d12/ex2/ex2.py b/2022/d12/ex2/ex2.py index 0a713b3..657f807 100755 --- a/2022/d12/ex2/ex2.py +++ b/2022/d12/ex2/ex2.py @@ -20,7 +20,7 @@ class HeightMap: def reachable_neighbours(self, p: Point) -> Iterator[Point]: reachable_height = self.heights[p.x][p.y] + 1 - for dx, dy in ((-1, 0), (1, 0), (0, -1), (0, 1)): + for (dx, dy) in ((-1, 0), (1, 0), (0, -1), (0, 1)): x, y = p.x + dx, p.y + dy if x < 0 or x >= len(self.heights): continue diff --git a/2022/d18/ex2/ex2.py b/2022/d18/ex2/ex2.py index 57f8b5a..6f7bfcb 100755 --- a/2022/d18/ex2/ex2.py +++ b/2022/d18/ex2/ex2.py @@ -2,6 +2,7 @@ import itertools import sys +from collections import deque from collections.abc import Iterator from typing import NamedTuple diff --git a/2022/d21/ex1/ex1.py b/2022/d21/ex1/ex1.py index e9c4727..7c12836 100755 --- a/2022/d21/ex1/ex1.py +++ b/2022/d21/ex1/ex1.py @@ -25,7 +25,7 @@ class Operator(str, enum.Enum): class Monkey: def get_value(self, monkeys: dict[str, "Monkey"]) -> int: - raise NotImplementedError + raise NotImplemented @dataclasses.dataclass diff --git a/2022/d21/ex2/ex2.py b/2022/d21/ex2/ex2.py index 386a187..ec9ca8d 100755 --- a/2022/d21/ex2/ex2.py +++ b/2022/d21/ex2/ex2.py @@ -93,7 +93,7 @@ class MathObserver: class Monkey: def get_value(self, monkeys: dict[str, "Monkey"]) -> Num: - raise NotImplementedError + raise NotImplemented @dataclasses.dataclass diff --git a/2023/d02/ex2/ex2.py b/2023/d02/ex2/ex2.py index 32c3a34..309753e 100755 --- a/2023/d02/ex2/ex2.py +++ b/2023/d02/ex2/ex2.py @@ -1,6 +1,8 @@ #!/usr/bin/env python +import functools import math +import operator as op import sys from collections import Counter from enum import StrEnum diff --git a/2023/d14/ex2/ex2.py b/2023/d14/ex2/ex2.py index b7b0222..090724f 100755 --- a/2023/d14/ex2/ex2.py +++ b/2023/d14/ex2/ex2.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import dataclasses import itertools import sys from enum import StrEnum diff --git a/2023/d17/ex2/ex2.py b/2023/d17/ex2/ex2.py index f4cfc6e..a643534 100755 --- a/2023/d17/ex2/ex2.py +++ b/2023/d17/ex2/ex2.py @@ -2,6 +2,7 @@ import functools import heapq +import itertools import sys from collections.abc import Iterator from enum import Enum diff --git a/flake.lock b/flake.lock index d2cf81b..ffbe623 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", "type": "github" }, "original": { @@ -21,11 +21,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -43,11 +43,11 @@ ] }, "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", "owner": "hercules-ci", "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", "type": "github" }, "original": { @@ -58,11 +58,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1731890469, - "narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=", + "lastModified": 1701336116, + "narHash": "sha256-kEmpezCR/FpITc6yMbAh4WrOCiT2zg5pSjnKrq51h5Y=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5083ec887760adfe12af64830a66807423a859a7", + "rev": "f5c27c6136db4d76c30e533c20517df6864c46ee", "type": "github" }, "original": { @@ -75,6 +75,9 @@ "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat", + "flake-utils": [ + "futils" + ], "gitignore": "gitignore", "nixpkgs": [ "nixpkgs" @@ -84,11 +87,11 @@ ] }, "locked": { - "lastModified": 1732021966, - "narHash": "sha256-mnTbjpdqF0luOkou8ZFi2asa1N3AA2CchR/RqCNmsGE=", + "lastModified": 1700922917, + "narHash": "sha256-ej2fch/T584b5K9sk1UhmZF7W6wEfDHuoUYpFN8dtvM=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "3308484d1a443fc5bc92012435d79e80458fe43c", + "rev": "e5ee5c5f3844550c01d2131096c7271cec5e9b78", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 066f6db..6334931 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,7 @@ repo = "pre-commit-hooks.nix"; ref = "master"; inputs = { + flake-utils.follows = "futils"; nixpkgs.follows = "nixpkgs"; nixpkgs-stable.follows = "nixpkgs"; }; @@ -39,11 +40,15 @@ src = self; hooks = { - nixpkgs-fmt = { + black = { enable = true; }; - ruff-format = { + isort = { + enable = true; + }; + + nixpkgs-fmt = { enable = true; }; }; @@ -53,11 +58,12 @@ devShell = pkgs.mkShell { buildInputs = with pkgs; [ (python3.withPackages (ps: with ps; [ + black + isort mypy z3 ])) pyright - ruff ]; inherit (self.checks.${system}.pre-commit) shellHook;