aoc2024/day-02/internal/util/util.go

23 lines
298 B
Go

package util
import (
"strconv"
"strings"
)
func MustConv(s string) int {
n, err := strconv.Atoi(s)
if err != nil {
panic(err)
}
return n
}
func IntsFromString(s string) []int {
nums := []int{}
for _, r := range strings.Fields(s) {
nums = append(nums, MustConv(r))
}
return nums
}