Skip to content

Instantly share code, notes, and snippets.

@lykkin
Last active August 29, 2015 14:15
Show Gist options
  • Save lykkin/b08d910b50a082032880 to your computer and use it in GitHub Desktop.
Save lykkin/b08d910b50a082032880 to your computer and use it in GitHub Desktop.
from random import random
envs = [1, 2]
swapping = 0
staying = 0
for x in xrange(100000000):
if random() <= .5:
envs.reverse()
if random() <= .5:
swapping += envs[1]
else:
swapping += envs[0]
for x in xrange(10000000):
if random() <= .5:
envs.reverse()
if random() <= .5:
staying += envs[0]
else:
staying += envs[1]
print 'swapping: ', swapping
print 'staying: ', staying
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment