2023 Day 17 Complete

This commit is contained in:
2023-12-17 10:52:08 -06:00
parent a34f05d1af
commit d64a18280f
16 changed files with 517 additions and 131 deletions

View File

@@ -7,7 +7,7 @@ import (
termbox "github.com/nsf/termbox-go"
"../../"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
var gridWidth, gridHeight int
@@ -18,8 +18,8 @@ func main() {
passcode := "pvhmgsws"
gridWidth, gridHeight = 4, 4
if len(os.Args) >= 3 {
gridWidth = aoc.Atoi(os.Args[1])
gridHeight = aoc.Atoi(os.Args[2])
gridWidth = h.Atoi(os.Args[1])
gridHeight = h.Atoi(os.Args[2])
}
run := true
err := termbox.Init()
@@ -83,80 +83,80 @@ func PrintState(path, passcode string) {
posX, posY := currPos(path)
for y := 0; y < gridHeight; y++ {
for x := 0; x < gridWidth; x++ {
fmt.Print(aoc.BorderNW)
fmt.Print(h.BorderNW)
if posX == x && posY == y && doorIsOpen(path, passcode, 'N') {
// Current Pos w/ open door
fmt.Print(aoc.BorderSE)
fmt.Print(aoc.BorderSW)
fmt.Print(h.BorderSE)
fmt.Print(h.BorderSW)
} else if y == posY+1 && x == posX && doorIsOpen(path, passcode, 'S') {
// Room below, w/ open door
fmt.Print(aoc.BorderNE)
fmt.Print(aoc.BorderNW)
fmt.Print(h.BorderNE)
fmt.Print(h.BorderNW)
} else {
// All other cases
fmt.Print(aoc.BorderWE)
fmt.Print(aoc.BorderWE)
fmt.Print(h.BorderWE)
fmt.Print(h.BorderWE)
}
fmt.Print(aoc.BorderNE)
fmt.Print(h.BorderNE)
}
fmt.Println()
for x := 0; x < gridWidth; x++ {
if posX == x && posY == y && doorIsOpen(path, passcode, 'W') {
fmt.Print(aoc.BorderSE)
fmt.Print(h.BorderSE)
} else {
fmt.Print(aoc.BorderNS)
fmt.Print(h.BorderNS)
}
if posX == x && posY == y {
fmt.Print(aoc.BorderNW)
fmt.Print(aoc.BorderNE)
fmt.Print(h.BorderNW)
fmt.Print(h.BorderNE)
} else {
fmt.Print(" ")
fmt.Print(" ")
}
if posX == x && posY == y && doorIsOpen(path, passcode, 'E') {
fmt.Print(aoc.BorderSW)
fmt.Print(h.BorderSW)
} else {
fmt.Print(aoc.BorderNS)
fmt.Print(h.BorderNS)
}
}
fmt.Println()
for x := 0; x < gridWidth; x++ {
if posX == x && posY == y && doorIsOpen(path, passcode, 'W') {
fmt.Print(aoc.BorderNE)
fmt.Print(h.BorderNE)
} else {
fmt.Print(aoc.BorderNS)
fmt.Print(h.BorderNS)
}
if posX == x && posY == y {
fmt.Print(aoc.BorderSW)
fmt.Print(aoc.BorderSE)
fmt.Print(h.BorderSW)
fmt.Print(h.BorderSE)
} else {
fmt.Print(" ")
fmt.Print(" ")
}
if posX == x && posY == y && doorIsOpen(path, passcode, 'E') {
fmt.Print(aoc.BorderNW)
fmt.Print(h.BorderNW)
} else {
fmt.Print(aoc.BorderNS)
fmt.Print(h.BorderNS)
}
}
fmt.Println()
for x := 0; x < gridWidth; x++ {
fmt.Print(aoc.BorderSW)
fmt.Print(h.BorderSW)
if posX == x && posY == y && doorIsOpen(path, passcode, 'S') {
fmt.Print(aoc.BorderNE)
fmt.Print(aoc.BorderNW)
fmt.Print(h.BorderNE)
fmt.Print(h.BorderNW)
} else {
fmt.Print(aoc.BorderWE)
fmt.Print(aoc.BorderWE)
fmt.Print(h.BorderWE)
fmt.Print(h.BorderWE)
}
fmt.Print(aoc.BorderSE)
fmt.Print(h.BorderSE)
}
fmt.Println()
}
}
func ClearScreen() {
fmt.Print(aoc.ClearScreen)
fmt.Print(h.ClearScreen)
}
func printUsageAndExit() {