Created
April 7, 2017 20:08
-
-
Save april/be09a9c1d27e50972034d8121bab176c 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
#!/usr/bin/env python3 | |
from random import randint | |
dice = 2 # two dice | |
die = 20 # d20 | |
rolls = 10000000 # roll this many times | |
f = min # low roll == min, high roll == max | |
rolled = sum = 0 | |
while rolled < rolls: | |
rolled += 1 | |
sum += f((randint(1, die) for _ in range(dice))) | |
print("Average roll: ", sum / rolled) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment