s = "kapkapkap"
def find_repeating_substring(s):
# Проверим, что длина строки четная
if len(s) % 2 != 0:
return ""
n = len(s)
for i in range(1, n // 2 + 1):
if n % i == 0: # Длина подстроки должна делиться на общую длину без остатка
substring = s[:i]
is_valid = True
for j in range(i, n, i):
if s[j:j+i] != substring:
is_valid = False
break
if is_valid:
return substring
return "No" # Подходящей подстроки нет
print(find_repeating_substring(s))
cyA9ICJrYXBrYXBrYXAiCgpkZWYgZmluZF9yZXBlYXRpbmdfc3Vic3RyaW5nKHMpOgogICAgIyDQn9GA0L7QstC10YDQuNC8LCDRh9GC0L4g0LTQu9C40L3QsCDRgdGC0YDQvtC60Lgg0YfQtdGC0L3QsNGPCiAgICBpZiBsZW4ocykgJSAyICE9IDA6CiAgICAgICAgcmV0dXJuICIiCiAgICAKICAgIG4gPSBsZW4ocykKICAgIAogICAgZm9yIGkgaW4gcmFuZ2UoMSwgbiAvLyAyICsgMSk6CiAgICAgICAgaWYgbiAlIGkgPT0gMDogICMg0JTQu9C40L3QsCDQv9C+0LTRgdGC0YDQvtC60Lgg0LTQvtC70LbQvdCwINC00LXQu9C40YLRjNGB0Y8g0L3QsCDQvtCx0YnRg9GOINC00LvQuNC90YMg0LHQtdC3INC+0YHRgtCw0YLQutCwCiAgICAgICAgICAgIHN1YnN0cmluZyA9IHNbOmldCiAgICAgICAgICAgIAogICAgICAgICAgICBpc192YWxpZCA9IFRydWUKICAgICAgICAgICAgZm9yIGogaW4gcmFuZ2UoaSwgbiwgaSk6CiAgICAgICAgICAgICAgICBpZiBzW2o6aitpXSAhPSBzdWJzdHJpbmc6CiAgICAgICAgICAgICAgICAgICAgaXNfdmFsaWQgPSBGYWxzZQogICAgICAgICAgICAgICAgICAgIGJyZWFrCiAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgIGlmIGlzX3ZhbGlkOgogICAgICAgICAgICAgICAgcmV0dXJuIHN1YnN0cmluZwogICAgICAgICAgICAgICAgCiAgICByZXR1cm4gIk5vIiAgIyDQn9C+0LTRhdC+0LTRj9GJ0LXQuSDQv9C+0LTRgdGC0YDQvtC60Lgg0L3QtdGCCiAgICAKcHJpbnQoZmluZF9yZXBlYXRpbmdfc3Vic3RyaW5nKHMpKQ==