Last active
December 11, 2015 06:18
-
-
Save mgius/4558097 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import random | |
trials = 10000 | |
win_count = 0 | |
bag = ['RG', 'RP', 'GP'] | |
for _ in xrange(trials): | |
if 'G' in random.choice(bag): | |
win_count += 1 | |
print "I won %d out of %d times" % (win_count, trials) |
This file contains hidden or 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 calc_wins.py | |
I won 6701 out of 10000 times |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment