lots of cleanup

This commit is contained in:
Ruediger Ludwig 2022-12-10 19:30:10 +01:00
parent 7d0d3e504e
commit 0385cbd62e
26 changed files with 337 additions and 417 deletions

View file

@ -1,7 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import Iterator
from typing import Iterator, Self
day_num = 8
@ -20,10 +20,10 @@ class Forest:
width: int
height: int
@staticmethod
def parse(lines: Iterator[str]) -> Forest:
@classmethod
def parse(cls, lines: Iterator[str]) -> Self:
trees = [[int(tree) for tree in line] for line in lines]
return Forest(trees, len(trees[0]), len(trees))
return cls(trees, len(trees[0]), len(trees))
def count_visible_trees(self) -> int:
visible: set[tuple[int, int]] = set()