initial commit

This commit is contained in:
2026-07-23 23:25:26 +01:00
commit 6df41c1888
14 changed files with 765 additions and 0 deletions

19
util.go Normal file
View File

@@ -0,0 +1,19 @@
package lottery
import (
"math/rand"
"sort"
)
// drawUnique returns count unique numbers in the range [1, max].
// It uses the rand.Perm function to generate a random permutation of numbers and selects the first count numbers from it.
// The result is sorted before being returned.
func drawUnique(count, max int) []int {
perm := rand.Perm(max)
result := make([]int, count)
for i := range result {
result[i] = perm[i] + 1
}
sort.Ints(result)
return result
}