def window(seq, size, step=1):
    """Yields the moving window of size `size` with step size `step`
    over the sequence `seq`

    >>> seq = list(range(10))
    >>> list(window(seq, 5, 2))
    [[0, 1, 2, 3, 4], [2, 3, 4, 5, 6], [4, 5, 6, 7, 8]]
    """
    nchuncks = (len(seq) - size) // step + 1
    for i in range(0, nchuncks * step, step):
        yield seq[i:i + size]
