Last active
December 19, 2023 01:04
Revisions
-
LukeberryPi revised this gist
Dec 19, 2023 . No changes.There are no files selected for viewing
-
LukeberryPi created this gist
Dec 18, 2023 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ function areAdjacent(coord1, coord2) { const [x1, y1] = coord1; const [x2, y2] = coord2; const isHorizontallyAdjacent = Math.abs(x1 - x2) === 1 && y1 === y2; const isVerticallyAdjacent = x1 === x2 && Math.abs(y1 - y2) === 1; const isDiagonallyAdjacent = Math.abs(x1 - x2) === 1 && Math.abs(y1 - y2) === 1; return isHorizontallyAdjacent || isVerticallyAdjacent || isDiagonallyAdjacent; }