Probability, linear independence and study of variant of Lights Out

99 Views Asked by At

Using Arduino, some leds and pushbuttons I've created a simple variant of the mathematically popular game "Lights Out". In my variant, the starting configuration is always all lights on; what changes are the led controlled by each button. In pseudocode:

for each button
    for each led
        switch_matrix[button][led] = random(1)

Where random(1) returns 0 with 50% probability, 1 otherwise.
switch_matrix is a N*M matrix, where N is the number of buttons and M the number of LEDs. For example, switch_matrix[j][i] indicates whether by pressing button j the state of LED i is switched.

Using the pseudocode above there is no guarantee the game will be solvable. To address that, a simple naive solution is to generate the matrix, check if solvable (you can see that the solution it's just a matter of which buttons to press and which not. The order doesn't count) and if not, go back to step 1.
While this is feasible with my current configuration (6 LEDs, 4 buttons) it isn't when N << M; and here's my first question:

Given N and M, what's the probability of the game created at random being solvable?

My first try at this question was along the lines of "the buttons generate a $\mathbb Z_2^N$ space, the LEDs are a $\mathbb Z^M_2$ one, the probability of a random $\mathbb Z^N_2$ space covering a point in $\mathbb Z^M_2$ is $2^{N-M}$"
This doesn't work for various reason, one of which is that the buttons generate a $\mathbb Z_2^N$ space only when they (= their rows on the switch_matrix) are linearly independent, and that's my second question:

What's the probability of N random $\mathbb Z^M_2$ vectors being linearly independent?

My third and final problem is, if possible, an algorithm which creates solvable switch_matrixs as random as the one created by the "make a new one until solvable" algorithm.

Any additional info on this variant of lights out is welcome. For example I think (had an idea for proof, never really tried to put it in a formal way) the number of solutions is always an even number or 1. Is this correct?