This commit is contained in:
Joshua Seigler 2024-12-13 10:29:23 -05:00
parent 6490326b05
commit 5e26df54c8
No known key found for this signature in database

View file

@ -104,13 +104,24 @@ const part2 = (rawInput: string) => {
const nextDirection = (thisDirection + 1) % 4 const nextDirection = (thisDirection + 1) % 4
const presentNextDirection = orthogonalProbes[nextDirection] const presentNextDirection = orthogonalProbes[nextDirection]
if ( if (
presentThisDirection && // example: plot is X, direction is right
presentNextDirection && // ###
!diagonalProbes[thisDirection] // #XA
// #B.
presentThisDirection && // A
presentNextDirection && // B
!diagonalProbes[thisDirection] // .
) { ) {
corners += 1 corners += 1
} }
if (!presentThisDirection && !presentNextDirection) { if (
// example: plot is X, direction is right
// ##.
// #X!
// .!.
!presentThisDirection && // !
!presentNextDirection // !
) {
corners += 1 corners += 1
} }
}) })