| 49 | return abs(self.x - other.x) + abs(self.y - other.y) |
| 50 | |
| 51 | def forward(self, direction: Direction, distance: int = 1) -> Self: |
| 52 | match direction: |
| 53 | case "N": |
| 54 | return Point(self.x, self.y - distance) # ty: ignore[invalid-return-type] |
| 55 | case "S": |
| 56 | return Point(self.x, self.y + distance) # ty: ignore[invalid-return-type] |
| 57 | case "E": |
| 58 | return Point(self.x + distance, self.y) # ty: ignore[invalid-return-type] |
| 59 | case "W": |
| 60 | return Point(self.x - distance, self.y) # ty: ignore[invalid-return-type] |
| 61 | |
| 62 | @dataclass |
| 63 | class Rect: |