Cody

# Problem 44767. Lights Out 13 - 5x5, three stages, x moves

Solution 2068615

Submitted on 24 Dec 2019 by Alexander
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
board = [1 1 0 2 2 1 0 0 0 2 0 0 0 0 0 0 2 2 0 0 2 1 1 2 0]; moves = lights_out_13(board); % [1 1 10 15 21] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 2 moves = 2 2 7 7 moves = 2 2 7 7 17 moves = 2 2 7 7 17 22 moves = 2 2 7 7 17 22 3 moves = 2 2 7 7 17 22 3 8 8 moves = 2 2 7 7 17 22 3 8 8 18 moves = 2 2 7 7 17 22 3 8 8 18 23 23 moves = 2 2 7 7 17 22 3 8 8 18 23 23 4 moves = 2 2 7 7 17 22 3 8 8 18 23 23 4 9 moves = 2 2 7 7 17 22 3 8 8 18 23 23 4 9 19 19 moves = 2 2 7 7 17 22 3 8 8 18 23 23 4 9 19 19 24 24 moves = 2 2 7 7 17 22 3 8 8 18 23 23 4 9 19 19 24 24 15 moves = 2 2 7 7 17 22 3 8 8 18 23 23 4 9 19 19 24 24 15 20

2   Pass
board = [2 2 0 2 2 0 0 2 0 0 2 2 2 2 2 0 0 2 0 0 2 2 0 2 2]; moves = lights_out_13(board); % [6:2:20] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 moves = 2 7 moves = 2 7 17 moves = 2 7 17 22 moves = 2 7 17 22 3 moves = 2 7 17 22 3 8 moves = 2 7 17 22 3 8 13 13 moves = 2 7 17 22 3 8 13 13 18 moves = 2 7 17 22 3 8 13 13 18 23 moves = 2 7 17 22 3 8 13 13 18 23 4 moves = 2 7 17 22 3 8 13 13 18 23 4 9 9 moves = 2 7 17 22 3 8 13 13 18 23 4 9 9 19 19 moves = 2 7 17 22 3 8 13 13 18 23 4 9 9 19 19 24 moves = 2 7 17 22 3 8 13 13 18 23 4 9 9 19 19 24 5 5 moves = 2 7 17 22 3 8 13 13 18 23 4 9 9 19 19 24 5 5 10 10 moves = 2 7 17 22 3 8 13 13 18 23 4 9 9 19 19 24 5 5 10 10 15 moves = 2 7 17 22 3 8 13 13 18 23 4 9 9 19 19 24 5 5 10 10 15 20 20 moves = 2 7 17 22 3 8 13 13 18 23 4 9 9 19 19 24 5 5 10 10 15 20 20 25 25 moves = 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 moves = 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 moves = 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Column 31 3 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 32 3 8 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 33 3 8 13 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 35 3 8 13 18 18 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 37 3 8 13 18 18 9 9 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 38 3 8 13 18 18 9 9 14 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 39 3 8 13 18 18 9 9 14 24 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 41 3 8 13 18 18 9 9 14 24 10 10 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 43 3 8 13 18 18 9 9 14 24 10 10 15 15 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 45 3 8 13 18 18 9 9 14 24 10 10 15 15 20 20 moves = Columns 1 through 30 2 3 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 23 24 25 25 2 7 12 Columns 31 through 47 3 8 13 18 18 9 9 14 24 10 10 15 15 20 20 25 25

3   Pass
board = [1 1 0 2 0 1 0 2 2 2 2 0 0 1 0 1 1 2 2 2 0 1 2 2 0]; moves = lights_out_13(board); % [1 1 4 5 10 17 19] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 2 moves = 2 2 7 7 moves = 2 2 7 7 17 moves = 2 2 7 7 17 3 moves = 2 2 7 7 17 3 8 8 moves = 2 2 7 7 17 3 8 8 13 moves = 2 2 7 7 17 3 8 8 13 4 4 moves = 2 2 7 7 17 3 8 8 13 4 4 5 5 moves = 2 2 7 7 17 3 8 8 13 4 4 5 5 10 moves = 2 2 7 7 17 3 8 8 13 4 4 5 5 10 20 moves = 2 2 7 7 17 3 8 8 13 4 4 5 5 10 20 25 moves = 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 moves = 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 moves = 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 3 3 moves = 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 3 3 8 moves = 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 3 3 8 13 13 moves = 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 3 3 8 13 13 4 4 moves = Columns 1 through 30 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 3 3 8 13 13 4 4 Column 31 19 moves = Columns 1 through 30 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 3 3 8 13 13 4 4 Columns 31 through 33 19 5 5 moves = Columns 1 through 30 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 3 3 8 13 13 4 4 Columns 31 through 35 19 5 5 20 20 moves = Columns 1 through 30 1 1 2 2 3 4 4 5 5 6 6 6 7 7 8 8 10 13 17 20 25 2 7 3 3 8 13 13 4 4 Columns 31 through 37 19 5 5 20 20 25 25

