subset.go 222 B

1234567891011121314
  1. package resolver
  2. import "math/rand"
  3. func subset(set []string, sub int) []string {
  4. rand.Shuffle(len(set), func(i, j int) {
  5. set[i], set[j] = set[j], set[i]
  6. })
  7. if len(set) <= sub {
  8. return set
  9. }
  10. return set[:sub]
  11. }