[Tutor] Finding the "streaks" in heads/tails list
Alec Henriksen
alecwh at gmail.com
Wed Oct 1 22:56:08 CEST 2008
Hello,
I thought it'd be cool to write a program for my logic/critical thinking
class, and right now we're evaluating randomness - and the deception of
it. A previous post inspired it - coin flipping.
So, I've written a program that flips a coin 1000 times and records it
all in a dictionary, like this:
# 0 = heads, 1 = tails
flips = [0,0,0,1,0,1,0,0,1,1,1,1,1,0,0,1,0,1,0,1,0,1]
What I want to do, is find out the largest "streak" of digits. In the
above example, the streak would be 5, because there are 5 tails flips in
a row.
I've thought about this, and it seems like regular expressions would be
needed.
Can someone help/hint? Thanks in advance!
More information about the Tutor
mailing list