Suppose you have built a system of equations and solved them as best as possible, but some series turned out to have all 0 on the left side of the equation (I present the equations as an extended matrix) Suppose you tried to solve a system in the ring Z2 (which in the practical sense for this specific example means that the only change is that 1 + 1 = 0, otherwise everything remains unchanged ... ergo we only need the XOR operator) and as a result we get the following matrix:
1001 1 0100 1 0011 0 0000 0
As you can see in this example, the 4th line is all 0, which means that we have no answer. However, think of it this way: a line of only 0 means that this variable does not affect the decision. This is actually a poor choice of words ... it just means that they can be of any value (and we are lucky here, because all values mean 1 or 0, unlike real numbers ... Thus, this means that we have 2 solutions for this system).
Here's why: what you need to know at this point is that the rightmost column still contains the right solution for your game. For example, take the first row. It says that
button_0 + button_3 = 1
but we know that button 3 can be any (since line 3 is all 0s). At this point, button 3 is 0 (the rightmost column in row 3 is 0 at this point), so now we know what that means
button_0 + 0 = 1
therefore, we know that button_0 is 1. Therefore, in this system, although we could not directly recognize button_3, we still have a valid solution.
The above matrix is sufficient to verify solvability. If the string contains all 0s, then essentially they say that
nothing = nothing
or to better understand why this works,
0x = 0
which makes sense, the system remains valid. If, however, we encounter a string that is equal to all 0 except the rightmost bit, that is
0000 1
who will speak
0x = 1
which is impossible, therefore we now know that the system cannot be solved, since we cannot solve such an impossible situation.
Therefore, in a nutshell, try and solve the equation as best as possible, don’t worry if you can’t find out exactly what some of the variables, until you encounter, at any moment, the impossible line that I just mentioned, then the game is solvable.
But what if we want the shortest solution for the system? Here we look at all the possible solutions. We have button_3, which can be any value, so this means that any 1 in column 3 means that the row in which it is found depends on button_3. Therefore, suppose we want to check if the solution using button_3 is shorter. We create another matrix, but now set button_3 to 1 (since we previously determined that it could be anything, and we already had 0, so now we check 1). Now we get the following matrix:
1001 1 0100 1 0011 0 0001 1
We reduce this as much as we can, and now we get this matrix:
1000 0 0100 1 0010 1 0001 1
This is still a valid solution, however, we see that the solution is longer (it takes 3 instead of two button presses), so we discard it. We must do this for each permutation to set the lines we found, like all 0s to 1. Therefore, if we have x lines that were all 0s, then the system has x ^ 2 solutions, and we need to check them all.