Skip to content

Instantly share code, notes, and snippets.

@mahiuchun
Created September 3, 2012 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahiuchun/3614851 to your computer and use it in GitHub Desktop.
Save mahiuchun/3614851 to your computer and use it in GitHub Desktop.
HW0 Problem2 Simulation
import random
import os
cnum = 1000000
total = 0
n = 6
random.seed(os.urandom(1024))
for i in range(cnum):
money = 0
alice = random.choice(range(1, n+1))
bob = 0
while bob < alice:
bob = random.choice(range(1, n+1))
money = money + 1
total = total + money
print total / float(cnum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment