Premium problem75. Sliding Window Average

Hard Locked

Compute the moving average of vector Z over a sliding window of size n. Return a vector of length len(Z) - n + 1.

Input

Z = [ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19]
n = 3

Output

[ 1.  2.  3.  4.  5.  6.  7.  8.  9. 10. 11. 12. 13. 14. 15. 16. 17. 18.]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)