Last active
January 17, 2018 20:36
-
-
Save kageru/71824d28e784d648ff6d2557393a5e13 to your computer and use it in GitHub Desktop.
digital die, just paste in into the python/ipython shell
This file contains 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
from random import randint | |
from functools import partial | |
def d(m, n=1): | |
s = 0 | |
print(f'{n}d{m}') | |
for _ in range(n): | |
r = randint(1, m) | |
s += r | |
print(r) | |
if n > 1: | |
print('sum:', s) | |
d6 = partial(d, 6, 1) | |
d20 = partial(d, 20, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment