parent
b0b9d126f1
commit
7a3ac77866
@ -1,14 +1,17 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import "math/rand"
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
func RandArray(n int) []int {
|
func RandArray(n int) []int {
|
||||||
// needed a seed input else it will generate the same number
|
// needed a seed input else it will generate the same number
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
arr := make([]int, n)
|
arr := make([]int, n)
|
||||||
for i := 0; i <= n - 1; i++ {
|
for i := 0; i <= n-1; i++ {
|
||||||
arr[i] = rand.Intn(n)
|
arr[i] = rand.Intn(n)
|
||||||
}
|
}
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue