Your task today is to apply a wave to an array of numbers. A wave looks like this: [1, 0, -1, 0, 1, 0, -1, 0, 1...]
Applying it to a given array means adding together the first elements, the second elements, etc.
More precisely:
Your program or function will receive an array of integers. It must print or return an equally sized array with 1
added to the 1st, 5th, 9th, etc. element of the original array, -1
added to the 3rd, 7th, 11th, etc. element of the original array, and the rest of the elements should be left untouched.
The input array is guaranteed to have at least one element.
Test cases:
Input | Output
[0] | [1]
[-1] | [0]
[-4, 3, 0, 1, 7, 9, 8, -2, 11, -88] | [-3, 3, -1, 1, 8, 9, 7, -2, 12, -88]
[0, 0, 0, 0, 0] | [1 ,0 ,-1 ,0 ,1]
[1, 1] | [2, 1]
This is code-golf, shortest code wins!