Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
I have broken my head solution in Clear category for Long Repeat Inside by Kolia951
import re
def repeat_inside(data: str) -> str:
"""
first the longest repeating substring
"""
matches = re.findall(r"(?=((\w+?)\2+))", data)
matches_list = [i[0] for i in matches]
return "" if not matches_list else max(matches_list, key=len)
print("Example:")
print(repeat_inside("aaaaa"))
assert repeat_inside("aaaaa") == "aaaaa"
assert repeat_inside("aabbff") == "aa"
assert repeat_inside("aababcc") == "abab"
assert repeat_inside("abc") == ""
assert repeat_inside("abcabcabab") == "abcabc"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Jan. 4, 2023