advent-of-code/2023/lib.go

24 lines
371 B
Go
Raw Normal View History

2023-12-08 19:04:55 +01:00
package _023
import (
"regexp"
"strconv"
"strings"
)
var reg = regexp.MustCompile(`\s+`)
func lineToInts(line string) []int {
line = strings.TrimSpace(line)
values := reg.Split(line, -1)
ints := make([]int, len(values))
for i, value := range values {
number, err := strconv.Atoi(value)
if err != nil {
panic(err)
}
ints[i] = number
}
return ints
}