mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 22:30:47 +00:00
31 lines
625 B
Go
31 lines
625 B
Go
package one
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
)
|
|
|
|
func parseLines(r io.Reader) (int, map[kind][]*schematic, error) {
|
|
raw, _ := io.ReadAll(r)
|
|
rawSchematics := bytes.Split(raw, []byte("\n\n"))
|
|
|
|
schematics := map[kind][]*schematic{kindOfLock: {}, kindOfKey: {}}
|
|
for _, rawSchematic := range rawSchematics {
|
|
s := newSchematic(bytes.Split(rawSchematic, []byte("\n")))
|
|
schematics[s.kind] = append(schematics[s.kind], s)
|
|
}
|
|
|
|
maxHeight := len(schematics[kindOfLock][0].heights)
|
|
|
|
return maxHeight, schematics, nil
|
|
}
|
|
|
|
func allInString(s string, r rune) bool {
|
|
for _, c := range s {
|
|
if c != r {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|