Created
June 14, 2018 05:50
-
-
Save f3ath/3ffe8d74214501c5f653562dfab9afd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def substrings_exist(line, size): | |
max_possible_offset = len(line) - size * 2 | |
for offset in range(0, max_possible_offset + 1): | |
border = offset + size | |
substring = line[offset:border] | |
the_rest_of_the_string = line[border:] | |
if the_rest_of_the_string.find(substring) != -1: | |
return True | |
return False | |
def double_substring(line): | |
max_possible_substring_size = len(line) // 2 | |
for size in range(max_possible_substring_size, 0, -1): | |
if substrings_exist(line, size): | |
return size | |
return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment