Test  Status  Code Input and Output 

1  Fail 
board = [0 1 0 0 0
1 1 1 0 1
0 1 0 1 1
1 0 0 0 1
1 1 0 0 0];
moves = lights_out_1(board); %should be [5 7 23]
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)==3)
board =
0 1 0 0 0
1 1 1 0 1
0 1 0 1 1
1 0 0 0 1
1 1 0 0 0
l1 =
1
ans =
2
board =
0 0 0 0 0
0 1 1 0 1
0 1 0 1 1
1 0 0 0 1
1 1 0 0 0
l1 =
1
ans =
2
board =
0 0 0 0 0
0 1 1 0 1
0 1 0 1 1
1 0 0 0 1
1 1 0 0 0
l1 =
1 3
ans =
2
board =
0 0 0 0 0
0 1 1 0 1
0 0 0 1 1
0 0 0 0 1
1 1 0 0 0
l1 =
1 3
ans =
2
board =
0 0 0 0 0
0 1 1 0 1
0 0 0 1 1
0 0 0 0 1
1 1 0 0 0
l1 =
1 3 5
ans =
2
board =
0 0 0 0 0
0 1 1 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5
ans =
2
board =
0 0 0 0 0
0 1 1 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7 17
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7 17
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7 17
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7 17
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7 17
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7 17
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 1
0 0 0 0 0
l1 =
1 3 5 7 17 23
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 3 5 7 17 23
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 3 5 7 17 23
ans =
2

2  Fail 
board = [1 1 0 0 0
1 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1];
moves = lights_out_1(board); %should be [1 13 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)==3)
board =
1 1 0 0 0
1 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 1 0 0
0 1 1 1 0
0 0 1 0 1
0 0 0 1 1
l1 =
1
ans =
3
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 1 1
l1 =
13
ans =
5

3  Fail 
board = [1 0 0 0 0
0 1 0 0 0
1 1 0 0 0
0 1 0 0 0
1 0 0 0 0];
moves = lights_out_1(board); %should be [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)==3)
board =
1 0 0 0 0
0 1 0 0 0
1 1 0 0 0
0 1 0 0 0
1 0 0 0 0
l1 =
1
ans =
1
board =
0 0 0 0 0
0 1 0 0 0
1 1 0 0 0
0 1 0 0 0
1 0 0 0 0
l1 =
2
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 1 0 0 0
1 0 0 0 0
l1 =
2
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 1 0 0 0
1 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2
board =
0 0 0 0 0
0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
2 4
ans =
2

4  Fail 
board = [0 1 1 1 0
1 0 1 0 1
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0];
moves = lights_out_1(board); %should be [7 12 17]
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)==3)
board =
0 1 1 1 0
1 0 1 0 1
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1
ans =
2
board =
0 0 1 1 0
0 0 1 0 1
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1
ans =
2
board =
0 0 1 1 0
0 0 1 0 1
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1
ans =
2
board =
0 0 1 1 0
0 0 1 0 1
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1
ans =
2
board =
0 0 1 1 0
0 0 1 0 1
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1
ans =
2
board =
0 0 1 1 0
0 0 1 0 1
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1
ans =
2
board =
0 0 1 1 0
0 0 1 0 1
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7
ans =
2
board =
0 0 1 1 0
0 0 0 0 1
0 0 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7
ans =
2
board =
0 0 1 1 0
0 0 0 0 1
0 0 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7
ans =
2
board =
0 0 1 1 0
0 0 0 0 1
0 0 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7
ans =
2
board =
0 0 1 1 0
0 0 0 0 1
0 0 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 1 1 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2
board =
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
l1 =
1 7 11 13
ans =
2

5  Fail 
board = [0 0 0 0 0
0 0 0 0 0
0 0 0 1 1
0 0 1 1 0
0 0 1 0 0];
moves = lights_out_1(board); %you're 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)==3)
board =
0 0 0 0 0
0 0 0 0 0
0 0 0 1 1
0 0 1 1 0
0 0 1 0 0
l1 =
0 1
ans =
0

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

Project Euler: Problem 3, Largest prime factor
158 Solvers
Make one big string out of two smaller strings
1069 Solvers
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
144 Solvers
Magic is simple (for beginners)
1069 Solvers
Remove entire row and column in the matrix containing the input values
109 Solvers