Cody

# Problem 44765. Lights Out 11 - 5x5, with wrapping, x moves

Solution 2068677

Submitted on 24 Dec 2019 by Alexander
• Size: 314
• This is the leading solution.
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 0 0 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 0 0 0 0 1 1]; moves = lights_out_11(board); % [2 4 13 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)

moves = 2 4 13 25

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

moves = 2 4 7 9 17 19 22 24

3   Pass
board = [0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0]; moves = lights_out_11(board); % [2 6 8 12 14 18 20 24] 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)

moves = 1 3 5 7 10 12 13 14 15 18 20 23 24 25

4   Pass
board = [1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 1 1 1 0 0 1 1]; moves = lights_out_11(board); % [3 7 17 21 23: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)

moves = 1 2 3 4 5 7 9 10 12 13 14 15 17 18 20 23 25

5   Pass
board = [0 1 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 0 1 1 0 1 1 1 0]; moves = lights_out_11(board); % [7:9 12:14 17: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)

moves = 7 8 9 12 13 14 17 18 19

6   Pass
board = [0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0]; moves = lights_out_11(board); % [11:15] 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)

moves = 1 5 7 10 15 18 20 24 25

7   Pass
board = [1 1 1 0 0 0 0 1 0 0 1 1 1 1 1 1 0 0 1 0 1 1 0 1 0]; moves = lights_out_11(board); % [9 11 14 21 23 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)

moves = 2 3 7 8 9 12 13 22 24 25

8   Pass
board = [1 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 1 1 1 1 0 1 1]; moves = lights_out_11(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)

moves = 1 2 3 4 5 7 10 12 14 15 18 20 22 23 25

9   Pass
board = [0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1]; moves = lights_out_11(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)

moves = 3 8 12 14 22 24

10   Pass
board = [1 0 0 0 1 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 1 0 0 0 1]; moves = lights_out_11(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)

moves = 2 4 13 22 24