4   Pass
board = [2 1 0 1 2 1 2 2 2 1 0 2 1 2 0 1 2 2 2 1 2 1 0 1 2]; moves = lights_out_13(board); % [1 5 7 9 13 13 17 19 21 25] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 moves = 2 7 7 moves = 2 7 7 17 17 moves = 2 7 7 17 17 22 moves = 2 7 7 17 17 22 3 3 moves = 2 7 7 17 17 22 3 3 8 moves = 2 7 7 17 17 22 3 3 8 18 moves = 2 7 7 17 17 22 3 3 8 18 23 23 moves = 2 7 7 17 17 22 3 3 8 18 23 23 4 4 moves = 2 7 7 17 17 22 3 3 8 18 23 23 4 4 9 9 moves = 2 7 7 17 17 22 3 3 8 18 23 23 4 4 9 9 19 19 moves = 2 7 7 17 17 22 3 3 8 18 23 23 4 4 9 9 19 19 24 24 moves = 2 7 7 17 17 22 3 3 8 18 23 23 4 4 9 9 19 19 24 24 5 5 moves = 2 7 7 17 17 22 3 3 8 18 23 23 4 4 9 9 19 19 24 24 5 5 10 10 moves = 2 7 7 17 17 22 3 3 8 18 23 23 4 4 9 9 19 19 24 24 5 5 10 10 20 20 moves = 2 7 7 17 17 22 3 3 8 18 23 23 4 4 9 9 19 19 24 24 5 5 10 10 20 20 25 25 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 34 24 25 25 2 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 35 24 25 25 2 7 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 37 24 25 25 2 7 3 3 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 38 24 25 25 2 7 3 3 8 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 40 24 25 25 2 7 3 3 8 13 13 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 42 24 25 25 2 7 3 3 8 13 13 4 4 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 43 24 25 25 2 7 3 3 8 13 13 4 4 19 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 45 24 25 25 2 7 3 3 8 13 13 4 4 19 5 5 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 47 24 25 25 2 7 3 3 8 13 13 4 4 19 5 5 20 20 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 7 8 9 9 10 10 17 17 18 19 19 20 20 22 23 23 24 Columns 31 through 49 24 25 25 2 7 3 3 8 13 13 4 4 19 5 5 20 20 25 25

5   Pass
board = [2 0 2 0 0 1 1 1 0 0 1 0 1 0 0 1 1 1 0 0 2 0 2 0 0]; moves = lights_out_13(board); % [6:10 7:9] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 moves = 2 12 moves = 2 12 3 moves = 2 12 3 13 moves = 2 12 3 13 18 18 moves = 2 12 3 13 18 18 9 moves = 2 12 3 13 18 18 9 14 moves = 2 12 3 13 18 18 9 14 24 moves = 2 12 3 13 18 18 9 14 24 15 15 moves = 2 12 3 13 18 18 9 14 24 15 15 20 20 moves = 2 12 3 13 18 18 9 14 24 15 15 20 20 25 25 moves = 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 moves = 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 moves = 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 moves = 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 moves = 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 moves = 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 moves = 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 moves = 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 9 moves = Columns 1 through 30 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 9 Columns 31 through 32 14 14 moves = Columns 1 through 30 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 9 Columns 31 through 34 14 14 24 24 moves = Columns 1 through 30 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 9 Columns 31 through 35 14 14 24 24 10 moves = Columns 1 through 30 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 9 Columns 31 through 36 14 14 24 24 10 15 moves = Columns 1 through 30 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 9 Columns 31 through 37 14 14 24 24 10 15 20 moves = Columns 1 through 30 2 3 6 9 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 9 Columns 31 through 38 14 14 24 24 10 15 20 25

