Cody

Solution 1955871

Submitted on 2 Oct 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 = [0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0]; moves = lights_out_7(board); % [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)

pp = 1 moves = 13

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

pp = 1 pp = 2 pp = 3 moves = 7 13 19

3   Pass
board = [0 1 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 0 1 1 0 1 1 1 0]; moves = lights_out_7(board); % [7:9 12:14 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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 pp = 10 pp = 11 pp = 12 pp = 13 pp = 14 pp = 15 pp = 16 pp = 17 pp = 18 moves = 7 8 9 12 13 14 17 18 19

4   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_7(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)

pp = 1 pp = 2 pp = 3 pp = 4 moves = 7 9 17 19

5   Pass
board = [1 0 0 0 1 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 1 0 0 0 1]; moves = lights_out_7(board); % [1 5 7 9 13 17 19 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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 moves = 7 1 19 25 5 9 13 17 21

6   Pass
board = [0 0 0 0 0 1 0 1 0 1 1 0 1 0 1 1 0 1 0 1 0 0 0 0 0]; moves = lights_out_7(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)

pp = 1 pp = 2 pp = 3 moves = 3 13 23

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

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 moves = 7 17 8 9 18 19

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

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 moves = 19 23 18 21 22 20 24 25

9   Pass
board = [1 1 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1]; moves = lights_out_7(board); % [1:6 10:11 15:16 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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 moves = 3 23 6 16 12 10 14 20

10   Pass
board = [1 1 0 1 1 1 1 0 1 1 0 0 0 0 0 1 1 0 1 1 1 1 0 1 1]; moves = lights_out_7(board); % [1:2 4:7 9:10 16:17 19: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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 pp = 10 pp = 11 pp = 12 pp = 13 pp = 14 pp = 15 pp = 16 moves = 1 5 17 19 12 16 14 20 11 6 1 7 15 9 10 5

11   Pass
board = [1 1 1 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 0 1 0 0 0]; moves = lights_out_7(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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 moves = 7 3 8 5 4 2 6 1

12   Pass
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_7(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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 pp = 10 pp = 11 moves = 13 2 6 4 10 21 20 24 16 22 21

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

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 moves = 4 10 16 22 1 7 13 19 25

14   Pass
board = [0 0 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1]; moves = lights_out_7(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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 pp = 10 pp = 11 moves = 17 3 16 12 11 20 15 9 8 2 1

15   Pass
board = [1 1 1 0 0 0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 1 1 0 1 0]; moves = lights_out_7(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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 pp = 10 pp = 11 pp = 12 pp = 13 moves = 10 15 9 6 12 16 22 23 17 3 7 2 1

16   Pass
board = [1 1 1 1 1 1 0 0 0 1 1 0 1 0 1 1 0 0 0 1 1 1 1 1 1]; moves = lights_out_7(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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 pp = 10 pp = 11 moves = 1 10 20 14 16 23 3 13 12 6 1

17   Pass
board = [1 1 1 0 0 0 0 1 0 1 1 0 1 0 1 0 1 1 0 0 0 1 0 0 1]; moves = lights_out_7(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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 pp = 10 pp = 11 moves = 2 7 13 23 25 15 14 18 17 16 22

18   Pass
board = [0 0 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 1]; moves = lights_out_7(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)

pp = 1 pp = 2 pp = 3 pp = 4 pp = 5 pp = 6 pp = 7 pp = 8 pp = 9 pp = 10 moves = 17 18 19 23 16 21 22 20 24 25