Friday, 6 September 2013

Counting runs in a string

Counting runs in a string

I have a string that looks like:
string = 'TTHHTHHTHHHHTTHHHTTT'
How can I count the number of runs in the string so that I get,
5 runs of T and 4 runs of H

No comments:

Post a Comment