Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Readable, explainable, enjoynable solution in Clear category for Double Substring by standrey
def double_substring(line):
reslen = 0
for i in range(0, len(line)):
for j in range(i+1, len(line)):
sub_str = line[i:j]
#print("Check " + sub_str + " in " + line[j:])
if sub_str in line[j:] and reslen < len(sub_str):
reslen = len(sub_str)
#print(reslen)
return reslen
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