Created
May 4, 2012 01:56
-
-
Save fission6/2591268 to your computer and use it in GitHub Desktop.
for odedo
This file contains 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
#!/usr/env python2 | |
from random import choice | |
pop = ['a', 'b', 'c',] | |
simulations = 0 | |
""" | |
while simulations < 3: | |
simulations += 1 | |
def simulate(): | |
steps = 0 | |
result = choice(pop) | |
while result.find('abcb') == -1: | |
result = result + choice(pop) | |
steps += 1 | |
return steps | |
""" | |
# try something more like | |
def simulate(): | |
steps = 0 | |
result = choice(pop) | |
while not 'abcb' in result: | |
result = result + choice(pop) | |
steps += 1 | |
return steps | |
TOTAL_SUM = 0 | |
for i in range(3): | |
total = 0 | |
total += simulate() | |
print total | |
TOTAL_SUM += total | |
print TOTAL_SUM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment