Cody

# Problem 44766. Lights Out 12 - 5x5, three stages, <7 moves

Solution 2068614

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 0 0 1 0 0 0 0 0 0 0 2 0 0 0 2 2 2 0 0 0 2 0]; moves = lights_out_12(board); % [1 1 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 3 moves = 2 2 7 7 3 8 8 moves = 2 2 7 7 3 8 8 13 moves = 2 2 7 7 3 8 8 13 4 moves = 2 2 7 7 3 8 8 13 4 5 moves = 2 2 7 7 3 8 8 13 4 5 20 moves = 2 2 7 7 3 8 8 13 4 5 20 25 moves = 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 moves = 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 moves = 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 3 3 moves = 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 3 3 8 moves = 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 3 3 8 13 13 moves = 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 3 3 8 13 13 4 4 moves = 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 3 3 8 13 13 4 4 19 moves = 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 3 3 8 13 13 4 4 19 5 5 moves = Columns 1 through 30 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 3 3 8 13 13 4 4 19 5 5 20 Column 31 20 moves = Columns 1 through 30 1 1 2 2 3 4 5 6 6 6 7 7 8 8 13 20 25 2 7 3 3 8 13 13 4 4 19 5 5 20 Columns 31 through 33 20 25 25

2   Pass
board = [2 2 0 2 2 2 0 2 0 2 0 2 2 2 0 2 0 2 0 2 2 2 0 2 2]; moves = lights_out_12(board); % [1 5 13 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 moves = 2 7 17 moves = 2 7 17 22 moves = 2 7 17 22 3 3 moves = 2 7 17 22 3 3 8 moves = 2 7 17 22 3 3 8 13 13 moves = 2 7 17 22 3 3 8 13 13 18 moves = 2 7 17 22 3 3 8 13 13 18 23 23 moves = 2 7 17 22 3 3 8 13 13 18 23 23 4 4 moves = 2 7 17 22 3 3 8 13 13 18 23 23 4 4 9 moves = 2 7 17 22 3 3 8 13 13 18 23 23 4 4 9 19 moves = 2 7 17 22 3 3 8 13 13 18 23 23 4 4 9 19 24 24 moves = 2 7 17 22 3 3 8 13 13 18 23 23 4 4 9 19 24 24 5 5 moves = 2 7 17 22 3 3 8 13 13 18 23 23 4 4 9 19 24 24 5 5 10 10 moves = 2 7 17 22 3 3 8 13 13 18 23 23 4 4 9 19 24 24 5 5 10 10 20 20 moves = 2 7 17 22 3 3 8 13 13 18 23 23 4 4 9 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 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 32 25 2 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 33 25 2 7 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 35 25 2 7 3 3 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 36 25 2 7 3 3 8 moves = Columns 1 through 30 1 1 2 3 3 4 4 5 5 6 6 6 7 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 38 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 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 40 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 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 41 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 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 43 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 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 45 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 8 9 10 10 13 13 17 18 19 20 20 22 23 23 24 24 25 Columns 31 through 47 25 2 7 3 3 8 13 13 4 4 19 5 5 20 20 25 25

3   Pass
board = [0 1 0 0 0 1 1 1 0 1 0 1 0 1 1 1 0 0 0 1 1 1 0 0 0]; moves = lights_out_12(board); % [5 5 7 7 23 23] 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 = 7 7 moves = 7 7 23 23 moves = 7 7 23 23 5 5

4   Pass
board = [2 1 2 0 0 2 0 2 0 0 2 0 2 0 0 2 0 2 0 0 2 1 2 0 0]; moves = lights_out_12(board); % [6:10] 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 12 moves = 2 7 7 12 3 moves = 2 7 7 12 3 8 8 moves = 2 7 7 12 3 8 8 13 moves = 2 7 7 12 3 8 8 13 18 18 moves = 2 7 7 12 3 8 8 13 18 18 14 moves = 2 7 7 12 3 8 8 13 18 18 14 24 moves = 2 7 7 12 3 8 8 13 18 18 14 24 15 15 moves = 2 7 7 12 3 8 8 13 18 18 14 24 15 15 20 20 moves = 2 7 7 12 3 8 8 13 18 18 14 24 15 15 20 20 25 25 moves = 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 moves = 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 moves = 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 moves = 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 moves = 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Column 31 13 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Columns 31 through 32 13 18 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Columns 31 through 33 13 18 9 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Columns 31 through 35 13 18 9 14 14 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Columns 31 through 37 13 18 9 14 14 24 24 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Columns 31 through 38 13 18 9 14 14 24 24 10 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Columns 31 through 39 13 18 9 14 14 24 24 10 15 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Columns 31 through 40 13 18 9 14 14 24 24 10 15 20 moves = Columns 1 through 30 2 3 6 7 7 8 8 12 13 14 15 15 18 18 20 20 24 25 25 2 2 7 7 12 12 3 3 8 8 13 Columns 31 through 41 13 18 9 14 14 24 24 10 15 20 25

5   Pass
board = [1 1 0 0 0 2 0 0 0 0 1 1 0 0 0 2 0 0 0 0 1 1 0 0 0]; moves = lights_out_12(board); % [1 1 3 3 5 5] 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 8 8 moves = 2 2 7 7 8 8 13 moves = 2 2 7 7 8 8 13 4 moves = 2 2 7 7 8 8 13 4 19 19 moves = 2 2 7 7 8 8 13 4 19 19 20 moves = 2 2 7 7 8 8 13 4 19 19 20 25 moves = 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 moves = 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 moves = 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 3 3 moves = 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 3 3 8 moves = 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 3 3 8 13 13 moves = 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 3 3 8 13 13 4 4 moves = 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 3 3 8 13 13 4 4 19 moves = 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 3 3 8 13 13 4 4 19 5 5 moves = Columns 1 through 30 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 3 3 8 13 13 4 4 19 5 5 20 Column 31 20 moves = Columns 1 through 30 1 1 2 2 4 6 6 6 7 7 8 8 13 19 19 20 25 2 7 3 3 8 13 13 4 4 19 5 5 20 Columns 31 through 33 20 25 25

6   Pass
board = [0 2 0 2 0 2 2 0 2 2 0 0 2 0 0 2 2 0 2 2 0 2 0 2 0]; moves = lights_out_12(board); % [7 9 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 = 7 moves = 7 17 moves = 7 17 13 moves = 7 17 13 9 moves = 7 17 13 9 19

7   Pass
board = [0 2 0 2 0 2 1 1 1 2 2 0 1 0 2 2 1 1 1 2 0 2 0 2 0]; moves = lights_out_12(board); % [7:9 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 = 7 moves = 7 17 moves = 7 17 8 moves = 7 17 8 18 moves = 7 17 8 18 9 moves = 7 17 8 18 9 19

8   Pass
board = [0 0 0 0 0 0 2 1 2 0 2 0 2 0 2 0 2 1 2 0 0 0 0 0 0]; moves = lights_out_12(board); % [8 13 13 18] 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 moves = 8 13 13 moves = 8 13 13 18

9   Pass
board = [0 1 1 1 0 1 2 0 2 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0]; moves = lights_out_12(board); % [7 7 12 12 17 17] 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 = 7 7 moves = 7 7 12 12 moves = 7 7 12 12 17 17

10   Pass
board = [0 0 0 1 2 0 0 2 2 1 0 1 0 2 2 0 1 1 2 2 2 0 0 0 2]; moves = lights_out_12(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 = 17 17 moves = 17 17 22 moves = 17 17 22 13 13 moves = 17 17 22 13 13 18 moves = 17 17 22 13 13 18 23 23 moves = 17 17 22 13 13 18 23 23 10 10 moves = 17 17 22 13 13 18 23 23 10 10 25 25 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 3 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 3 8 8 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 3 8 8 13 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 3 8 8 13 4 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 3 8 8 13 4 19 19 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 3 8 8 13 4 19 19 5 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 3 8 8 13 4 19 19 5 20 moves = 1 6 6 6 10 10 13 13 17 17 18 22 23 23 25 25 2 2 7 7 3 8 8 13 4 19 19 5 20 25

11   Pass
board = [0 2 1 0 0 2 2 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; moves = lights_out_12(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 = 7 moves = 7 12 12 moves = 7 12 12 8 moves = 7 12 12 8 18 moves = 7 12 12 8 18 4 moves = 7 12 12 8 18 4 9 moves = 7 12 12 8 18 4 9 14 14 moves = 7 12 12 8 18 4 9 14 14 19 19 moves = 7 12 12 8 18 4 9 14 14 19 19 24 24 moves = 7 12 12 8 18 4 9 14 14 19 19 24 24 5 moves = 7 12 12 8 18 4 9 14 14 19 19 24 24 5 10 moves = 7 12 12 8 18 4 9 14 14 19 19 24 24 5 10 15 moves = 7 12 12 8 18 4 9 14 14 19 19 24 24 5 10 15 20 20 moves = 7 12 12 8 18 4 9 14 14 19 19 24 24 5 10 15 20 20 25 25 moves = 1 1 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 24 25 25 2 2 moves = 1 1 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 24 25 25 2 2 7 7 moves = 1 1 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 24 25 25 2 2 7 7 12 moves = Columns 1 through 30 1 1 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 24 25 25 2 2 7 7 12 8 Column 31 8 moves = Columns 1 through 30 1 1 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 24 25 25 2 2 7 7 12 8 Columns 31 through 33 8 18 18 moves = Columns 1 through 30 1 1 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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 4 5 6 6 7 8 9 10 12 12 14 14 15 18 19 19 20 20 24 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

12   Pass
board = [1 1 1 0 0 0 0 0 0 0 2 1 1 0 0 2 0 0 2 0 0 1 1 2 0]; moves = lights_out_12(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 7 moves = 2 2 7 7 12 12 moves = 2 2 7 7 12 12 3 3 moves = 2 2 7 7 12 12 3 3 13 13 moves = 2 2 7 7 12 12 3 3 13 13 18 moves = 2 2 7 7 12 12 3 3 13 13 18 9 9 moves = 2 2 7 7 12 12 3 3 13 13 18 9 9 24 24 moves = 2 2 7 7 12 12 3 3 13 13 18 9 9 24 24 10 moves = 2 2 7 7 12 12 3 3 13 13 18 9 9 24 24 10 15 15 moves = 2 2 7 7 12 12 3 3 13 13 18 9 9 24 24 10 15 15 20 moves = 2 2 7 7 12 12 3 3 13 13 18 9 9 24 24 10 15 15 20 25 moves = 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 moves = 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 moves = 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 moves = 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 moves = 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 moves = 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 moves = 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 18 18 moves = Columns 1 through 30 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 18 18 Columns 31 through 32 9 9 moves = Columns 1 through 30 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 18 18 Columns 31 through 33 9 9 14 moves = Columns 1 through 30 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 18 18 Columns 31 through 34 9 9 14 24 moves = Columns 1 through 30 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 18 18 Columns 31 through 36 9 9 14 24 10 10 moves = Columns 1 through 30 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 18 18 Columns 31 through 38 9 9 14 24 10 10 15 15 moves = Columns 1 through 30 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 18 18 Columns 31 through 40 9 9 14 24 10 10 15 15 20 20 moves = Columns 1 through 30 2 2 3 3 6 6 7 7 9 9 10 12 12 13 13 15 15 18 20 24 24 25 2 7 12 3 8 13 18 18 Columns 31 through 42 9 9 14 24 10 10 15 15 20 20 25 25