chore: fixes
All checks were successful
Go Bump / bump (push) Successful in 7s
Go Test / build (push) Successful in 35s

This commit is contained in:
xuu 2024-01-22 16:07:16 -07:00
parent 951c2c298a
commit f8fa61672f
Signed by: xuu
GPG Key ID: 8B3B0604F164E04F
4 changed files with 21 additions and 9 deletions

View File

@ -2,7 +2,9 @@ package aoc
import (
"cmp"
"fmt"
"sort"
"strings"
"golang.org/x/exp/maps"
)
@ -109,8 +111,8 @@ func (m *cmap[C, N]) String() string {
for k, nbs := range m.neighbors {
fmt.Fprintln(b, k)
for to, v := range nbs {
fmt.Fprintln(b, " ", to, k)
for to, c := range nbs {
fmt.Fprintln(b, " ", to, c)
}
}
@ -136,7 +138,7 @@ func CompressMap[C number, N comparable](p pather[C, N], start N) pather[C, N] {
to[b] = to[n] + p.Cost(n, b)
delete(to, n)
visited[a] = to
} else if to, ok := visited[b]; ok {
} else if to, ok := visited[b]; ok {
to[a] = to[n] + p.Cost(n, a)
delete(to, n)
visited[b] = to

View File

@ -1,8 +1,6 @@
package aoc_test
import (
"fmt"
"sort"
"testing"
"github.com/matryer/is"
@ -27,7 +25,6 @@ func TestRepeat(t *testing.T) {
is.Equal(aoc.Repeat(5, 3), []int{5, 5, 5})
}
func TestTranspose(t *testing.T) {
is := is.New(t)
@ -44,4 +41,4 @@ func TestTranspose(t *testing.T) {
{1, 0, 1},
},
)
}
}

View File

@ -1,5 +1,11 @@
package aoc_test
import (
"testing"
"github.com/matryer/is"
aoc "go.sour.is/advent-of-code"
)
func TestLCM(t *testing.T) {
is := is.New(t)
@ -24,4 +30,4 @@ func TestABS(t *testing.T) {
is.Equal(aoc.ABS(1), 1)
is.Equal(aoc.ABS(0), 0)
is.Equal(aoc.ABS(-1), 1)
}
}

View File

@ -1,5 +1,12 @@
package aoc_test
import (
"sort"
"testing"
"github.com/matryer/is"
aoc "go.sour.is/advent-of-code"
)
func TestSet(t *testing.T) {
is := is.New(t)
@ -17,4 +24,4 @@ func TestSet(t *testing.T) {
items := s.Items()
sort.Ints(items)
is.Equal(items, []int{1, 2, 3, 4})
}
}