Skip to content

Instantly share code, notes, and snippets.

@kacole2
Created August 19, 2015 18:30
Show Gist options
  • Save kacole2/41813b651c183cedfef2 to your computer and use it in GitHub Desktop.
Save kacole2/41813b651c183cedfef2 to your computer and use it in GitHub Desktop.
random number generator used to choose beers at Chuck's Hop Shop in Seattle
package main
import (
"fmt"
"math/rand"
"time"
)
func random(min, max int) int {
rand.Seed(time.Now().Unix())
return rand.Intn(max-min) + min
}
func main() {
a := random(1, 8)
b := random(1, 6)
c := random(1, 9)
fmt.Printf("Your magic beer is: %v%v%v \n", a, b, c)
fmt.Printf("Fridge Column: %v\nRow: %v\nBeer: %v\n", a, b, c)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment