Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Single pass Solution solution in Speedy category for Long Repeat by brubru777
def long_repeat(line):
"""
length the longest substring that consists of the same char
"""
max_count = 0
ounnt = 0
prev = None
for c in line:
if c == prev:
count += 1
else:
count = 1
if count > max_count:
max_count = count
prev = c
return max_count
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"?')
Oct. 18, 2017