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

34 lines
504 B
Go
Raw Permalink Normal View History

2024-12-19 09:39:38 +00:00
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
}