Created
November 1, 2016 20:09
-
-
Save mmasztalerczuk/f183a46bd10981840981cc50205b413f 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
class SquareFreeString: | |
def get_all_substrings(self, input_string): | |
length = len(input_string) | |
return [input_string[i:j + 1] for i in range(length) for j in range(i, length)] | |
def isSquareFree(self, test): | |
t = self.get_all_substrings(test) | |
for i in t: | |
if len(i) % 2 != 0: | |
pass | |
else: | |
# rint(i, "?", i[:int(len(i) / 2)], i[int(len(i) / 2):]) | |
if i[:int(len(i) / 2)] == i[int(len(i) / 2):]: | |
return "not square-free" | |
return "square-free" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment