diff --git a/day13/day.go b/day13/day.go index f65a6b6..be1c94d 100644 --- a/day13/day.go +++ b/day13/day.go @@ -1,7 +1,6 @@ package day13 import ( - "fmt" "strconv" "strings" "tools" @@ -49,6 +48,7 @@ func buildMaze(maxX, maxY int) tools.GridToggle { return maze } +/* func printMaze(maze tools.GridToggle, path []tools.Coordinate) { pathMap := make(map[tools.Coordinate]int) for i, c := range path { @@ -69,16 +69,30 @@ func printMaze(maze tools.GridToggle, path []tools.Coordinate) { fmt.Println() } } +*/ func Part1(puzzle tools.AoCPuzzle) interface{} { favNumber, targetX, targetY = parseInput(puzzle.GetInputArray()) maze := buildMaze(targetX+mazeHangover, targetY+mazeHangover) path := maze.GetPathAStar(tools.Coordinate{X: 1, Y: 1}, tools.Coordinate{X: targetX, Y: targetY}, false) - printMaze(maze, path) return len(path) - 1 } func Part2(puzzle tools.AoCPuzzle) interface{} { - return 0 + favNumber, targetX, targetY = parseInput(puzzle.GetInputArray()) + maze := buildMaze(52, 52) + targets := 0 + for x := 0; x < 50; x++ { + for y := 0; y < 50; y++ { + if maze.State(x, y) { + continue + } + checkPath := maze.GetPathAStar(tools.Coordinate{X: 1, Y: 1}, tools.Coordinate{X: x, Y: y}, false) + if checkPath != nil && len(checkPath) <= 51 { + targets++ + } + } + } + return targets }