Add some test for vertical movement

This commit is contained in:
Kovid Goyal
2022-10-17 12:50:02 +05:30
parent 00ef9c1955
commit d260d2f480
3 changed files with 46 additions and 1 deletions

View File

@@ -53,3 +53,23 @@ func StableSortWithKey[T any, C constraints.Ordered](s []T, key func(a T) C) []T
sort.SliceStable(s, func(i, j int) bool { return mem[i] < mem[j] })
return s
}
func Max[T constraints.Ordered](a T, items ...T) (ans T) {
ans = a
for _, q := range items {
if q > ans {
ans = q
}
}
return ans
}
func Min[T constraints.Ordered](a T, items ...T) (ans T) {
ans = a
for _, q := range items {
if q < ans {
ans = q
}
}
return ans
}