chore: fix dijkstra
Some checks failed
Go Test / build (pull_request) Failing after 2m39s

This commit is contained in:
xuu
2023-12-28 18:57:22 -07:00
parent 1a3374a557
commit 1fac5f7b4d
13 changed files with 314 additions and 269 deletions

View File

@@ -32,15 +32,15 @@ func run(scan *bufio.Scanner) (*result, error) {
options := make([]int, 2*(rows+cols)+2)
i := 0
for j:=0; j<=rows-1; j++ {
for j := 0; j <= rows-1; j++ {
options[i+0] = runCycle(m, ray{[2]int{j, -1}, RT})
options[i+1] = runCycle(m, ray{[2]int{j, cols}, LF})
i+=2
i += 2
}
for j:=0; j<=cols-1; j++ {
for j := 0; j <= cols-1; j++ {
options[i+0] = runCycle(m, ray{[2]int{-1, j}, DN})
options[i+1] = runCycle(m, ray{[2]int{rows, j}, UP})
i+=2
i += 2
}
// fmt.Println(options)
@@ -96,7 +96,6 @@ func (m *Map) Get(p [2]int) rune {
return (*m)[p[0]][p[1]]
}
func runCycle(m Map, r ray) int {
current := r
@@ -186,4 +185,4 @@ func runCycle(m Map, r ray) int {
// }
return len(energized)
}
}

View File

@@ -47,4 +47,4 @@ func TestStack(t *testing.T) {
s := stack[int]{}
s.Push(5)
is.Equal(s.Pop(), 5)
}
}