mirror of
https://github.com/Crocmagnon/advent-of-code.git
synced 2024-11-21 14:08:11 +01:00
23 lines
371 B
Go
23 lines
371 B
Go
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
|
|
}
|