import numpy
import time
arr = [5, 3, 1, 3, 5, 2, 5, 3, 1, 3, 5, 2, 5]
arr1 = [1, 1, 1, 1]
arr2 = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]
arr3 = [5, 4, 2, 1, 5]
arr4 = [4, 3, 4, 3, 4, 2, 4, 3, 4, 3, 4, 2, 4]
arr5 = [4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4]
arr_time = list((numpy.random.rand(29999) * 10).astype(int))
arr_time.append(arr_time[0])
def sectors(arr):
l, last = 0, len(arr) - 1
while l < last:
l = arr[l+1:].index(arr[0]) + l + 1
if last % l != 0:
continue
for i in range(last // l):
if arr[0:l] != arr[l * i: l * (i + 1)]:
break
else:
break
return l
a = sectors(arr)
b = sectors(arr1)
c = sectors(arr2)
d = sectors(arr3)
e = sectors(arr4)
f = sectors(arr5)
print(a,b,c,d,e,f)
t = time.time()
print(sectors(arr_time))
print("Array of %d elements took %.3f seconds to process" % (len(arr_time), time.time() - t))
aW1wb3J0IG51bXB5CmltcG9ydCB0aW1lCgphcnIgPSBbNSwgMywgMSwgMywgNSwgMiwgNSwgMywgMSwgMywgNSwgMiwgNV0KYXJyMSA9IFsxLCAxLCAxLCAxXQphcnIyID0gWzMsIDIsIDEsIDMsIDIsIDEsIDMsIDIsIDEsIDMsIDIsIDEsIDMsIDIsIDEsIDNdCmFycjMgPSBbNSwgNCwgMiwgMSwgNV0KYXJyNCA9IFs0LCAzLCA0LCAzLCA0LCAyLCA0LCAzLCA0LCAzLCA0LCAyLCA0XQphcnI1ID0gWzQsIDMsIDQsIDMsIDQsIDMsIDQsIDMsIDQsIDMsIDQsIDMsIDRdCmFycl90aW1lID0gbGlzdCgobnVtcHkucmFuZG9tLnJhbmQoMjk5OTkpICogMTApLmFzdHlwZShpbnQpKQphcnJfdGltZS5hcHBlbmQoYXJyX3RpbWVbMF0pCgpkZWYgc2VjdG9ycyhhcnIpOgoJbCwgbGFzdCA9IDAsIG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