2023 Day 17 Complete
This commit is contained in:
@@ -9,13 +9,13 @@ import (
|
||||
|
||||
"github.com/fatih/color"
|
||||
|
||||
"../../"
|
||||
h "git.bullercodeworks.com/brian/adventofcode/helpers"
|
||||
)
|
||||
|
||||
var tWidth, tHeight int
|
||||
|
||||
func main() {
|
||||
fileNm := aoc.GetArgNumber(1)
|
||||
fileNm := h.GetArgNumber(1)
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("Usage: ./day24 <mazefile>")
|
||||
os.Exit(1)
|
||||
@@ -32,14 +32,14 @@ func main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
poiPerms := aoc.StringPermutations(poiString)
|
||||
poiPerms := h.StringPermutations(poiString)
|
||||
shortest := -1
|
||||
var shortestPerm string
|
||||
for _, perm := range poiPerms {
|
||||
if perm[0] != '0' {
|
||||
continue
|
||||
}
|
||||
if aoc.ArgIsSet("-2") {
|
||||
if h.ArgIsSet("-2") {
|
||||
// For part 2 we return to 0
|
||||
perm = perm + "0"
|
||||
}
|
||||
@@ -79,8 +79,8 @@ type Floor struct {
|
||||
|
||||
func CreateFloorFromFile(fileNm string) *Floor {
|
||||
f := new(Floor)
|
||||
f.debug = aoc.ArgIsSet("-d")
|
||||
f.cells = aoc.FileToStringSlice(fileNm)
|
||||
f.debug = h.ArgIsSet("-d")
|
||||
f.cells = h.FileToStringSlice(fileNm)
|
||||
for y := range f.cells {
|
||||
for x := range f.cells[y] {
|
||||
if f.cells[y][x] != '#' {
|
||||
@@ -101,7 +101,7 @@ func CreateFloorFromFile(fileNm string) *Floor {
|
||||
|
||||
// Find the shortest paths between all points of interest
|
||||
f.shortestPaths = make(map[string]int)
|
||||
if aoc.ArgIsSet("-2") {
|
||||
if h.ArgIsSet("-2") {
|
||||
|
||||
/* Output from running part 1
|
||||
1;2 232
|
||||
@@ -301,7 +301,7 @@ func (f *Floor) Solve(x, y, dist int) (Path, bool) {
|
||||
if !tPathContains {
|
||||
f.testedPath.Append(wrkCoord)
|
||||
if f.debug {
|
||||
fmt.Println(aoc.ClearScreen, f.start.Name(), "=>", f.end.Name(), "\n", len(f.testedPath.coords), "/", f.cellCount, "\n", "Shortest:", shortestFound)
|
||||
fmt.Println(h.ClearScreen, f.start.Name(), "=>", f.end.Name(), "\n", len(f.testedPath.coords), "/", f.cellCount, "\n", "Shortest:", shortestFound)
|
||||
f.PrintPath(f.testedPath)
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
}
|
||||
|
Reference in New Issue
Block a user