day09 typos

This commit is contained in:
Ruediger Ludwig 2022-12-09 07:59:25 +01:00
parent c375fb4ad5
commit 4ca3d7d51a

View file

@ -43,7 +43,7 @@ class Point:
return Point(self.x - other.x, self.y - other.y) return Point(self.x - other.x, self.y - other.y)
def is_unit(self) -> bool: def is_unit(self) -> bool:
""" return true, if this discribes any point (diagonally) adjacent to the origin""" """ return true, if this describes any point (diagonally) adjacent to the origin"""
return abs(self.x) <= 1 and abs(self.y) <= 1 return abs(self.x) <= 1 and abs(self.y) <= 1
def as_unit(self) -> Point: def as_unit(self) -> Point:
@ -53,6 +53,7 @@ class Point:
return Point(unit(self.x), unit(self.y)) return Point(unit(self.x), unit(self.y))
def step_to(self, other: Point) -> Point | None: def step_to(self, other: Point) -> Point | None:
""" Returns a point one step towards the other point. Returns None, if already adjacent """
diff = other.sub(self) diff = other.sub(self)
if diff.is_unit(): if diff.is_unit():
return None return None
@ -75,7 +76,7 @@ class Command:
@staticmethod @staticmethod
def walk(lst: list[Command], rope_length: int): def walk(lst: list[Command], rope_length: int):
""" Walks the whole rope in Planck length steps """ """ Walks the whole rope in Planck length steps according to commands """
rope = [Point(0, 0)] * rope_length rope = [Point(0, 0)] * rope_length
visited = {rope[-1]} visited = {rope[-1]}
for command in lst: for command in lst: