Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created April 27, 2012 16:28
Show Gist options
  • Select an option

  • Save ralphbean/2510587 to your computer and use it in GitHub Desktop.

Select an option

Save ralphbean/2510587 to your computer and use it in GitHub Desktop.
def randint(min=0, max=10):
"""Return an int between min and max"""
range = max - min
if range == 0:
#raise ValueError("range cannot be zero")
return min
modulos = int(float(MAX_INT) / range)
too_big = modulos * range
while True:
num = get_data()[0]
if num >= too_big:
continue
else:
return num / modulos + min
from quantumrandom import randint
for i in range(5):
for j in range(i+1, 5):
for k in range(3):
print "randint(%i, %i) -> %i" % (i, j, randint(i, j))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment