
Garland

You are given a sequence lights, where each integer is a distinct light with its brightness. This value determines how many adjacent positions to both left and right the illumination from that light reaches, in addition to illuminating the position of that light itself. (A light whose brightness is zero will therefore illuminate only itself, but doesn’t have anything to shine on its neighbors).
Your task is to turn on as few individual lights as possible so that every position of the entire row is illuminated by at least one light. Since the smallest working subset of lights is not necessarily unique, your function should only return the number of lights needed to illuminate the entire row.
Input: Array of integers (number).
Output: Integer (number).
Examples:
assert.strictEqual(illuminateAll([0, 0]), 2); assert.strictEqual(illuminateAll([2, 3, 3, 2]), 1); assert.strictEqual(illuminateAll([1, 0, 1, 0]), 2);
The mission was taken from Python CCPS 109. It is taught for Ryerson Chang School of Continuing Education by Ilkka Kokkarinen