Created
August 30, 2019 04:53
-
-
Save carwin/f905ff324bcb8794950581e45149c0eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dice | |
import { | |
"time" | |
"math/rand" | |
) | |
func RollDice(count int, sides int) int { | |
min := 1 | |
max := sides | |
seed := rand.NewSource(time.Now().UnixNano()) | |
var total int | |
for i := 0; i < count; i++ { | |
total += rand.New(seed).Intn(max - min + 1) + min | |
} | |
return total | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment