Cody

# Problem 44753. Lights Out 3 - 5x5, 6 moves

Solution 1853283

Submitted on 19 Jun 2019
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   Fail
board = [1 0 1 0 1 1 0 1 0 1 0 0 0 0 0 1 0 1 0 1 1 0 1 0 1]; moves = lights_out_3(board); % [1 5 11 15 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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

ans = 10 12 24 26 38 40 moves = 2 4 12 14 22 24 moves = 16 30 ans = 16 18 20 30 32 34 moves = 6 8 10 16 18 20 moves = 16 30 ans = 16 18 20 30 32 34 moves = 6 8 10 16 18 20 ans = 10 12 24 26 38 40 moves = 2 4 12 14 22 24

Assertion failed.

2   Fail
board = [0 0 1 0 0 0 0 1 1 0 1 1 0 1 1 0 1 1 0 0 0 0 1 0 0]; moves = lights_out_3(board); % [4 9 10 16 17 22] 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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

moves = 30 ans = 12 19 20 30 31 38 moves = 4 9 10 16 17 22 moves = 16 ans = 10 16 17 33 34 40 moves = 2 6 7 19 20 24 moves = 16 ans = 10 16 17 33 34 40 moves = 2 6 7 19 20 24 moves = 30 ans = 12 19 20 30 31 38 moves = 4 9 10 16 17 22

Assertion failed.

3   Fail
board = [0 1 0 1 0 1 0 0 0 1 1 1 0 1 1 1 0 0 0 1 0 1 0 1 0]; moves = lights_out_3(board); % [7 8 9 17 18 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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

ans = 17 18 19 31 32 33 moves = 7 8 9 17 18 19 ans = 17 19 24 26 31 33 moves = 7 9 12 14 17 19 ans = 17 19 24 26 31 33 moves = 7 9 12 14 17 19 ans = 17 18 19 31 32 33 moves = 7 8 9 17 18 19

Assertion failed.

4   Fail
board = [0 1 1 0 1 0 1 1 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0]; moves = lights_out_3(board); % [4 8 11 13 17 22] 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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

moves = 16 30 ans = 10 11 16 20 24 25 26 27 30 31 32 34 39 40 moves = 4 8 11 13 17 22 moves = 16 ans = 11 16 17 25 26 34 moves = 3 6 7 13 14 20 moves = 16 ans = 16 24 25 33 34 39 moves = 6 12 13 19 20 23 ans = 12 19 25 27 32 38 moves = 4 9 13 15 18 22

Assertion failed.

5   Fail
board = [0 1 1 1 1 1 1 0 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0]; moves = lights_out_3(board); % [7 8 12 14 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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

moves = 37 ans = 17 18 24 26 27 37 moves = 7 8 12 14 15 21 moves = 16 30 37 ans = 11 13 16 19 20 26 30 34 37 41 moves = 3 5 6 9 10 14 16 20 21 25 ans = 11 18 24 31 32 41 moves = 3 8 12 17 18 25 moves = 16 30 ans = 10 11 12 13 16 18 20 27 30 33 34 38 39 40 moves = 5 11 12 14 18 19

Assertion failed.

6   Fail
board = [0 0 0 1 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 0]; moves = lights_out_3(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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

moves = 30 ans = 12 18 19 20 24 25 26 27 30 32 34 38 39 40 moves = 2 3 6 9 11 13 ans = 11 12 20 25 27 33 moves = 3 4 10 13 15 19 moves = 16 ans = 10 11 12 16 17 18 20 24 25 26 27 32 34 40 moves = 7 11 13 16 22 23 ans = 25 27 31 34 39 40 moves = 13 15 17 20 23 24

Assertion failed.

7   Fail
board = [0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 0]; moves = lights_out_3(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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

ans = 11 12 17 19 33 39 moves = 3 4 7 9 19 23 moves = 16 30 ans = 10 11 12 16 18 19 20 24 26 30 31 32 33 38 39 40 moves = 9 11 15 17 19 20 moves = 30 ans = 10 11 12 17 18 19 20 24 26 30 31 32 34 38 39 40 moves = 6 7 9 11 15 17 ans = 11 17 31 33 38 39 moves = 3 7 17 19 22 23

Assertion failed.

8   Fail
board = [0 0 0 0 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 1 0 1 0 0]; moves = lights_out_3(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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

ans = 11 13 19 26 32 39 moves = 3 5 9 14 18 23 moves = 16 30 ans = 10 11 12 16 18 20 26 30 33 34 38 39 40 41 moves = 11 12 15 18 19 25 moves = 37 ans = 10 12 13 17 18 24 37 38 40 41 moves = 1 7 8 11 14 15 moves = 37 ans = 11 18 24 31 37 39 moves = 3 8 12 17 21 23

Assertion failed.

9   Fail
board = [0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 1 0 0]; moves = lights_out_3(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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

moves = 37 ans = 13 20 26 32 34 37 39 41 moves = 5 10 14 18 20 21 23 25 ans = 10 12 13 26 27 32 moves = 2 4 5 14 15 18 moves = 16 30 37 ans = 10 11 12 16 20 26 27 30 32 34 37 39 moves = 8 11 12 21 22 24 ans = 20 24 32 34 39 41 moves = 10 12 18 20 23 25

Assertion failed.

10   Fail
board = [0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 1 0 0]; moves = lights_out_3(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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

moves = 16 ans = 10 11 12 13 16 20 moves = 2 3 4 5 6 10 ans = 12 20 27 34 40 41 moves = 4 10 15 20 24 25 moves = 16 30 37 ans = 12 13 16 24 26 27 30 37 40 41 moves = 1 2 6 11 16 22 moves = 30 37 ans = 30 34 37 38 39 40 moves = 16 20 21 22 23 24

Assertion failed.

11   Fail
board = [0 1 1 1 0 0 1 1 1 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0]; moves = lights_out_3(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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

moves = 16 30 ans = 10 11 12 16 19 20 24 27 30 34 38 40 moves = 8 9 11 14 18 23 moves = 16 30 ans = 10 12 16 18 20 27 30 33 34 38 39 40 moves = 3 11 12 14 18 19 ans = 17 18 24 26 27 39 moves = 7 8 12 14 15 23 ans = 11 18 24 27 31 32 moves = 3 8 12 15 17 18

Assertion failed.

12   Fail
board = [0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0]; moves = lights_out_3(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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==6)

moves = 30 37 ans = 11 13 18 20 24 30 34 37 39 40 moves = 3 5 8 10 12 16 20 21 23 24 moves = 30 37 ans = 12 13 18 24 30 37 moves = 4 5 8 12 16 21 moves = 37 ans = 13 20 26 32 37 38 moves = 5 10 14 18 21 22 moves = 16 30 37 ans = 10 11 13 16 20 26 30 32 37 39 moves = 2 3 5 6 10 14 16 18 21 23

Assertion failed.