Cody

# Problem 44766. Lights Out 12 - 5x5, three stages, <7 moves

Solution 2394684

Submitted on 27 May 2020
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 1 0 0 0 1 0 0 0 0 0 0 0 2 0 0 0 2 2 2 0 0 0 2 0]; moves = lights_out_12(board); % [1 1 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)

Assertion failed.

2   Fail
board = [2 2 0 2 2 2 0 2 0 2 0 2 2 2 0 2 0 2 0 2 2 2 0 2 2]; moves = lights_out_12(board); % [1 5 13 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)

Assertion failed.

3   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_12(board); % [5 5 7 7 23 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]),3); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

Assertion failed.

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

Assertion failed.

5   Fail
board = [1 1 0 0 0 2 0 0 0 0 1 1 0 0 0 2 0 0 0 0 1 1 0 0 0]; moves = lights_out_12(board); % [1 1 3 3 5 5] 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)

Assertion failed.

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

Assertion failed.

7   Fail
board = [0 2 0 2 0 2 1 1 1 2 2 0 1 0 2 2 1 1 1 2 0 2 0 2 0]; moves = lights_out_12(board); % [7:9 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)

Assertion failed.

8   Fail
board = [0 0 0 0 0 0 2 1 2 0 2 0 2 0 2 0 2 1 2 0 0 0 0 0 0]; moves = lights_out_12(board); % [8 13 13 18] 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)

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!