Both come from the system of equations w = a + b + c, x = a + b + d, y = a + c + d, z = b + c + d, all mod 10. These come from each click affecting all cells except the one opposite from it. If you add these equations up you get w + x + y + z = 3(a + b + c + d) (mod 10). The modular inverse of 3 mod 10 is 7, as 3 * 7 = 21 = 1 (mod 10). So, the equation can be rewritten S = 7(w + x + y + z) = a + b + c + d (mod 10). To solve for a, subtract b + c + d from both sides, and since b + c + d is z, a = S - z (mod 10). Similar steps can be applied to b, c, and d. The second method is solving the system using linear algebra method and you multiply by 21 to make the resulting vector all integers since 21 = 1 (mod 10).