beds runs along a fence: 1 means the bed already holds a shrub, 0 means it is empty. Shrubs in neighbouring beds crowd each other's roots, so no two shrubs may stand side by side, and right now the row respects that.
The gardener has seedlings new plants. Return True if all of them can go into empty beds while keeping the no-neighbours rule, and False otherwise.
The beds at either end have a neighbour on one side only.beds=[0, 0, 1, 0, 0, 0, 0], seedlings=3 → True
Plant in beds 0, 4 and 6: none of them sits next to an occupied bed.
beds=[1, 0, 0, 1, 0], seedlings=1 → False
Beds 1 and 2 both touch an occupied bed, and so does bed 4. There is no room.
beds=[0], seedlings=1 → True
beds never has two 1s in a rowbeds=[0, 0, 1, 0, 0, 0, 0], seedlings=3
True
Run checks the first 3 tests in your browser. Submit checks all 107 tests on the server, hidden ones included.