package one import ( "bytes" log "github.com/sirupsen/logrus" ) func Solve(buf []byte) (int, error) { r := bytes.NewReader(buf) maxHeight, schematics, err := parseLines(r) if err != nil { return 0, err } var count int for _, lock := range schematics[kindOfLock] { for _, key := range schematics[kindOfKey] { if func() bool { for i := range key.heights { if key.heights[i]+lock.heights[i] > maxHeight { return false } } return true }() { count++ log.Debugf("lock: %v and key: %v", lock.heights, key.heights) } } } return count, nil }