6   Pass
board = [2 0 2 0 2 2 2 1 2 2 2 2 1 2 2 2 2 1 2 2 2 0 2 0 2]; moves = lights_out_13(board); % [6:20] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 moves = 2 12 moves = 2 12 22 moves = 2 12 22 8 8 moves = 2 12 22 8 8 13 moves = 2 12 22 8 8 13 18 18 moves = 2 12 22 8 8 13 18 18 4 moves = 2 12 22 8 8 13 18 18 4 9 moves = 2 12 22 8 8 13 18 18 4 9 14 14 moves = 2 12 22 8 8 13 18 18 4 9 14 14 19 moves = 2 12 22 8 8 13 18 18 4 9 14 14 19 24 moves = 2 12 22 8 8 13 18 18 4 9 14 14 19 24 5 5 moves = 2 12 22 8 8 13 18 18 4 9 14 14 19 24 5 5 10 moves = 2 12 22 8 8 13 18 18 4 9 14 14 19 24 5 5 10 20 moves = 2 12 22 8 8 13 18 18 4 9 14 14 19 24 5 5 10 20 25 25 moves = 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 moves = 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 moves = 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Column 31 8 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 33 8 18 18 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 35 8 18 18 4 4 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 37 8 18 18 4 4 9 9 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 38 8 18 18 4 4 9 9 14 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 39 8 18 18 4 4 9 9 14 19 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 40 8 18 18 4 4 9 9 14 19 24 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 42 8 18 18 4 4 9 9 14 19 24 5 5 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 44 8 18 18 4 4 9 9 14 19 24 5 5 10 10 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 46 8 18 18 4 4 9 9 14 19 24 5 5 10 10 15 15 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 47 8 18 18 4 4 9 9 14 19 24 5 5 10 10 15 15 20 moves = Columns 1 through 30 1 1 2 4 5 5 6 6 8 8 9 10 12 13 14 14 18 18 19 20 22 24 25 25 2 2 7 7 12 8 Columns 31 through 48 8 18 18 4 4 9 9 14 19 24 5 5 10 10 15 15 20 25

7   Pass
board = [1 1 2 1 0 0 1 2 1 2 2 2 2 2 2 2 1 1 1 2 2 2 0 2 0]; moves = lights_out_13(board); % [2 2 5 7:8 8 11 13 17:19] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 2 moves = 2 2 7 7 moves = 2 2 7 7 12 moves = 2 2 7 7 12 17 17 moves = 2 2 7 7 12 17 17 3 3 moves = 2 2 7 7 12 17 17 3 3 13 13 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 23 23 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 23 23 9 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 23 23 9 14 14 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 23 23 9 14 14 19 19 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 23 23 9 14 14 19 19 5 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 23 23 9 14 14 19 19 5 10 10 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 23 23 9 14 14 19 19 5 10 10 15 moves = 2 2 7 7 12 17 17 3 3 13 13 18 18 23 23 9 14 14 19 19 5 10 10 15 20 20 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 32 23 2 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 33 23 2 7 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 35 23 2 7 3 3 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 36 23 2 7 3 3 8 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 38 23 2 7 3 3 8 13 13 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 40 23 2 7 3 3 8 13 13 4 4 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 41 23 2 7 3 3 8 13 13 4 4 19 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 43 23 2 7 3 3 8 13 13 4 4 19 5 5 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 45 23 2 7 3 3 8 13 13 4 4 19 5 5 20 20 moves = Columns 1 through 30 1 1 2 2 3 3 5 6 6 6 7 7 9 10 10 12 13 13 14 14 15 17 17 18 18 19 19 20 20 23 Columns 31 through 47 23 2 7 3 3 8 13 13 4 4 19 5 5 20 20 25 25

