summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--1.py1
-rw-r--r--2.py3
-rw-r--r--3.py1
-rw-r--r--4.py4
4 files changed, 7 insertions, 2 deletions
diff --git a/1.py b/1.py
index 024c501..1c52458 100644
--- a/1.py
+++ b/1.py
@@ -1,3 +1,4 @@
+# pyright: strict
import re
from itertools import chain
from sys import stdin
diff --git a/2.py b/2.py
index e21b3a4..d9c4433 100644
--- a/2.py
+++ b/2.py
@@ -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})
diff --git a/3.py b/3.py
index 8f5a8d3..eed75a3 100644
--- a/3.py
+++ b/3.py
@@ -1,3 +1,4 @@
+# pyright: strict
import re
from collections import defaultdict
from collections.abc import Iterator
diff --git a/4.py b/4.py
index dfd7468..04f645f 100644
--- a/4.py
+++ b/4.py
@@ -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(" | ")