diff options
-rw-r--r-- | 1.py | 1 | ||||
-rw-r--r-- | 2.py | 3 | ||||
-rw-r--r-- | 3.py | 1 | ||||
-rw-r--r-- | 4.py | 4 |
4 files changed, 7 insertions, 2 deletions
@@ -1,3 +1,4 @@ +# pyright: strict import re from itertools import chain from sys import stdin @@ -1,3 +1,4 @@ +# pyright: strict from dataclasses import dataclass from functools import reduce from operator import mul @@ -16,7 +17,7 @@ class Game: def parse(inp: str) -> Game: game, subsets_str = inp.rstrip().split(": ") _, game = game.split(" ") - subsets = list() + subsets: list[dict[str, int]] = list() for s in subsets_str.split("; "): cubes = [c.split(" ") for c in s.split(", ")] subsets.append({c[1]: int(c[0]) for c in cubes}) @@ -1,3 +1,4 @@ +# pyright: strict import re from collections import defaultdict from collections.abc import Iterator @@ -1,6 +1,8 @@ +# pyright: strict from dataclasses import dataclass from functools import cache from sys import stdin +from typing import Type @dataclass(frozen=True) @@ -14,7 +16,7 @@ class Card: return len(self.winning & self.have) @classmethod - def from_str(cls, s: str): + def from_str[T](cls: Type[T], s: str) -> T: card, rest = s.split(": ") _, card_id = card.split() winning, have = rest.split(" | ") |