Consecutive Character Sequences
sun.aries at gmail.com
Thu Jul 14 09:17:49 CEST 2005
I have tested George's solutions, it seems not complete. When pass (s,
3) to the function hasConsequent(), it returns the wrong result.
The following is my approach. The performence may be not so good. There
must be better ones.
>>> from re import findall
>>> def hasConsequent(aString, minConsequent):
for ch in aString:
result = findall(ch*minConsequent, aString)
if len(result) >= 1:
>>> hasConsequent(s, 2)
>>> hasConsequent(s, 3)
>>> hasConsequent(s, 4)
More information about the Python-list