Cody

Solution 1952396

Submitted on 29 Sep 2019 by Augusto Mazzei
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 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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1393 ------------------ pp = 4 ans = 1602 ------------------ ans = logical 1 moves = 2 16 24 5

2   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1278 ------------------ pp = 4 ans = 1658 ------------------ ans = logical 1 moves = 3 4 2 1

3   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1434 ------------------ pp = 4 ans = 1548 ------------------ ans = logical 1 moves = 7 9 17 19

4   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1321 ------------------ pp = 4 ans = 1723 ------------------ ans = logical 1 moves = 12 13 17 18

5   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1566 ------------------ pp = 4 ans = 1849 ------------------ ans = logical 1 moves = 8 12 14 18

6   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1394 ------------------ pp = 4 ans = 1496 ------------------ ans = logical 1 moves = 10 23 11 16

7   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1385 ------------------ pp = 4 ans = 1707 ------------------ ans = logical 1 moves = 19 3 9 15

8   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1424 ------------------ pp = 4 ans = 1746 ------------------ ans = logical 1 moves = 19 13 7 2

9   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1450 ------------------ pp = 4 ans = 1619 ------------------ ans = logical 1 moves = 9 10 12 11

10   Pass
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)

pp = 1 ans = 25 ------------------ pp = 2 ans = 300 ------------------ pp = 3 ans = 1398 ------------------ pp = 4 ans = 1770 ------------------ ans = logical 1 moves = 19 13 12 6