aoc2024/day-21/internal/two/util.go

28 lines
384 B
Go

package two
import (
"bufio"
"io"
"strconv"
)
func parseLines(r io.Reader) ([]string, error) {
codes := []string{}
scanner := bufio.NewScanner(r)
for scanner.Scan() {
codes = append(codes, scanner.Text())
}
if err := scanner.Err(); err != nil {
return nil, err
}
return codes, nil
}
func numFromCode(s string) int {
n, _ := strconv.Atoi(s[:len(s)-1])
return n
}