Finding the period of a recurring element in an array Given an array A of integers, there exists at least one positive integer p such that A[i] == A[j] for all i and j for which i % p == j % p == 0. Find the smallest p.

Examples:


Input array: [1, _, 1, _, 1, _, 1, _, 1]. Output: 2
Input array: [1, _, _, 1, _, _, 1, _, _]. Output: 3.
Input array: [1, _, _, _, 1, _, _, _, 1]. Output: 4
Python 3, 47 bytes



f=lambda l,d=1:f(l,d+1)if~-len({*l[::d]})else d


Try It Online