import random
def getResult():
L=[0,0,0]
car=random.randint(0,2)
L[car]=1
choice=random.randint(0,2)
if choice==car:
return 0
else:
return 1
def getPI():
x=random.uniform(-1,1)
y=random.uniform(-1,1)
if x*x+y*y<=1:
return 1
else:
return 0
K=1000000
i=0
circle=0
while i<K:
circle+=getPI()
i+=1
print circle*1.0/i*4
import random
def diff(a,b,c,d,e):
if(a==3):
return 1
elif(b==3 or c==3 or d==3 or e==3):
return 0
die=random.randint(0,4)
if(die==0):
return diff(a+1,b,c,d,e)
elif die==1:
return diff(a,b+1,c,d,e)
elif die==2:
return diff(a,b,c+1,d,e)
elif die==3:
return diff(a,b,c,d+1,e)
else:
return diff(a,b,c,d,e+1)
K=100000
a=0
i=0
while i<K:
a+=diff(2,1,1,1,1)
i+=1
print a*1.0/i