Skip to content

Instantly share code, notes, and snippets.

@kiennq
Created October 24, 2013 09:30
Show Gist options
  • Save kiennq/7134028 to your computer and use it in GitHub Desktop.
Save kiennq/7134028 to your computer and use it in GitHub Desktop.
#!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