Cody

# Problem 44752. Lights Out 2 - 5x5, 4 moves

Solution 1743899

Submitted on 6 Mar 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 1 1 1 1 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 0 0 1]; moves = lights_out_2(board); % [2 5 16 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]),2); %remove semicolon to display progress end assert(sum(abs(board(:)))==0) assert(numel(moves)==4)

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test1 (line 6) moves = lights_out_2(board); % [2 5 16 24]

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

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test2 (line 6) moves = lights_out_2(board); % [1 2 3 4]

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

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test3 (line 6) moves = lights_out_2(board); % [7 9 17 19]

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

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test4 (line 6) moves = lights_out_2(board); % [12 13 17 18]

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

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test5 (line 6) moves = lights_out_2(board); % [8 12 14 18]

6   Fail
board = [0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 0 1 0 0 1 1 1 1 0 0]; moves = lights_out_2(board); % on your own now 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)==4)

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test6 (line 6) moves = lights_out_2(board); % on your own now

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

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test7 (line 6) moves = lights_out_2(board);

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

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test8 (line 6) moves = lights_out_2(board);

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

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test9 (line 6) moves = lights_out_2(board);

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

Undefined function 'sum2' for input arguments of type 'logical'. Error in lights_out_2 (line 27) priority=[priority sum2(s==1)]; Error in Test10 (line 6) moves = lights_out_2(board);