In computer science, cycle detection is the algorithmic problem of finding a cycle in a sequence of iterated function values.
For any function ƒ, and any initial value x0 in S, the sequence of iterated function values
    x0,x1=f(x0), x2=f(x1), ...,xi=f(x{i-1}),...
may eventually use the same value twice under some assumptions: S finite, f periodic ... etc. So there will be some `i ≠ j` such that `xi = xj`. Once this happens, the sequence must continue by repeating the cycle of values from `xi to xj−1`. Cycle detection is the problem of finding `i` and `j`, given `ƒ` and `x0`. Let `μ` be the smallest index such that the value associated will reappears and `λ` the smallest value such that `xμ = xλ+μ, λ` is the loop length.
Example:
Consider the sequence: 
```
2, 0, 6, 3, 1, 6, 3, 1, 6, 3, 1, ....
```
The cycle in this value sequence is 6, 3, 1.
μ is 2 (first 6)
λ is 3 (length of the sequence or difference between position of consecutive 6).
The goal of this kata is to build a function that will return `[μ,λ]` when given a short sequence. Simple loops will be sufficient. The sequence will be given in the form of an array. All array will be valid sequence associated with deterministic function. It means that the sequence will repeat itself when a value is reached a second time. (So you treat two cases: non repeating [1,2,3,4] and repeating [1,2,1,2], no hybrid cases like [1,2,1,4]). If there is no repetition you should return []. 
This kata is followed by two other cycle detection algorithms: 
Loyd's: http://www.codewars.com/kata/cycle-detection-floyds-tortoise-and-the-hare
Bret's: http://www.codewars.com/kata/cycle-detection-brents-tortoise-and-hare
def cycle(sequence):
    found = {}
    for i, item in enumerate(sequence):
        if item in found:
            return [found[item], i - found[item]]
        found[item] = i
    else:
        return []
def cycle(sequence):
    found = {}
    for i, item in enumerate(sequence):
        if item in found:
            return [found[item], i - found[item]]
        found[item] = i
    else:
        return []