Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Repeat by aya.kanazawa
def long_repeat(line):
top = 0
now_count = 0
last_char = ''
for char in line:
if char != last_char:
now_count = 1
else:
now_count += 1
top = now_count if now_count > top else top
last_char = char
return top
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"
assert long_repeat('abababaab') == 2, "Third"
assert long_repeat('abababa') == 1, "Fourth"
assert long_repeat('') == 0, "Empty"
print('"Run" is good. How is "Check"?')
April 22, 2019
Comments: