A simple array of integers is given. The problem is to detect if a pattern is repeatedly occurring in the array, and find the length of that pattern.
For example, for
{19, 6, 19, 6, 19, 6, 19, 6, 19, 6, 19, 6}
pattern {19, 6} should be detected and its length is 2.
For
{73, 7, 4, 73, 7, 4, 73, 7, 4, 73, 7, 4, 73, 7}
pattern {73, 7, 4} should be detected and its length is 3. (at the end of the array there need not be the complete pattern, but the pattern should start at the beginning of the array)
For
{73, 7, 4, 7, 2, 6, 7, 2, 7, 73, 9, 17, 7, 7}
the whole array is the pattern and its length is 14.
Related links



I suspect that algorithm is going to be the cleanest and fastest solution in any high-level language that supports finding sequences within a list.
– QuestionC Apr 17 '15 at 16:05(s+s).find(s, 1, -1)answer is (IMO) pretty amazing, so I wanted to raise attention in case that's applicable in Mathematica. – QuestionC Apr 17 '15 at 16:19Fourieris possible here? (I'm the guy who came up with the(s+s).find(s, 1, -1)solution, btw--flattered to see it's gotten so much attention!) – David Zhang Apr 17 '15 at 21:19{1,2,3,1,2,3,1,2}should display a cycle length of 3, but the concatenate-and-search algorithm would indicate that the string is not periodic. – David Z Apr 19 '15 at 08:57