All problems

Smoothing a Noisy Line With a Moving Average

hardPythonMatplotlibSmoothing

Daily figures from a shop jump around so much that the underlying direction is hard to see, so the chart shows the raw line faintly and a calmer line drawn on top of it. Each point of the calmer line is the average of three neighbouring days: the first covers days one to three, the next covers days two to four, and so on, stepping one day at a time. Days at the very start and end never sit in the middle of a full group of three, so the calmer line is shorter than the raw one. The row of figures printed under the chart is what is checked here.

Task: Print the smoothed values.

Input

The first line holds an integer n, the number of days, which is at least 3. Each of the next n lines holds one day's figure, in day order.

Output

One line holding the smoothed values separated by single spaces, in day order, each written with exactly two decimal places. There are n - 2 of them.

Example:

Input:
5
10
20
30
40
50

Output:
20.00 30.00 40.00

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…