https://github.com/uberswe/randompick
A simple function which takes a map of weighted options and picks one at random. This might be useful for a lottery or raffle where participants might have multiple tickets.
https://github.com/uberswe/randompick
random-pick random-pick-with-weight
Last synced: about 1 year ago
JSON representation
A simple function which takes a map of weighted options and picks one at random. This might be useful for a lottery or raffle where participants might have multiple tickets.
- Host: GitHub
- URL: https://github.com/uberswe/randompick
- Owner: uberswe
- License: mit
- Created: 2022-07-26T11:30:54.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-26T11:32:03.000Z (almost 4 years ago)
- Last Synced: 2025-05-19T20:33:23.062Z (about 1 year ago)
- Topics: random-pick, random-pick-with-weight
- Language: Go
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RandomPick
A simple function which takes a map of weighted options and picks one at random. This might be useful for a lottery or raffle where participants might have multiple tickets.
```go
rand.Seed(time.Now().UnixNano())
m := map[string]int{
"Bob": 900,
"Steve": 2000,
"Kyle": 300,
}
fmt.Println(randompick.Result(m))
```