values and a number radius. For each position i, take the window of elements with indices from i - radius to i + radius inclusive and compute their average using integer division (the fractional part is dropped).
If the window runs past either end of the array, record -1 for position i. Return an array of len(values) such numbers.values=[4, 0, 8, 2, 5], radius=1 → [-1, 4, 3, 5, -1]
Position 1: (4 + 0 + 8) / 3 = 4; position 2: (0 + 8 + 2) / 3 = 3 after dropping the fraction; position 3: (8 + 2 + 5) / 3 = 5. The end positions lack a neighbour, so they get -1.
values=[6, 3], radius=0 → [6, 3]
With radius 0 the window is just the element itself.
values=[1, 2, 3], radius=2 → [-1, -1, -1]
values=[4, 0, 8, 2, 5], radius=1
[-1, 4, 3, 5, -1]
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.