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

28 lines
384 B
Go
Raw Normal View History

2024-12-25 14:45:38 +00:00
package one
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
}