This is actually a trivially easy question that gets to the heart of whether you understand the point of moving averages or not (that you can update a sum by subtracting out the value leaving the window and adding in the value entering the window).
"Programming ability" isn't one dimensional. Whether or not the above question is useful depend entirely on what skills are important in a candidate.