day05: Coordinate() learned a new trick :)
This commit is contained in:
parent
da4b6567a3
commit
bf0b19a1b9
6
day05.py
6
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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user