aoc2024/day-22/internal/one/solve.go

30 lines
456 B
Go
Raw Permalink Normal View History

2024-12-22 16:54:03 +00:00
package one
import (
"bytes"
"github.com/onyx-and-iris/aoc2024/day-22/internal/randomiser"
)
const numIterations = 2000
func Solve(buf []byte) (int, error) {
r := bytes.NewReader(buf)
secrets, err := parseLines(r)
if err != nil {
return 0, err
}
var sum int
for _, secret := range secrets {
randomiser := randomiser.New(secret)
for range numIterations {
randomiser.Randomise()
}
sum += randomiser.Secret()
}
return sum, nil
}