Cody

# Problem 44757. Lights Out 6 - 5x5, 13 moves

Solution 1675352

Submitted on 16 Nov 2018
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 = [0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0]; moves = lights_out_6(board); % [1:5 8 13 18 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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test1 (line 6) moves = lights_out_6(board); % [1:5 8 13 18 21:25]

2   Fail
board = [1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0]; moves = lights_out_6(board); % [1:13] 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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test2 (line 6) moves = lights_out_6(board); % [1:13]

3   Fail
board = [1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 1]; moves = lights_out_6(board); % [1:2: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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test3 (line 6) moves = lights_out_6(board); % [1:2:25]

4   Fail
board = [1 1 1 1 0 1 1 0 0 0 1 1 0 1 0 0 1 0 0 1 1 0 1 1 0]; moves = lights_out_6(board); % [1:3 6 8:11 16:19 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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test4 (line 6) moves = lights_out_6(board); % [1:3 6 8:11 16:19 22]

5   Fail
board = [0 1 1 1 0 0 0 1 1 1 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0]; moves = lights_out_6(board); % [1 4 6:9 12:16 19 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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test5 (line 6) moves = lights_out_6(board); % [1 4 6:9 12:16 19 22]

6   Fail
board = [1 0 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 1 0 0 0 1 0 1 1]; moves = lights_out_6(board); % [1 3 9 11 14 16 19 20: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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test6 (line 6) moves = lights_out_6(board); % [1 3 9 11 14 16 19 20:25]

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

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test7 (line 6) moves = lights_out_6(board); % [1:2 4:6 10 13 16 20:22 24:25]

8   Fail
board = [0 0 1 1 1 1 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1 1 1 0 0]; moves = lights_out_6(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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test8 (line 6) moves = lights_out_6(board); % on your own

9   Fail
board = [0 1 1 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 0 1 0 1 1 1 0]; moves = lights_out_6(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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test9 (line 6) moves = lights_out_6(board);

10   Fail
board = [0 0 0 0 0 1 1 0 0 1 0 1 0 1 0 1 0 1 1 1 0 0 0 1 1]; moves = lights_out_6(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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test10 (line 6) moves = lights_out_6(board);

11   Fail
board = [1 0 0 1 1 1 1 0 1 0 1 1 0 1 1 1 1 0 1 1 0 0 0 0 1]; moves = lights_out_6(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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test11 (line 6) moves = lights_out_6(board);

12   Fail
board = [0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 1 1 0 1]; moves = lights_out_6(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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test12 (line 6) moves = lights_out_6(board);

13   Fail
board = [0 1 1 0 0 0 0 0 1 0 0 1 1 0 0 0 1 0 1 1 1 1 1 0 0]; moves = lights_out_6(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)==13)

Undefined function 'lights_out_6' for input arguments of type 'double'. Error in Test13 (line 6) moves = lights_out_6(board);