From 38e3e9376ac836c7f20d4a5921d31e28ebd2536a Mon Sep 17 00:00:00 2001 From: Vishnu Raveendranthan Date: Sun, 13 Jun 2021 23:03:08 +0530 Subject: [PATCH] using the latest Shuffle function of rand package Updated the Script to use the Shuffle function from rand package --- code/cards/deck.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/code/cards/deck.go b/code/cards/deck.go index 3243ae1..4c7d851 100644 --- a/code/cards/deck.go +++ b/code/cards/deck.go @@ -60,12 +60,6 @@ func newDeckFromFile(filename string) deck { } func (d deck) shuffle() { - source := rand.NewSource(time.Now().UnixNano()) - r := rand.New(source) - - for i := range d { - newPosition := r.Intn(len(d) - 1) - - d[i], d[newPosition] = d[newPosition], d[i] - } + rand.Seed(time.Now().UnixNano()) + rand.Shuffle(len(d), func(i, j int) { d[i], d[j] = d[j], d[i] }) }