8   Pass
board = [0 0 0 2 0 0 2 1 2 2 1 2 2 0 1 0 1 2 1 1 2 1 2 2 1]; moves = lights_out_13(board); % [3 3 7 9:11 11 16:18 17 21 21 24 25] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 17 moves = 17 8 moves = 17 8 13 moves = 17 8 13 4 moves = 17 8 13 4 9 9 moves = 17 8 13 4 9 9 14 14 moves = 17 8 13 4 9 9 14 14 19 moves = 17 8 13 4 9 9 14 14 19 24 24 moves = 17 8 13 4 9 9 14 14 19 24 24 10 10 moves = 17 8 13 4 9 9 14 14 19 24 24 10 10 15 moves = 17 8 13 4 9 9 14 14 19 24 24 10 10 15 25 25 moves = 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 moves = 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 moves = 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 moves = 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 moves = 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 moves = 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 moves = 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 moves = Columns 1 through 30 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 Column 31 9 moves = Columns 1 through 30 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 Columns 31 through 33 9 14 14 moves = Columns 1 through 30 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 Columns 31 through 35 9 14 14 24 24 moves = Columns 1 through 30 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 Columns 31 through 36 9 14 14 24 24 10 moves = Columns 1 through 30 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 Columns 31 through 37 9 14 14 24 24 10 15 moves = Columns 1 through 30 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 Columns 31 through 38 9 14 14 24 24 10 15 20 moves = Columns 1 through 30 4 6 8 9 9 10 10 13 14 14 15 17 19 24 24 25 25 2 2 7 7 12 12 3 3 8 8 13 13 18 Columns 31 through 39 9 14 14 24 24 10 15 20 25

9   Pass
board = [0 0 0 0 2 0 2 0 1 2 1 2 0 2 0 2 2 2 0 2 1 2 1 0 2]; moves = lights_out_13(board); % [4 8 10 14 18 22 24] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 22 moves = 22 8 moves = 22 8 18 moves = 22 8 18 4 moves = 22 8 18 4 14 moves = 22 8 18 4 14 24 moves = 22 8 18 4 14 24 10

10   Pass
board = [0 0 0 0 0 0 1 2 1 0 0 2 0 2 0 0 1 2 1 0 0 0 0 0 0]; moves = lights_out_13(board); % on your own b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 8 8 moves = 8 8 13 moves = 8 8 13 18 18 moves = 8 8 13 18 18 4 moves = 8 8 13 18 18 4 9 moves = 8 8 13 18 18 4 9 14 moves = 8 8 13 18 18 4 9 14 19 moves = 8 8 13 18 18 4 9 14 19 24 moves = 8 8 13 18 18 4 9 14 19 24 5 moves = 8 8 13 18 18 4 9 14 19 24 5 25 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 4 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 4 9 9 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 4 9 9 14 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 4 9 9 14 19 19 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 4 9 9 14 19 19 24 moves = 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 4 9 9 14 19 19 24 5 moves = Columns 1 through 30 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 4 9 9 14 19 19 24 5 Columns 31 through 32 10 10 moves = Columns 1 through 30 1 4 5 6 6 8 8 9 13 14 18 18 19 24 25 12 3 3 13 13 18 18 4 9 9 14 19 19 24 5 Columns 31 through 34 10 10 15 15

11   Pass
board = [1 2 0 2 1 2 2 2 2 2 0 2 2 2 0 2 2 2 2 2 1 2 0 2 1]; moves = lights_out_13(board); b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 2 moves = 2 2 7 moves = 2 2 7 17 moves = 2 2 7 17 22 22 moves = 2 2 7 17 22 22 3 moves = 2 2 7 17 22 22 3 8 moves = 2 2 7 17 22 22 3 8 13 13 moves = 2 2 7 17 22 22 3 8 13 13 18 moves = 2 2 7 17 22 22 3 8 13 13 18 23 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 9 9 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 9 9 19 19 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 9 9 19 19 24 24 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 9 9 19 19 24 24 5 5 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 9 9 19 19 24 24 5 5 10 10 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 9 9 19 19 24 24 5 5 10 10 15 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 9 9 19 19 24 24 5 5 10 10 15 20 20 moves = 2 2 7 17 22 22 3 8 13 13 18 23 4 4 9 9 19 19 24 24 5 5 10 10 15 20 20 25 25 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 32 25 2 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 33 25 2 7 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 34 25 2 7 12 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 35 25 2 7 12 3 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 36 25 2 7 12 3 8 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 37 25 2 7 12 3 8 13 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 39 25 2 7 12 3 8 13 18 18 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 41 25 2 7 12 3 8 13 18 18 9 9 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 42 25 2 7 12 3 8 13 18 18 9 9 14 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 43 25 2 7 12 3 8 13 18 18 9 9 14 24 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 45 25 2 7 12 3 8 13 18 18 9 9 14 24 10 10 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 47 25 2 7 12 3 8 13 18 18 9 9 14 24 10 10 15 15 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 49 25 2 7 12 3 8 13 18 18 9 9 14 24 10 10 15 15 20 20 moves = Columns 1 through 30 2 2 3 4 4 5 5 6 6 7 8 9 9 10 10 13 13 15 17 18 19 19 20 20 22 22 23 24 24 25 Columns 31 through 51 25 2 7 12 3 8 13 18 18 9 9 14 24 10 10 15 15 20 20 25 25

