chore: cleanup and add tools

This commit is contained in:
xuu
2024-10-30 13:32:44 -06:00
parent 04bbac8559
commit e046a6c06d
11 changed files with 325 additions and 53 deletions
+2 -22
View File
@@ -9,7 +9,6 @@ import (
aoc "go.sour.is/advent-of-code"
)
func TestList(t *testing.T) {
is := is.New(t)
@@ -56,7 +55,6 @@ func TestPriorityQueue(t *testing.T) {
is.True(v == nil)
}
func ExamplePriorityQueue() {
type memo struct {
pt int
@@ -74,7 +72,7 @@ func ExamplePriorityQueue() {
}
pq := aoc.PriorityQueue(less)
visited := aoc.Set([]int{}...)
visited := aoc.NewSet([]int{}...)
dist := aoc.DefaultMap[int](int(^uint(0) >> 1))
dist.Set(0, 0)
@@ -117,25 +115,7 @@ func ExamplePriorityQueue() {
// point 5 is 22 steps away.
// point 6 is 19 steps away.
}
func TestGraph(t *testing.T) {
is := is.New(t)
var adjacencyList = map[int][]int{
2: {3, 5, 1},
1: {2, 4},
3: {6, 2},
4: {1, 5, 7},
5: {2, 6, 8, 4},
6: {3, 0, 9, 5},
7: {4, 8},
8: {5, 9, 7},
9: {6, 0, 8},
}
g := aoc.Graph(aoc.WithAdjacencyList[int, int](adjacencyList))
is.Equal(g.Neighbors(1), []int{2, 4})
is.Equal(map[int][]int(g.AdjacencyList()), adjacencyList)
}
func ExampleFibHeap() {
type memo struct {
@@ -154,7 +134,7 @@ func ExampleFibHeap() {
}
pq := aoc.FibHeap(less)
visited := aoc.Set([]int{}...)
visited := aoc.NewSet([]int{}...)
dist := aoc.DefaultMap[int](int(^uint(0) >> 1))
dist.Set(0, 0)