diff --git a/day05.py b/day05.py index e419e0e..9426bd2 100644 --- a/day05.py +++ b/day05.py @@ -1,7 +1,6 @@ from aoc import AOCDay from coordinate import Coordinate from grid import Grid -from tools import compare from typing import Any @@ -13,9 +12,8 @@ def buildLineGrid(lines: list[list[str]], diagonals: bool = False) -> Grid: if not diagonals and start.x != end.x and start.y != end.y: continue - diff = end - start - for x in range(max(abs(diff.x), abs(diff.y)) + 1): - grid.add(Coordinate(start.x + compare(diff.x, 0) * x, start.y + compare(diff.y, 0) * x)) + for c in start.getLineTo(end): + grid.add(c) return grid