Day 8
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user