Cody

Solution 1996115

Submitted on 30 Oct 2019 by cokakola
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 1 0 2 2 1 0 0 0 2 0 0 0 0 0 0 2 2 0 0 2 1 1 2 0]; moves = lights_out_13(board); % [1 1 10 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]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

2   Pass
board = [2 2 0 2 2 0 0 2 0 0 2 2 2 2 2 0 0 2 0 0 2 2 0 2 2]; moves = lights_out_13(board); % [6:2:20] 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]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

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

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

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

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

7   Pass
board = [1 1 2 1 0 0 1 2 1 2 2 2 2 2 2 2 1 1 1 2 2 2 0 2 0]; moves = lights_out_13(board); % [2 2 5 7:8 8 11 13 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]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

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

9   Pass
board = [0 0 0 0 2 0 2 0 1 2 1 2 0 2 0 2 2 2 0 2 1 2 1 0 2]; moves = lights_out_13(board); % [4 8 10 14 18 22 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]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

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

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

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

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

Suggested Problems

More from this Author139