Test  Status  Code Input and Output 

1  Fail 
board = [1 0 1 0 1
1 0 1 0 1
0 0 0 0 0
1 0 1 0 1
1 0 1 0 1];
moves = lights_out_3(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)
assert(numel(moves)==6)

2  Fail 
board = [0 0 1 0 0
0 0 1 1 0
1 1 0 1 1
0 1 1 0 0
0 0 1 0 0];
moves = lights_out_3(board); % [4 9 10 16 17 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)==6)

3  Fail 
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_3(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)
assert(numel(moves)==6)

4  Fail 
board = [0 1 1 0 1
0 1 1 0 0
0 0 0 0 1
1 0 1 0 0
1 0 0 0 0];
moves = lights_out_3(board); % [4 8 11 13 17 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)==6)

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

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

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

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

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

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

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

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

3075 Solvers
785 Solvers
54 Solvers
1097 Solvers
Calculate Amount of Cake Frosting
7529 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!