Lights-Out looks deceptively simple: tap a tile, and it flips itself along with its orthogonal neighbors. Turn all the tiles on (or off) to clear the board.

But if you build a 500-stage Lights-Out game with custom board shapes, locked tiles, and diagonal toggle tiles — like Glass Lights on 2Day Games — two hard questions immediately show up:.

The answer is one of the cleanest applications of linear algebra in game development: Gaussian elimination over GF(2).

Every tile press is its own inverse — pressing a tile twice is identical to not pressing it at all (1 + 1 = 0 mod 2), and the order of presses does not matter.

That means an N×N board with M active (unlocked) tiles is simply a linear system over the binary field GF(2):.

Here is the subtle catch many implementations miss: for certain board sizes (famously 5×5 Lights-Out!), the matrix A is not invertible — its nullspace has dimension 2 (4 distinct valid solutions for the same board!).

If you stop at the first solution Gaussian elimination hands you, your Par number might be 11 clicks when a 7-click solution exists!

To compute the exact minimum Par for every stage in Glass Lights:.

That Hamming weight is the mathematically provable minimum Par!

In Glass Lights, every stage from 3×3 warmups up to 6×6 boards with locked cells and diagonal tiles carries its pre-verified Par value, displayed live as Clicks N / Par M right above the board.

Give it a try in your browser and see if you can match (or beat your own record toward) mathematical Par:.

📌 Read also:

→ Read original article