2024-12-03 14:51:54 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
_ "embed"
|
|
|
|
|
|
|
|
"github.com/matryer/is"
|
|
|
|
)
|
|
|
|
|
|
|
|
//go:embed example.txt
|
|
|
|
var example []byte
|
|
|
|
//go:embed example2.txt
|
|
|
|
var example2 []byte
|
|
|
|
|
|
|
|
//go:embed input.txt
|
|
|
|
var input []byte
|
|
|
|
|
|
|
|
func TestExample(t *testing.T) {
|
|
|
|
is := is.New(t)
|
|
|
|
|
|
|
|
result, err := run(bytes.NewReader(example))
|
|
|
|
is.NoErr(err)
|
|
|
|
|
|
|
|
t.Log(result)
|
|
|
|
is.Equal(result.valuePT1, 161)
|
|
|
|
|
2024-12-03 16:15:53 -07:00
|
|
|
result, err = run(bytes.NewReader(example2))
|
|
|
|
is.NoErr(err)
|
|
|
|
is.Equal(result.valuePT1, 161)
|
|
|
|
is.Equal(result.valuePT2, 48)
|
2024-12-03 14:51:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSolution(t *testing.T) {
|
|
|
|
is := is.New(t)
|
|
|
|
|
|
|
|
result, err := run(bytes.NewReader(input))
|
|
|
|
is.NoErr(err)
|
|
|
|
|
|
|
|
t.Log(result)
|
|
|
|
is.True(result.valuePT1 < 186942148) // first attempt too high
|
|
|
|
is.Equal(result.valuePT1, 184122457)
|
2024-12-03 16:15:53 -07:00
|
|
|
is.Equal(result.valuePT2, 107862689)
|
2024-12-03 14:51:54 -07:00
|
|
|
}
|