FunctionRacerProblemsRace

Pair Differences

EasyNumPyPython

arr has an even length and is made of consecutive pairs: items 0 and 1, items 2 and 3, and so on. Return a list with one number per pair: the second item minus the first. Hint: arr.reshape(-1, 2).

Example 1

arr [1,5,10,4]
returns [4,-6]

The pairs are (1, 5) and (10, 4), giving 4 and -6.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems