Skip to content

Instantly share code, notes, and snippets.

@carwin
Created August 30, 2019 04:53
Show Gist options
  • Save carwin/f905ff324bcb8794950581e45149c0eb to your computer and use it in GitHub Desktop.
Save carwin/f905ff324bcb8794950581e45149c0eb to your computer and use it in GitHub Desktop.
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