Home License -- for personal use only. Not for government, academic, research, commercial, or other organizational use. 13-May-2025 15:25:32 lights_out_test(): MATLAB/Octave version 9.11.0.2358333 (R2021b) Update 7 lights_out() examines the 5x5 Lights Out game. lo_initialize_random(m,n,k) randomly initializes the board with k lights turned on. Random board with 15 lights illuminated. * * * . * * . . * * * . . * * * . . * * * . . * . lo_initialize_solvable(m,n,push) randomly initializes the board with push = 5 button pushes. Solvable board with 13 lights illuminated * . * * * . * . * . . * * . . * * . * . . * . * . lo_update(L,i,j) updates the board after button (i,j) = (2,3) was pushed. Updated board with 10 lights illuminated * . . * * . . * . . . * . . . * * . * . . * . * . lo_solvability_matrices() returns matrices N1 and N2 which test a board configuration for solvability. Solvability matrix N1 . * * * . * . * . * * * . * * * . * . * . * * * . Solvability matrix N2 * . * . * * . * . * . . . . . * . * . * * . * . * lo_dot() computes the dot product modulo 2 of two board configurations. Dot product of N1 and N2 is 0 Dot product of L1 and N1 is 0 Dot product of L1 and N2 is 0 Dot product of L2 and N1 is 0 Dot product of L2 and N2 is 0 lo_solvable(L) determines whether configuration L is solvable. Test lo_initialize_solvable() configurations Solvable? true Solvable? true Solvable? true Solvable? true Solvable? true Test lo_initialize_random() configurations Solvable? false Solvable? false Solvable? false Solvable? false Solvable? true lo_light_chase(L) pushes buttons to shut off all lights above the bottom row. Initial configuration L0 . . . * . * * . * * . . . . . * * * . * . . . . * Light chasing required 9 button pushes. After light chasing: . . . . . . . . . . . . . . . . . . . . . . . . . lo_light_chase_top(L) examines a Lights Out configuration after the light chase algorithm has been completed. It reports whether the problem is completed, unsolvable, or solvable. For solvable problems, it suggests which buttons to push on the top row, so that restarting the light chase algorithm will solve the problem. Initial configuration L0 * . * . * . * * . . * . . . . * * * * . . * * * * Light chasing required 7 button pushes. After light chasing: . . . . . . . . . . . . . . . . . . . . . * * . * This configuration is solvable. Pushing these buttons in top row: 1 0 0 0 0 Then do a second round of light chasing. After pushing top row buttons: * * . . . * . . . . . . . . . . . . . . . * * . * Light chasing required 8 button pushes. After second round of light chasing: . . . . . . . . . . . . . . . . . . . . . . . . . lo_matrix() returns a 25x25 matrix A which applies a set of button pushes P, creating the corresponding Lights Out configuration AP. Given a configuration AP, we can try to solve A*P=AP to get a set of button pushes creating the configuration. Applying them to a configuration solves the puzzle. The 9x9 submatrix of A: 1 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 The button pushes 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 The configuration after pushing button 7 and 13 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 [Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 4.827057e-19.] [> In lights_out_test (line 235) In run (line 91) ] The button pushes deduced from the configuration The singular system solution may have errors. 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 lights_out_test(): Normal end of execution. 13-May-2025 15:25:32