Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Long Repeat by zgub4
def long_repeat(line):
if len(line) == 0:
return 0
longest = 0
current_len = 0
current_letter = line[0]
for c in line:
if c == current_letter:
current_len += 1
else:
current_letter = c
if current_len > longest:
longest = current_len
current_len = 1
if current_len > longest:
return current_len
return longest
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. 21, 2017