def powercheck(lst):
    count = 0
position = 0
for pos in KnuthMorrisPratt(double(lst), lst):
    count += 1
position = pos
if count == 2:
    break
return lst[:position]

def double(lst):
    for i in range(1, 3):
        for elem in lst:
            yield elem

def main():
    print(powercheck([1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1]))
if __name__ == '__main__':
    main()
Detect whether sequence is a multiple of a subsequence in Python