Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
module re. This is a very difficult task for the Elementary+ level!!! solution in Clear category for Long Repeat Inside by chur4hella
import re
def repeat_inside(line):
r = re.findall(r'(?=((.+?)\2+))', line)
return sorted([i[0] for i in r], key=len, reverse=True)[0] if r else ''
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert repeat_inside('aaaaa') == 'aaaaa', "First"
assert repeat_inside('aabbff') == 'aa', "Second"
assert repeat_inside('aababcc') == 'abab', "Third"
assert repeat_inside('abc') == '', "Forth"
assert repeat_inside('abcabcabab') == 'abcabc', "Fifth"
print('"Run" is good. How is "Check"?')
Jan. 28, 2021
Comments: