Created
September 30, 2012 16:44
-
-
Save anonymous/3807542 to your computer and use it in GitHub Desktop.
3 Line dice roller
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
#!/usr/bin/python | |
import sys, random, re | |
m = re.match(r"(\d*)d(\d*)([-+]?\d*)",sys.argv[1]) | |
print sum([random.randint(1,int(m.group(2))) for i in range(int(m.group(1)or"1"))]) + (int(m.group(3) or "0")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment