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

34 lines
504 B
Go

package one
import (
"bufio"
"io"
"strings"
)
func parseLines(r io.Reader) ([]string, []string, error) {
var stripes, designs []string
var inDesigns bool
scanner := bufio.NewScanner(r)
for scanner.Scan() {
line := scanner.Text()
if line == "" {
inDesigns = true
continue
}
if inDesigns {
designs = append(designs, line)
} else {
stripes = strings.Split(line, ", ")
}
}
if err := scanner.Err(); err != nil {
return nil, nil, err
}
return stripes, designs, nil
}