aoc2024/day-25/internal/one/util.go

31 lines
629 B
Go
Raw Normal View History

2024-12-26 19:00:37 +00:00
package one
import (
"bytes"
"io"
)
func parseLines(r io.Reader) (int, map[kindOfSchematic][]*schematic, error) {
raw, _ := io.ReadAll(r)
rawSchematics := bytes.Split(raw, []byte("\n\n"))
schematics := map[kindOfSchematic][]*schematic{Lock: {}, Key: {}}
for _, rawSchematic := range rawSchematics {
s := newSchematic(bytes.Split(rawSchematic, []byte("\n")))
schematics[s.kind] = append(schematics[s.kind], s)
}
maxHeight := len(schematics[Lock][0].heights)
return maxHeight, schematics, nil
}
func allInString(s string, r rune) bool {
for _, c := range s {
if c != r {
return false
}
}
return true
}