Cody

Problem 44769. Lights Out 14 - 5x5, four stages, x moves

Solution 2287135

Submitted on 16 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 3 1 0 0 3 3 0 0 0 0 3 0 0 2 0 0 0 2 2 2 0]; moves = lights_out_14(board); % [1 1 1 15 15 22] 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]),4); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test1 (line 6) moves = lights_out_14(board); % [1 1 1 15 15 22]

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

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test2 (line 6) moves = lights_out_14(board); % [1:10 6:10]

3   Fail
board = [1 3 0 3 1 3 2 3 2 3 0 3 3 3 0 3 2 3 2 3 1 3 0 3 1]; moves = lights_out_14(board); % [1 1 1 5 5 5 7 7 9 9 13 17 17 19 19 21 21 21 25 25 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]),4); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test3 (line 6) moves = lights_out_14(board); % [1 1 1 5 5 5 7 7 9 9 13 17 17 19 19 21 21 21 25 25 25]

4   Fail
board = [2 1 1 1 2 1 2 3 2 1 1 3 0 3 1 1 2 3 2 1 2 1 1 1 2]; moves = lights_out_14(board); % [6:10 16:20 2:5:22 4:5: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]),4); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test4 (line 6) moves = lights_out_14(board); % [6:10 16:20 2:5:22 4:5:24]

5   Fail
board = [1 0 3 1 3 2 2 2 3 2 0 2 3 1 2 0 0 0 1 0 3 2 1 2 1]; moves = lights_out_14(board); % [2 4 4 4:7 6 10:13 12 17:21 18:20 19 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]),4); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test5 (line 6) moves = lights_out_14(board); % [2 4 4 4:7 6 10:13 12 17:21 18:20 19 25]

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

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test6 (line 6) moves = lights_out_14(board); % [7 7 9 9 9 17 17 17 19 19]

7   Fail
board = [0 3 1 3 0 0 2 2 2 0 0 1 1 1 0 0 2 2 2 0 0 3 1 3 0]; moves = lights_out_14(board); % [11:15 12:14 13] 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]),4); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test7 (line 6) moves = lights_out_14(board); % [11:15 12:14 13]

8   Fail
board = [3 1 0 0 0 1 2 3 0 0 0 3 1 3 0 0 0 3 2 1 0 0 0 1 3]; moves = lights_out_14(board); % [1 7 7 13 13 13 19 19 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]),4); %remove semicolon to display progress end assert(sum(abs(board(:)))==0)

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test8 (line 6) moves = lights_out_14(board); % [1 7 7 13 13 13 19 19 25]

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

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test9 (line 6) moves = lights_out_14(board); % on your own

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

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test10 (line 6) moves = lights_out_14(board);

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

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test11 (line 6) moves = lights_out_14(board);

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

Error using .* Matrix dimensions must agree. Error in lights_out_14>bsolve (line 56) Ab(d,:) = mod(scalingFactor .* Ab(d,:),nstates); Error in lights_out_14 (line 26) Sv = bsolve(A(ndv,ndv),mod(b(ndv)-(A(ndv,nd+1:end)*v),nstates),nstates); Error in Test12 (line 6) moves = lights_out_14(board);

Suggested Problems

More from this Author139

Community Treasure Hunt

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

Start Hunting!