A continuation of Inverse Deltas of an Array
Your task is to take an array of signed 32 bit integers, recompile it with its deltas reversed.
Example
The List,
18 19 17 20 16
has the deltas:
1 -2 3 -4
which, when reversed, yields:
-4 3 -2 1
then when recompiled, using yields:
18 14 17 15 16
which should be your return value.
Recompiling consists of taking the C
, which is the first value of the array. In this case, 18
, and applying the deltas to it in order.
So 18 + -4
gives 14
, 14 + 3
gives 17
, and so on.
Input/Output
You will be given a list/array/table/tuple/stack/etc. of signed integers as input through any standard input method.
You must output the modified data once again in any acceptable form, following the above delta reversing method.
You will receive N inputs where 0 < N < 10
where each number falls within the range -1000 < X < 1000
Test Cases
1 2 3 4 5 -> 1 2 3 4 5
18 19 17 20 16 -> 18 14 17 15 16
5 9 1 3 8 7 8 -> 5 6 5 10 12 4 8
6 5 4 1 2 3 -> 6 7 8 5 4 3
Notes
- As stated in above, you will always receive at least 1 input, and no more than 9.
- The first and last number of your output, will always match that of the input.
- Only Standard Input Output is accepted
- Standard loopholes apply
- This is code-golf, so the lowest byte-count wins!
- Have fun!
And the winner is...
Dennis! Who firstly took the first place, then beat himself with a shorter solution, giving himself both the first and second place!
Honorable mention to ais523 with their Jelly, that if not for Dennis getting in just before them, would have held the second place.