Classic lights out only toggles the light you press and the 4 lights in the 4 cardinal directions. I was surprised how baked into my brain that was and how much trouble I had getting my brain to adapt.
I had a technical interview just last week wherein I was asked to write a program to determine whether a given lights out board could be solved or not! Hadn't ever seen the game before then.
I wanted to sketch this idea of a puzzle game that I came up with while on a walk. It turned out to roll pretty well though it couldn't be any more minimal.
Simple things are pretty powerful sometimes, don't you think?
Like Lights Out, this game can be solved using Gaussian elimination over Z/2 (integers modulo 2). This means the order of the tiles you press do not matter, and that you can solve the board by forming the desired pattern row by row.
Sorry how does it follow that you can form the pattern row by row? When you write this down as a linear algebra problem you kinda forget about the structure of the board, and the rows of the resulting matrix you apply Gauss elimination to don't correspond to the rows of the game board. So you must have meant something else that I'm missing, but I'm confused how you would solve just the bottom row without touching any others.
where the i-th row is the effect of pressing the i-th tile. Now, we can just solve for x (assuming M is not singular). Re-using our above example, we find
This is a very nice exposition of the strategy, but I still don't see how it answers my more specific question, about whether you can solve the problem row by row (is the grid).
Sorry, it turns that was misunderstanding from my part. It turns out we cannot solve a board row by row without revisiting the previous rows. The board below is a counterexample:
101
010
100
The first and second rows are solved. However we cannot solve the last row without re-doing the first and second rows. The two solutions of this board shows this:
solution #1:
110
100
000
solution #2:
110
110
000
Actually, seeing my mistake made me challenge my assumption that a singular matrix over the reals might not be over integers modulo 2. This is likely wrong too. I don't know much about abstract algebra (and I am not a mathematician). Wikipedia (https://en.wikipedia.org/wiki/Determinant#Square_matrices_ov...) states "the reduction modulo m of the determinant of such a matrix is equal to the determinant of the matrix reduced modulo m."
The move matrix M for all boards of size 3n + 2 appears to be singular. This means these boards may have no solution or a large number of solutions.
FYI, a singular matrix taking values in {0,1} that is singular over R if and only if it is also singular over Z/2, for exactly the reason you provide, that the determinant commutes with modding by 2.
This is interesting but I don't really understand because I've tried doing what you're saying. Maybe a side note: I'm very interested in learning algorithms but they are so inaccessible to me.
Have you taken linear algebra? It gives a structure for solving systems of linear equations and the parent post is noting that the game state is a linear function of which squares you've pressed, when considering the states of a square as either one or zero and doing arithmetic mod 2. So the standard techniques of linear algebra can solve this system, such as Gaussian elimination. However, you still have to write down the large matrix that encodes what each square does (an n x n board will need an n^2 x n^2 matrix which shows how each square affects all the others once pressed). Then you solve that system.
For this particular game there is probably a more intuitive way to directly solve it.
I just created a solver for the 4x4 case, also in google sheets... Who would have though it could handle ~15,000 rows with decent performance!
Works by calculating via formulae the result of any sequence, 6 moves or less. The bit patterns of each individual move are XORed together for each possible combination of moves.
The difference between the current state and the target is calculated, again via XOR, and then looked up in this data sheet via the query functionality, to give the sequence of moves which resulted in that delta bit pattern.
I think it's pretty amazing how good you get in this game once you play it a little more. At first it's simply impossible, but you start to recognize the patterns pretty quickly and you can usually beat the 3x3 ones in less than 10 moves.
You should never have to use more than 9 moves for 3x3. Hitting the same square twice has no net effect, even if the two moves on the same square are separated by other moves.
You can actually knock that down to 8 moves (maybe less?) as the max required for a solution. You never have to press the middle square, since it flips every square, inverting the board. Inversion doesn't bring you closer to the checkered pattern of the chessboard. (An inverted chessboard... is a chessboard!)
There is a lot of math involved in this game and you can quite quickly note some less obvious rules like this one. Maybe there are some very nontrivial, but interesting things out there. I'm not good enough in combinatorics to tell... :D
8 moves are sometimes required. If you have a chessboard 3x3 grid with the middle square the wrong color, you have to flip all squares except the middle.
I think it really depends on the size. Often the 5x5 feels like a breeze, but then 6x6 is a lot tougher. Probably there is some mathematical reason for this related to the divisibility of the grid side length.
Classic lights out only toggles the light you press and the 4 lights in the 4 cardinal directions. I was surprised how baked into my brain that was and how much trouble I had getting my brain to adapt.