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

21 lines
278 B
Go

package one
import (
"cmp"
"slices"
"strconv"
)
func mustConv(s string) int {
n, err := strconv.Atoi(s)
if err != nil {
panic(err)
}
return n
}
func insertSorted[T cmp.Ordered](ts []T, t T) []T {
i, _ := slices.BinarySearch(ts, t)
return slices.Insert(ts, i, t)
}