68 lines
736 B
Go
68 lines
736 B
Go
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)
|
|
}
|