All problems

The 3-Day Moving Average

mediumPythonTime SeriesLists

Meridian Coffee's daily cup counts jump around too much to read: a wet Tuesday and a sunny Saturday between them say nothing about how the shop is doing. The manager wants the run smoothed, with each day replaced by the average of the three days ending on it, so that one odd day can no longer swing the line.

Task: Print the smoothed series.

Input

The first line holds an integer n, the number of days, always at least 3. Each of the next n lines holds one day's cup count.

Output

One line per complete three-day stretch, each an average with exactly two digits after the decimal point. Days 1 and 2 have no full stretch behind them and produce nothing at all, so the output is two lines shorter than the input and its first line covers days 1 to 3.

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…