title: Finding integer pattern from a list
body: <p>I have a list of numbers, for example:</p>
  
  <pre><code>list= [1, 2, 4, 1, 2, 4, 1, 2, 4]
  </code></pre>
  
  <p>You can see the obvious repeating pattern of 1,2,4</p>
  
  <p>I'm trying to find a way to go through that list to determine the cycle and it's length. The numbers vary every time in my program. So for example, the list that I give, I want it to output 3, which is the length of the pattern. </p>
  
  <p>I tried comparing the items together, but ultimately couldn't figure out a way to do it efficiently without going out of the list index every time, because I was just looking for when a number repeated in the sequence. The problem with that was that the pattern could be something like 2 2 1, in which case i would have outputted 2 as the pattern length, when it was actually 3. </p>
  
  <p>Sorry for the lack of information, I'm lost as to how to do this so I don't have much sample code to show.</p>