much better day13 after looking at others
This commit is contained in:
67
2022/go/day13/day13_test.go
Normal file
67
2022/go/day13/day13_test.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package day13
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"strings"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPart1(t *testing.T) {
|
||||
input := `[1,1,3,1,1]
|
||||
[1,1,5,1,1]
|
||||
|
||||
[[1],[2,3,4]]
|
||||
[[1],4]
|
||||
|
||||
[9]
|
||||
[[8,7,6]]
|
||||
|
||||
[[4,4],4,4]
|
||||
[[4,4],4,4,4]
|
||||
|
||||
[7,7,7,7]
|
||||
[7,7,7]
|
||||
|
||||
[]
|
||||
[3]
|
||||
|
||||
[[[]]]
|
||||
[[]]
|
||||
|
||||
[1,[2,[3,[4,[5,6,7]]]],8,9]
|
||||
[1,[2,[3,[4,[5,6,0]]]],8,9]`
|
||||
stringSlice := strings.Split(input, "\n")
|
||||
r := Part1(stringSlice)
|
||||
|
||||
require.Equal(t, 13, r)
|
||||
}
|
||||
|
||||
func TestPart2(t *testing.T) {
|
||||
input := `[1,1,3,1,1]
|
||||
[1,1,5,1,1]
|
||||
|
||||
[[1],[2,3,4]]
|
||||
[[1],4]
|
||||
|
||||
[9]
|
||||
[[8,7,6]]
|
||||
|
||||
[[4,4],4,4]
|
||||
[[4,4],4,4,4]
|
||||
|
||||
[7,7,7,7]
|
||||
[7,7,7]
|
||||
|
||||
[]
|
||||
[3]
|
||||
|
||||
[[[]]]
|
||||
[[]]
|
||||
|
||||
[1,[2,[3,[4,[5,6,7]]]],8,9]
|
||||
[1,[2,[3,[4,[5,6,0]]]],8,9]`
|
||||
stringSlice := strings.Split(input, "\n")
|
||||
r := Part2(stringSlice)
|
||||
|
||||
require.Equal(t, 140, r)
|
||||
}
|
||||
Reference in New Issue
Block a user