This commit is contained in:
2024-12-08 11:47:51 +00:00
parent 6c210fd0be
commit a1480b8dce
2 changed files with 76 additions and 4 deletions

View File

@@ -35,14 +35,14 @@ for (let i = 0; i <= input.length; i++) {
}
x++;
}
const width = x + 1;
const width = x;
const height = y + 1;
const guardStart = guard.pos;
const positions: Array<Coord> = [guard.pos];
function coodsMatch(a: Coord, b: Coord) {
function coordsMatch(a: Coord, b: Coord) {
return a.x === b.x && a.y === b.y;
}
@@ -72,7 +72,7 @@ function rotateGuard() {
}
function isObs(coord: Coord, otherObs: Array<Coord>|null = null) {
return (otherObs || obs).some((obsCoord) => coodsMatch(obsCoord, coord));
return (otherObs || obs).some((obsCoord) => coordsMatch(obsCoord, coord));
}
function offMap(coord: Coord) {
@@ -83,7 +83,7 @@ function offMap(coord: Coord) {
}
function alreadyVisited(coord: Coord) {
return positions.some((pos) => coodsMatch(pos, coord));
return positions.some((pos) => coordsMatch(pos, coord));
}
while (true) {