Untitled

mail@pastecode.io avatar
unknown
python
a year ago
431 B
4
Indexable
Never
def  getAnagramPeriod(input_str):
    n = len(input_str)
    from collections import Counter
    def is_possible(val):
        counter = Counter(input_str[:val])
        for i in range(val, n, val):
            if Counter(input_str[i: i+val]) != counter:
                return False
        return True
    
    for i in range(1, n):
        if n % i == 0:
            if is_possible(i):
                return i
    
    return n