12   Pass
board = [1 2 2 2 2 1 1 1 0 0 2 1 1 2 2 1 1 1 0 0 1 2 2 2 2]; moves = lights_out_13(board); b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 2 2 moves = 2 2 7 moves = 2 2 7 12 moves = 2 2 7 12 17 moves = 2 2 7 12 17 22 moves = 2 2 7 12 17 22 3 3 moves = 2 2 7 12 17 22 3 3 8 moves = 2 2 7 12 17 22 3 3 8 13 13 moves = 2 2 7 12 17 22 3 3 8 13 13 23 moves = 2 2 7 12 17 22 3 3 8 13 13 23 4 4 moves = 2 2 7 12 17 22 3 3 8 13 13 23 4 4 9 9 moves = 2 2 7 12 17 22 3 3 8 13 13 23 4 4 9 9 14 moves = 2 2 7 12 17 22 3 3 8 13 13 23 4 4 9 9 14 24 24 moves = 2 2 7 12 17 22 3 3 8 13 13 23 4 4 9 9 14 24 24 5 5 moves = 2 2 7 12 17 22 3 3 8 13 13 23 4 4 9 9 14 24 24 5 5 10 10 moves = 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Column 31 7 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Columns 31 through 32 7 3 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Columns 31 through 34 7 3 8 8 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Columns 31 through 35 7 3 8 8 13 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Columns 31 through 36 7 3 8 8 13 4 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Columns 31 through 38 7 3 8 8 13 4 19 19 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Columns 31 through 39 7 3 8 8 13 4 19 19 5 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Columns 31 through 40 7 3 8 8 13 4 19 19 5 20 moves = Columns 1 through 30 1 2 2 3 3 4 4 5 5 6 6 6 7 8 9 9 10 10 12 13 13 14 17 22 23 24 24 2 2 7 Columns 31 through 41 7 3 8 8 13 4 19 19 5 20 25

13   Pass
board = [0 0 2 0 2 1 1 0 0 2 1 1 0 1 1 0 1 2 2 2 0 2 0 1 0]; moves = lights_out_13(board); b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b3;b2,b1,b2,b3,b3;b3,b2,b1,b2,b3;b3,b3,b2,b1,b2;b3,b3,b3,b2,b1]; for i = 1:numel(moves) board = mod(board + reshape(b_map(moves(i),:),[5,5]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

moves = 12 moves = 12 22 moves = 12 22 3 3 moves = 12 22 3 3 8 moves = 12 22 3 3 8 13 13 moves = 12 22 3 3 8 13 13 18 moves = 12 22 3 3 8 13 13 18 4 4 moves = 12 22 3 3 8 13 13 18 4 4 14 moves = 12 22 3 3 8 13 13 18 4 4 14 19 19 moves = 12 22 3 3 8 13 13 18 4 4 14 19 19 5 5 moves = 12 22 3 3 8 13 13 18 4 4 14 19 19 5 5 10 moves = 12 22 3 3 8 13 13 18 4 4 14 19 19 5 5 10 15 15 moves = 12 22 3 3 8 13 13 18 4 4 14 19 19 5 5 10 15 15 25 25 moves = 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 moves = 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 moves = 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 3 3 moves = 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 3 3 8 moves = Columns 1 through 30 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 3 3 8 Columns 31 through 32 13 13 moves = Columns 1 through 30 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 3 3 8 Columns 31 through 34 13 13 4 4 moves = Columns 1 through 30 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 3 3 8 Columns 31 through 35 13 13 4 4 19 moves = Columns 1 through 30 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 3 3 8 Columns 31 through 37 13 13 4 4 19 5 5 moves = Columns 1 through 30 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 3 3 8 Columns 31 through 39 13 13 4 4 19 5 5 20 20 moves = Columns 1 through 30 1 1 3 3 4 4 5 5 6 6 6 8 10 12 13 13 14 15 15 18 19 19 22 25 25 2 7 3 3 8 Columns 31 through 41 13 13 4 4 19 5 5 20 20 25 25