2023-22 straightforward grid problem but plenty of bugs to workout

This commit is contained in:
alexchao26
2024-08-15 12:53:28 -04:00
parent f2a2dd2b91
commit 36679efb83
2 changed files with 288 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
package main
import (
"testing"
)
var example = `1,0,1~1,2,1
0,0,2~2,0,2
0,2,3~2,2,3
0,0,4~0,2,4
2,0,5~2,2,5
0,1,6~2,1,6
1,1,8~1,1,9`
func Test_part1(t *testing.T) {
tests := []struct {
name string
input string
want int
}{
{
name: "example",
input: example,
want: 5,
},
{
name: "actual",
input: input,
want: 471,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := part1(tt.input); got != tt.want {
t.Errorf("part1() = %v, want %v", got, tt.want)
}
})
}
}
func Test_part2(t *testing.T) {
tests := []struct {
name string
input string
want int
}{
{
name: "example",
input: example,
want: 7,
},
{
name: "actual",
input: input,
want: 68525,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := part2(tt.input); got != tt.want {
t.Errorf("part2() = %v, want %v", got, tt.want)
}
})
}
}