# Will the length of a minimum average slice of a numeric array ever be greater than 3? [closed]

Within a sequence of random numbers, is it theoretically possible for a slice of 4 adjacent numbers to be smaller than the average of any slice of 2 or 3 adjacent numbers?

This question is based on a programming exercise called MinAvgTwoSlice. According to the scoring engine, the answer is no (that is to say, my solutions achieve 100% by assuming the answer is no). But what is the theoretical proof?

Let $a, b, c, d$ be the four consecutive numbers in the sequence. Then their average is $$\frac{a+b+c+d}4 = \frac{\frac{a+b}2 + \frac{c+d}2}{2}$$ In other words, the average of the four numbers is equal to the average of $\frac{a+b}2$ and $\frac{c+d}2$. An average can't be lower than the lowest of any of its entries, so at least one of the two two-slice averages must be equal to or less than the four-slice average.
For three-slice it's not true, and a four-slice can have lower average than any three-slice. For instance, take the sequence $$0,1,1,0,1,1,0,1,1,\ldots$$ Similarily, the sequence $$0,1,0,1,0,1,\ldots$$ shows that there can be three-slices with lower average than any two-slice.