Skip to content

Instantly share code, notes, and snippets.

@fission6
Created May 4, 2012 01:56
Show Gist options
  • Save fission6/2591268 to your computer and use it in GitHub Desktop.
Save fission6/2591268 to your computer and use it in GitHub Desktop.
for odedo
#!/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