diff --git a/solutions/06.ts b/solutions/06.ts index 9945567..234a0db 100644 --- a/solutions/06.ts +++ b/solutions/06.ts @@ -43,10 +43,10 @@ class DaySix implements Solvable { // returns true if out of bounds walk = (x: number, y: number, direction: Direction): [boolean, number, number, Direction] => { const nextStepInBounds = { - up: y >= 1, - down: y < this.map.length, - left: x >= 1, - right: x < this.map[0].length, + up: y > 0, + down: y < this.map.length - 1, + left: x > 0, + right: x < this.map[0].length - 1, } // if oob, return true @@ -82,9 +82,10 @@ class DaySix implements Solvable { public async part1(): Promise { // find starting position this.input.forEach((line, y) => line.forEach((char, x) => { if (char === '^') this.startingPosition = [y, x] })) - let [x, y] = [this.startingPosition[0], this.startingPosition[1]] + let [y, x] = [this.startingPosition[0], this.startingPosition[1]] let direction: Direction = 'up' let outOfBounds = false + this.visitedLoc.set(y + ',' + x, null) // starting position is a location // let i = 0 while (!outOfBounds) { @@ -109,6 +110,7 @@ class DaySix implements Solvable { console.log(result) + return new Promise(() => this) }