Created
October 24, 2013 09:30
-
-
Save kiennq/7134028 to your computer and use it in GitHub Desktop.
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
#!python | |
import random | |
def rnd04(): | |
return random.randint(0,4); | |
def rnd03(): | |
rnd = rnd04() | |
while rnd > 3: | |
rnd = rnd04() | |
return rnd | |
def rnd07(): | |
return (rnd03()>>1) + (rnd03()<<1) | |
def rnd06(): | |
rnd = rnd07() | |
while rnd > 6: | |
rnd = rnd07() | |
return rnd | |
if __name__ == '__main__': | |
dist = {} | |
for i in range(1000): | |
ind = rnd06() | |
dist[ind] = dist.get(ind, 0) + 1 | |
print dist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment