day 6 p 1 complete
This commit is contained in:
parent
a4d4dc2b23
commit
e51186bf8d
1 changed files with 7 additions and 5 deletions
|
@ -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<Solvable> {
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue