Skip to content

Instantly share code, notes, and snippets.

/dylemat Halla.py
Created Dec 6, 2008

Embed
What would you like to do?
#!/usr/bin/python
import random
gates = [1,2,3]
n = 1000000
n_switch = n_keep = 0
for i in xrange(n):
prize = random.choice(gates) # w tej bramce jest nagroda
choice = random.choice(gates) # bramka wybrana przez gracza
empty = random.choice(list( set(gates) - set([prize,choice]) ))
if prize == choice:
n_keep += 1
else:
n_switch += 1
print 'zmiana: %f, bez zmiany: %f' % ( float(n_switch)/n, float(n_keep)/n )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.