a = len(str1) b = len(str2) print(a, b) if a < b: str1, str2 = str2, str1 a = len(str1) b = len(str2)
ifnot a%b: for x in range(0, a//b): if str1[x*b:(x+1)*b] != str2: return'' return str2 else: for x in range(b, 0, -1): print(x) if x==b or b%x or a%x: continue for y in range(0, b//x): if str2[y*x:(y+1)*x] != str2[b-x:b]: return'' for y in range(0, a//x): if str1[y*x:(y+1)*x] != str2[0:x]: return'' return str2[0:x] # 44 ms 13.9 MB