Created
April 27, 2012 16:28
-
-
Save ralphbean/2510587 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
| 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 |
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
| 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