Cody

# Problem 44764. Lights Out 10 - 5x5, with wrapping, 6 moves

Solution 2069919

Submitted on 26 Dec 2019
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   Fail
board = [1 0 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 1 0 1 1 0 0 0 1]; moves = lights_out_10(board); % [1 5 11 15 21 25] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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)

Unrecognized function or variable 'moves1'. Error in lights_out_10>findMoves (line 40) if numel(moves1)<numel(moves2) Error in lights_out_10>findNmoves (line 15) [~, moves] = findMoves(board([x(in):5 1:x(in)-1],[y(in):5 1:y(in)-1])); Error in lights_out_10 (line 3) moves = findNmoves(board,6); Error in Test1 (line 6) moves = lights_out_10(board); % [1 5 11 15 21 25]

2   Fail
board = [0 1 1 0 0 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 0 0 1 1 0]; moves = lights_out_10(board); % [4 9 10 16 17 22] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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)

Unrecognized function or variable 'moves1'. Error in lights_out_10>findMoves (line 40) if numel(moves1)<numel(moves2) Error in lights_out_10>findNmoves (line 15) [~, moves] = findMoves(board([x(in):5 1:x(in)-1],[y(in):5 1:y(in)-1])); Error in lights_out_10 (line 3) moves = findNmoves(board,6); Error in Test2 (line 6) moves = lights_out_10(board); % [4 9 10 16 17 22]

3   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_10(board); % [7 8 9 17 18 19] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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   Pass
board = [0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 1 1 0 1 0 0]; moves = lights_out_10(board); % [4 8 11 13 17 22] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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 = [1 1 0 1 1 1 1 0 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 1]; moves = lights_out_10(board); % [7 8 12 14 15 21] b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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)

Unrecognized function or variable 'moves1'. Error in lights_out_10>findMoves (line 40) if numel(moves1)<numel(moves2) Error in lights_out_10>findNmoves (line 15) [~, moves] = findMoves(board([x(in):5 1:x(in)-1],[y(in):5 1:y(in)-1])); Error in lights_out_10 (line 3) moves = findNmoves(board,6); Error in Test5 (line 6) moves = lights_out_10(board); % [7 8 12 14 15 21]

6   Pass
board = [0 0 0 1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 0 0 0 0 1 0 0]; moves = lights_out_10(board); % on your own b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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   Pass
board = [0 1 0 0 0 0 1 1 0 1 1 1 0 0 0 1 0 0 1 1 1 1 0 1 0]; moves = lights_out_10(board); b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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   Pass
board = [1 0 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 1 1 0 1 0 1]; moves = lights_out_10(board); b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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   Pass
board = [0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 1 1 0 1 1 1 1 0]; moves = lights_out_10(board); b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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 = [1 0 1 0 0 0 0 0 0 1 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1]; moves = lights_out_10(board); b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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)

Unrecognized function or variable 'moves1'. Error in lights_out_10>findMoves (line 40) if numel(moves1)<numel(moves2) Error in lights_out_10>findNmoves (line 15) [~, moves] = findMoves(board([x(in):5 1:x(in)-1],[y(in):5 1:y(in)-1])); Error in lights_out_10 (line 3) moves = findNmoves(board,6); Error in Test10 (line 6) moves = lights_out_10(board);

11   Fail
board = [0 1 0 1 1 0 0 0 0 1 0 0 0 1 1 0 1 1 0 0 1 1 0 0 0]; moves = lights_out_10(board); b1 = diag(ones(1,5),0) + diag(ones(1,4),1) + diag(ones(1,4),-1); b1(1,5) = 1; b1(5,1) = 1; b2 = eye(5); b3 = zeros(5); b_map = [b1,b2,b3,b3,b2; b2,b1,b2,b3,b3; b3,b2,b1,b2,b3; b3,b3,b2,b1,b2; b2,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)

Unrecognized function or variable 'moves1'. Error in lights_out_10>findMoves (line 40) if numel(moves1)<numel(moves2) Error in lights_out_10>findNmoves (line 15) [~, moves] = findMoves(board([x(in):5 1:x(in)-1],[y(in):5 1:y(in)-1])); Error in lights_out_10 (line 3) moves = findNmoves(board,6); Error in Test11 (line 6) moves = lights_out_10(board);