Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Double Substring by smith84
def double_substring(line):
total_sequence = []
sequence = ''
max = 0
for literal in line:
if line.count(literal) > 1:
sequence += literal
if len(sequence) > 1 and line.count(sequence) >= 2:
total_sequence.append(sequence)
elif line.count(sequence) > 1:
total_sequence.append(sequence)
else:
sequence = ''
for element in total_sequence:
if len(element) > max:
max = len(element)
return max
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert double_substring('aaaa') == 2, "First"
assert double_substring('abc') == 0, "Second"
assert double_substring('aghtfghkofgh') == 3, "Third"
print('"Run" is good. How is "Check"?')
June 22, 2019