Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
find each character's sets solution in Speedy category for Long Repeat by PythonWithPI
def long_repeat(line):
"""
length the longest substring that consists of the same char
"""
import re
ret=[]
for char in set(line):
ret.append(max(map(len,re.findall(char+'+',line))))
return max(ret) if line else 0
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert long_repeat('sdsffffse') == 4, "First"
assert long_repeat('ddvvrwwwrggg') == 3, "Second"
print('"Run" is good. How is "Check"?')
Aug. 16, 2017
Comments: