Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Long Repeat by mori123
def long_repeat(line):
val=0
num=0
for i in range(len(line)):
if i!=0 and ord(line[i])== ord(line[i-1]):
num+=1
if num>val:
val=num
else:
num=0
if val>=0:
val+=1
if len(line)==0:
val=0
return val
"""
length the longest substring that consists of the same char
"""
# your code here
return val
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"?')
Dec. 2, 2017