Minimizing number of field lamps
Your algorithm is faulty, because it only tries to eliminate redundant lamps in the order in which they were installed.

Consider a 1 × 9 array with 7 initial lamps L0 … L6 at positions 2 … 8.



Your algorithm would first eliminate L0 at position 5, then L1 at position 4.  It would consider L2 and L3 essential.  Then it would eliminate L4 at position 7.  L5 and L6 would be essential.  Total lamps eliminated: three.

An optimal solution would eliminate four lamps at positions 3, 4, 6, 7.