diff --git a/2024/day08.py b/2024/day08.py index a5b6b34..bc74630 100644 --- a/2024/day08.py +++ b/2024/day08.py @@ -30,15 +30,15 @@ def isinGrid(pos,maxPos): return 0 <= pos[0] < maxPos[0] and 0 <= pos[1] < maxPos[1] def calcAntiNodes(posAntA, posAntB,maxPos): - AX = posAntA[0] - BX = posAntB[0] - AY = posAntA[1] - BY = posAntB[1] - CX = AX + (AX-BX) - CY = AY + (AY-BY) + X1 = posAntA[0] + X2 = posAntB[0] + Y1 = posAntA[1] + Y2 = posAntB[1] + X3 = X1 + (X1-X2) + Y3 = Y1 + (Y1-Y2) - if isinGrid ((CX,CY),maxPos): - return (CX,CY) + if isinGrid ((X3,Y3),maxPos): + return (X3,Y3) return (-1,-1) def findAntiNodesA(maxPos,posAntennes):