From f8fa61672f37fce9a7686e0c5fd8b334f30b4233 Mon Sep 17 00:00:00 2001 From: xuu Date: Mon, 22 Jan 2024 16:07:16 -0700 Subject: [PATCH] chore: fixes --- grids.go | 8 +++++--- itertools_test.go | 5 +---- math_test.go | 8 +++++++- set_test.go | 9 ++++++++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/grids.go b/grids.go index 17fdb58..a07340c 100644 --- a/grids.go +++ b/grids.go @@ -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 diff --git a/itertools_test.go b/itertools_test.go index db9ea78..63d1b45 100644 --- a/itertools_test.go +++ b/itertools_test.go @@ -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}, }, ) -} \ No newline at end of file +} diff --git a/math_test.go b/math_test.go index 14b2fd3..eeb8f2f 100644 --- a/math_test.go +++ b/math_test.go @@ -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) -} \ No newline at end of file +} diff --git a/set_test.go b/set_test.go index 16b12c9..c4a5d3d 100644 --- a/set_test.go +++ b/set_test.go @@ -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}) -} \ No newline at end of file +}