finally d13p2 ...
This commit is contained in:
parent
6868307aed
commit
8ec77c3b97
20
day13/day.go
20
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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user