counting runs

Jason Tangen j.tangen at unsw.edu.au
Mon Oct 31 19:22:27 EST 2005


Hello,

I'm trying to solve a seemingly simple problem and I could use some  
help. A coin flip will come out "Heads" or "Tails" and will produce,  
for example, the following series for 20 flips:

T,T,H,T,T,H,H,H,T,T,H,T,H,H,H,T,H,T,H,T

I need to count up the number events for a particular run.  For example,

Heads x 3 = 2
Heads x 2 = 0
Heads x 1 = 4
Tails x 1 = 4
Tails x 2 = 3
Tails x 3 = 0

I need to account for runs up to 60 (rather than 3 above) for  
hundreds of flips (rather than 20 above).

I've been using a very clumsy multiple if-then solution to date, but  
this quickly becomes difficult with many runs.

Can someone point me in the right direction?

Cheers,
Jason



More information about the use-livecode mailing list