day8 - use the tools, luke

This commit is contained in:
Stefan Harmuth 2024-12-08 11:51:21 +01:00
parent ad7d5e47f7
commit 4e749b6fdd

View File

@ -1,5 +1,6 @@
from itertools import combinations from itertools import combinations
from tools.aoc import AOCDay from tools.aoc import AOCDay
from tools.tools import minmax
from typing import Any from typing import Any
from tools.grid import Grid from tools.grid import Grid
@ -15,7 +16,7 @@ def get_antinode_count(grid: Grid, repeat: bool = False) -> int:
antinodes |= antennas antinodes |= antennas
for pair in combinations(antennas, 2): for pair in combinations(antennas, 2):
a, b = (pair[0], pair[1]) if pair[0] < pair[1] else (pair[1], pair[0]) a, b = minmax(*pair)
diff = b - a diff = b - a
while grid.isWithinBoundaries(a - diff): while grid.isWithinBoundaries(a - diff):