Consecutive Character Sequences
Aries Sun
sun.aries at gmail.com
Thu Jul 14 03:17:49 EDT 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:
return True
return False
>>> hasConsequent(s, 2)
True
>>> hasConsequent(s, 3)
True
>>> hasConsequent(s, 4)
False
Aries Sun
More information about the Python-list
mailing list