From f333f2f6e6cf4669279fe4aad55d8bcec344ca61 Mon Sep 17 00:00:00 2001 From: Gowtham Gopalakrishnan Date: Mon, 29 Oct 2018 17:41:33 +0530 Subject: [PATCH] Really randomising things Ref: [https://stackoverflow.com/questions/39529364/go-rand-intn-same-number-value](https://stackoverflow.com/questions/39529364/go-rand-intn-same-number-value) --- utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.go b/utils.go index 8b0830c..de6af9d 100644 --- a/utils.go +++ b/utils.go @@ -3,6 +3,9 @@ package utils import "math/rand" func RandArray(n int) []int { + // needed a seed input else it will generate the same number + rand.Seed(time.Now().UnixNano()) + arr := make([]int, n) for i := 0; i <= n - 1; i++ { arr[i] = rand.Intn(n)