Files
adventofcode/2024/go/day07/day07_test.go
2024-12-08 20:51:22 +00:00

47 lines
864 B
Go

package day07
import (
"testing"
"github.com/stretchr/testify/require"
"fmt"
)
func TestPart1(t *testing.T) {
r := Part1(`190: 10 19
3267: 81 40 27
83: 17 5
156: 15 6
7290: 6 8 6 15
161011: 16 10 13
192: 17 8 14
21037: 9 7 18 13
292: 11 6 16 20`)
require.Equal(t, 3749, r)
}
func TestPart2(t *testing.T) {
r := Part2(`190: 10 19
3267: 81 40 27
83: 17 5
156: 15 6
7290: 6 8 6 15
161011: 16 10 13
192: 17 8 14
21037: 9 7 18 13
292: 11 6 16 20`)
require.Equal(t, 11387, r)
}
func TestGetOp(t *testing.T) {
operations := []Op{Add, Mul, Conc} // Define the operations
X := 3 // Define the number of positions (columns)
// Start the recursive generation with an empty prefix
results := [][]Op{}
generatePermutations(operations, X, []Op{}, &results)
for _, op := range results {
fmt.Printf("%v\n", op)
}
r := Add
require.Equal(t, Add, r)
}