diff options
Diffstat (limited to 'factors/slices.go')
| -rw-r--r-- | factors/slices.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/factors/slices.go b/factors/slices.go new file mode 100644 index 0000000..f2462cf --- /dev/null +++ b/factors/slices.go @@ -0,0 +1,27 @@ +package factors + +import "sort" + +func sortUints(s []uint) []uint { + sort.Slice(s, func(i, j int) bool { return s[i] < s[j] }) + return s +} + +func maxUints(s []uint) uint { + max := uint(0) + for _, n := range s { + if n > max { + max = n + } + } + return max +} + +func contains[S ~[]E, E comparable](s S, e E) bool { + for _, element := range s { + if e == element { + return true + } + } + return false +} |
