Skip to content

Instantly share code, notes, and snippets.

Last active October 9, 2016 01:00
Show Gist options
  • Save anonymous/6361dafe227fbcce9ee29b2eb034be97 to your computer and use it in GitHub Desktop.
Save anonymous/6361dafe227fbcce9ee29b2eb034be97 to your computer and use it in GitHub Desktop.
import random
def rand5():
return random.randrange(0, 5)
def is_disqualified(a, b):
return a == 3 and b < 4
def rand7():
out = (rand5(), rand5())
while is_qualified(*out):
out = (rand5(), rand5())
sumout = sum(out) # Don't repeat this operation over and over...
""" Trust me, the picture I drew makes this look way more elegant. """
if sumout < 1: return 1
if sumout == 2: return 2
if sumout == 3: return 3
if sumout >= 7: return 6
if out[0] == 4: return 4
if out[1] == 4: return 5
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment