Cody

Problem 44767. Lights Out 13 - 5x5, three stages, x moves

Solution 1958320

Submitted on 3 Oct 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   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)

moves = 15 15 10 10 21 21 1 moves = 15 15 10 10 21 1 21 moves = 15 21 21 1 15 10 10 moves = 15 21 21 1 10 10 15 moves = 10 15 21 1 1

2   Fail
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)

Output argument "moves" (and maybe others) not assigned during call to "lights_out_13". Error in Test2 (line 6) moves = lights_out_13(board); % [6:2:20]

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)

moves = 19 19 17 17 10 4 10 4 5 5 1 moves = 19 19 17 17 1 10 4 10 4 5 5 moves = 19 19 17 17 1 10 5 10 5 4 4 moves = 19 19 17 17 1 10 4 4 5 5 10 moves = 4 5 10 17 19 1 1

4   Fail
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)

moves = 13 9 24 22 22 1 20 11 6 6 10 10 5 4 4 2 1 1 6 6 11 17 16 16 11 21 moves = 13 9 24 22 22 1 20 11 6 6 10 10 5 4 4 2 1 1 6 6 11 17 21 16 16 11 moves = 13 9 24 22 22 1 20 11 6 6 10 10 5 4 4 2 1 1 6 6 11 17 21 16 11 16 moves = 4 10 16 22 2 5 9 13 17 20 21 24 2 5 9 13 17 20 21 24

Assertion failed.

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)

moves = 10 10 9 8 7 6 6 moves = 6 6 7 8 9 10 10 moves = 10 10 9 6 6 7 8 moves = 10 10 9 8 6 6 7 moves = 6 6 7 8 10 10 9 moves = 6 10 7 8 9 7 8 9

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)

moves = 8 24 24 2 17 9 16 21 10 4 15 2 8 13 13 12 18 18 24 25 25 moves = 8 22 22 4 19 20 25 6 11 7 2 4 8 13 14 13 18 18 22 21 21 moves = 4 8 13 18 21 2 6 7 11 14 19 20 25 2 6 7 11 14 19 20 25

7   Fail
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)

Output argument "moves" (and maybe others) not assigned during call to "lights_out_13". Error in Test7 (line 6) moves = lights_out_13(board); % [2 2 5 7:8 8 11 13 17:19]

8   Fail
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)

Output argument "moves" (and maybe others) not assigned during call to "lights_out_13". Error in Test8 (line 6) moves = lights_out_13(board); % [3 3 7 9:11 11 16:18 17 21 21 24 25]

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)

moves = 9 9 22 24 24 22 18 18 8 8 4 4 10 10 9 14 14 moves = 4 8 10 14 18 22 24

10   Fail
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)

Output argument "moves" (and maybe others) not assigned during call to "lights_out_13". Error in Test10 (line 6) moves = lights_out_13(board); % on your own

11   Fail
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)

Output argument "moves" (and maybe others) not assigned during call to "lights_out_13". Error in Test11 (line 6) moves = lights_out_13(board);

12   Fail
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)

Output argument "moves" (and maybe others) not assigned during call to "lights_out_13". Error in Test12 (line 6) moves = lights_out_13(board);

13   Fail
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)

Output argument "moves" (and maybe others) not assigned during call to "lights_out_13". Error in Test13 (line 6) moves = lights_out_13(board);

Suggested Problems

More from this Author139