mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2026-04-08 18:13:36 +00:00
first commit
This commit is contained in:
20
day-01/internal/util/util.go
Normal file
20
day-01/internal/util/util.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package util
|
||||
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user