All problems

Day-Over-Day Change With np.diff

easyPythonNumPynp.diff

Halcyon Bank's research desk publishes a small chart under each stock's closing prices showing the move from one close to the next. What matters to a trader is the step from yesterday to today, not the distance from the start of the week, and a step upward has to read differently from a step downward. The very first close has no day before it, so it contributes no step — the chart is always one bar shorter than the price series.

Task: Print the move from each close to the next one.

Input

The first line holds a single integer n, the number of closing prices; n is at least 2. Each of the next n lines holds one closing price, in date order, which may carry decimals.

Output

One line holding n - 1 moves, in date order, separated by single spaces, each with two digits after the decimal point. A rise is positive; a fall carries a leading minus sign.

Example:

Input:
4
100
105
102
110

Output:
5.00 -3.00 8.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…