Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 62134

Submitted on 16 Mar 2012 by Matt

Correct

64Size
Leading solution size is 24.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%% Eight Queens Solution Checker Test Suite

                    
2
Pass
 
%%
% Unique solution #6 from
% http://en.wikipedia.org/wiki/Eight_queens_puzzle
in1 = [ ...
    0 0 0 0 1 0 0 0
    0 0 1 0 0 0 0 0
    0 0 0 0 0 0 0 1
    0 0 0 1 0 0 0 0
    0 0 0 0 0 0 1 0
    1 0 0 0 0 0 0 0
    0 0 0 0 0 1 0 0
    0 1 0 0 0 0 0 0 ];
out1 = isEightQueensSolution(in1);
assert(islogical(out1));
assert(isequal(out1, 1));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     0     0     8     1     1     1     1     1
     0     0     8     1     2     2     1     1     1     1
     0     0     1     1     1     0     1     8     1     1
     0     0     1     8     3     1     1     3     2     1
     0     0     1     1     2     1     8     2     2     2
     8     1     2     2     2     2     3     3     0     1
     1     1     1     1     1     8     3     3     2     1
     1     8     3     2     2     2     3     3     2     1
     1     1     2     2     0     1     1     2     1     1
     1     1     0     2     1     1     1     1     1     1
     1     1     0     1     1     2     1     0     0     1
     1     1     0     0     0     2     2     0     0     0
     1     1     0     0     0     1     1     1     0     0
     0     1     0     0     0     1     0     1     0     0
     0     1     0     0     0     0     0     0     1     0
  Columns 11 through 15
     1     1     0     0     0
     0     0     0     0     0
     1     1     1     1     1
     1     0     0     0     0
     1     1     1     1     0
     1     0     0     0     0
     2     2     1     0     0
     0     1     1     0     0
     1     0     0     1     0
     0     1     0     0     1
     1     0     1     0     0
     1     0     0     1     0
     0     1     0     0     0
     0     0     1     0     0
     0     0     0     0     0
y =
     1
3
Pass
 
%%
% Unique solution #7
in2 = [ ...
    0 0 0 0 1 0 0 0
    0 0 0 0 0 0 1 0
    0 0 0 1 0 0 0 0
    1 0 0 0 0 0 0 0
    0 0 1 0 0 0 0 0
    0 0 0 0 0 0 0 1
    0 0 0 0 0 1 0 0
    0 1 0 0 0 0 0 0 ];
out2 = isEightQueensSolution(in2);
assert(isequal(out2, 1));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     0     0     8     1     1     1     1     1
     0     0     0     0     1     1     8     1     1     1
     0     0     0     8     2     1     3     2     1     1
     8     1     1     2     3     1     2     2     1     0
     1     1     8     2     2     2     2     1     2     2
     1     0     2     2     1     0     2     8     1     2
     1     0     1     2     2     8     2     3     2     1
     1     8     2     2     3     3     3     2     2     1
     1     1     2     1     0     2     2     2     0     1
     1     1     1     2     0     1     1     2     1     0
     1     1     1     0     1     1     0     2     1     1
     0     1     1     0     0     2     0     1     0     1
     0     1     0     0     0     1     1     1     0     0
     0     1     0     0     0     1     0     1     0     0
     0     1     0     0     0     0     0     0     1     0
  Columns 11 through 15
     1     1     0     0     0
     1     1     1     1     0
     1     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     2     1     1     1     1
     2     2     1     0     0
     0     1     1     0     0
     1     0     0     1     0
     1     1     0     0     0
     0     0     1     0     0
     1     0     0     1     0
     0     1     0     0     1
     0     0     1     0     0
     0     0     0     0     0
y =
     1
4
Pass
 
%%
% Unique solution #10
in3 = [ ...
    0 0 0 0 0 1 0 0
    0 1 0 0 0 0 0 0
    0 0 0 0 0 0 1 0
    1 0 0 0 0 0 0 0
    0 0 0 1 0 0 0 0
    0 0 0 0 0 0 0 1
    0 0 0 0 1 0 0 0
    0 0 1 0 0 0 0 0 ];
out3 = isEightQueensSolution(in3);
assert(isequal(out3, 1));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     0     0     0     8     1     1     1     1
     0     8     1     1     1     2     2     1     1     0
     0     1     1     0     0     1     8     2     1     1
     8     2     1     2     1     2     2     2     1     0
     1     2     0     8     2     2     2     1     2     2
     1     1     1     1     1     2     1     8     1     2
     1     1     0     2     8     3     3     2     2     1
     1     1     8     2     3     3     3     3     1     2
     1     1     1     2     1     1     2     2     1     0
     1     0     1     1     2     0     2     2     1     0
     1     0     1     1     1     1     0     2     1     1
     0     0     1     1     1     0     1     1     0     1
     0     0     1     0     1     0     0     2     0     0
     0     0     1     0     1     0     0     0     1     0
     0     0     1     0     0     0     0     0     0     1
  Columns 11 through 15
     1     1     1     0     0
     0     0     0     0     0
     1     1     1     1     0
     0     0     0     0     0
     1     0     0     0     0
     2     1     1     1     1
     2     2     0     0     0
     0     1     1     0     0
     1     0     1     0     0
     0     1     0     1     0
     0     0     1     0     0
     1     0     0     1     0
     1     0     0     0     1
     0     1     0     0     0
     0     0     0     0     0
y =
     1
5
Pass
 
%%
% Unique solution #11
in4 = [ ...
    0 0 0 1 0 0 0 0
    0 0 0 0 0 0 1 0
    1 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 1
    0 0 0 0 1 0 0 0
    0 1 0 0 0 0 0 0
    0 0 0 0 0 1 0 0
    0 0 1 0 0 0 0 0 ];
out4 = isEightQueensSolution(in4);
assert(isequal(out4, 1));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     0     8     1     1     1     1     1     1
     0     0     0     1     1     0     8     1     1     1
     8     1     1     2     1     2     2     2     0     0
     1     1     0     1     0     0     2     8     2     1
     1     0     1     1     8     1     2     3     2     2
     1     8     1     3     2     2     2     2     2     1
     1     1     1     1     2     8     3     2     1     2
     1     1     8     3     2     3     3     3     1     1
     1     1     1     1     2     1     2     2     1     0
     1     1     1     0     2     2     0     2     1     1
     0     1     1     0     1     2     1     1     0     1
     0     1     1     0     1     1     1     1     0     0
     0     1     1     0     0     1     0     1     1     0
     0     0     1     0     0     1     0     0     1     0
     0     0     1     0     0     0     0     0     0     1
  Columns 11 through 15
     1     0     0     0     0
     1     1     1     1     0
     0     0     0     0     0
     1     1     1     1     1
     1     1     0     0     0
     1     0     0     0     0
     2     2     1     0     0
     1     1     1     0     0
     0     0     1     1     0
     0     0     0     1     0
     1     0     0     0     1
     1     1     0     0     0
     0     1     0     0     0
     0     0     1     0     0
     0     0     0     0     0
y =
     1
6
Pass
 
%%
in5 = [ ...
    0 0 0 0 1 0 0 0
    0 0 1 0 0 0 0 0
    0 0 0 1 0 0 0 0
    0 0 0 0 0 0 0 1
    0 0 0 0 0 0 1 0
    1 0 0 0 0 0 0 0
    0 0 0 0 0 1 0 0
    0 1 0 0 0 0 0 0 ];
out5 = isEightQueensSolution(in5);
assert(isequal(out5, 0));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     0     0     8     1     1     1     1     1
     0     0     8     1     2     2     1     1     1     1
     0     0     1     9     2     1     2     1     1     1
     0     0     1     1     3     0     0     9     1     1
     0     0     1     1     1     2     8     2     3     1
     8     1     2     2     2     1     4     3     0     2
     1     1     1     1     1     8     2     4     2     1
     1     8     3     2     2     2     3     2     3     1
     1     1     2     2     0     1     1     2     0     2
     1     1     0     2     1     1     1     1     1     0
     1     1     0     0     1     2     1     1     0     1
     1     1     0     0     0     2     2     0     0     0
     1     1     0     0     0     1     1     1     0     0
     0     1     0     0     0     1     0     1     0     0
     0     1     0     0     0     0     0     0     1     0
  Columns 11 through 15
     1     1     0     0     0
     0     0     0     0     0
     1     0     0     0     0
     1     1     1     1     1
     1     1     1     1     0
     0     0     0     0     0
     3     1     1     0     0
     0     2     0     0     0
     1     0     1     0     0
     1     1     0     1     0
     0     0     1     0     1
     1     0     0     1     0
     0     1     0     0     0
     0     0     1     0     0
     0     0     0     0     0
y =
     0
7
Pass
 
%%
in6 = [ ...
    0 0 1 0 0 0 0 0
    0 0 0 0 0 0 1 0
    0 0 0 1 0 0 0 0
    1 0 0 0 0 0 0 0
    0 0 1 0 0 0 0 0
    0 0 0 0 0 0 0 1
    0 0 0 0 0 1 0 0
    0 1 0 0 0 0 0 0 ];
out6 = isEightQueensSolution(in6);
assert(isequal(out6, 0));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     8     1     1     1     1     1     1     1
     0     0     1     1     0     0     8     1     1     1
     0     0     1     8     2     1     2     2     1     1
     8     1     2     2     2     2     2     1     1     0
     1     1     9     2     1     2     3     1     1     2
     1     0     3     2     0     0     2     9     1     1
     1     0     2     2     1     8     2     3     3     1
     1     8     3     2     2     3     3     2     2     2
     1     1     2     1     0     2     2     2     0     1
     1     1     1     2     0     1     1     2     1     0
     1     1     1     0     1     1     0     2     1     1
     0     1     1     0     0     2     0     1     0     1
     0     1     0     0     0     1     1     1     0     0
     0     1     0     0     0     1     0     1     0     0
     0     1     0     0     0     0     0     0     1     0
  Columns 11 through 15
     0     0     0     0     0
     1     1     1     1     0
     1     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     2     1     1     1     1
     1     2     1     0     0
     0     0     1     0     0
     1     0     0     1     0
     1     1     0     0     0
     0     0     1     0     0
     1     0     0     1     0
     0     1     0     0     1
     0     0     1     0     0
     0     0     0     0     0
y =
     0
8
Pass
 
%%
in7 = [ ...
    0 0 0 0 0 1 0 0
    0 1 0 0 0 0 0 0
    0 0 0 0 0 0 1 0
    1 0 0 0 0 0 0 0
    0 0 0 1 0 0 0 0
    0 0 0 0 0 0 0 1
    0 0 1 0 0 0 0 0
    0 0 0 0 1 0 0 0 ];
out7 = isEightQueensSolution(in7);
assert(isequal(out7, 0));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     0     0     0     8     1     1     1     1
     0     8     1     1     1     2     2     1     1     0
     0     1     1     0     0     1     8     2     1     1
     8     2     1     2     1     2     2     2     1     0
     1     2     0     8     2     2     2     1     2     2
     1     1     1     1     1     2     1     8     1     2
     1     1     8     3     1     3     3     2     2     1
     1     1     1     2     9     2     3     3     1     2
     1     1     1     1     2     2     1     2     1     0
     1     0     1     1     1     1     3     1     1     0
     1     0     1     1     1     0     1     3     0     1
     0     0     1     1     1     0     0     2     1     0
     0     0     1     0     1     0     0     1     1     1
     0     0     1     0     1     0     0     0     0     1
     0     0     0     0     1     0     0     0     0     0
  Columns 11 through 15
     1     1     1     0     0
     0     0     0     0     0
     1     1     1     1     0
     0     0     0     0     0
     1     0     0     0     0
     2     1     1     1     1
     1     1     0     0     0
     1     2     1     0     0
     1     0     1     0     0
     0     1     0     1     0
     0     0     1     0     0
     1     0     0     1     0
     0     0     0     0     1
     1     0     0     0     0
     0     1     0     0     0
y =
     0
9
Pass
 
%%
in8 = [ ...
    0 0 0 1 0 0 0 0
    0 0 0 0 0 0 1 0
    1 0 0 0 0 0 0 0
    0 0 0 0 1 0 0 1
    0 0 0 0 0 0 0 0
    0 1 0 0 0 0 0 0
    0 0 0 0 0 1 0 0
    0 0 1 0 0 0 0 0 ];
out8 = isEightQueensSolution(in8);
assert(isequal(out8, 0));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     0     8     1     1     1     1     1     1
     0     0     0     1     1     0     8     1     1     1
     8     1     1     2     1     2     2     2     0     0
     1     1     0     1     8     1     3     9     3     2
     1     0     1     1     1     1     1     2     1     1
     1     8     1     3     2     1     3     2     2     1
     1     1     1     1     2     8     2     3     1     2
     1     1     8     3     2     3     3     2     2     1
     1     1     1     1     2     1     2     2     0     1
     1     1     1     0     2     2     0     2     1     0
     0     1     1     0     1     2     1     1     0     1
     0     1     1     0     0     1     1     1     0     0
     0     1     1     0     0     1     0     1     1     0
     0     0     1     0     0     1     0     0     1     0
     0     0     1     0     0     0     0     0     0     1
  Columns 11 through 15
     1     0     0     0     0
     1     1     1     1     0
     0     0     0     0     0
     2     2     1     1     1
     0     0     0     0     0
     1     0     0     0     0
     2     2     1     0     0
     1     1     1     0     0
     0     0     1     1     0
     1     0     0     1     0
     0     1     0     0     1
     1     0     0     0     0
     0     1     0     0     0
     0     0     1     0     0
     0     0     0     0     0
y =
     0
10
Pass
 
%%
% Only 7 queens
in9 = [ ...
    0 0 0 0 1 0 0 0
    0 0 1 0 0 0 0 0
    0 0 0 0 0 0 0 1
    0 0 0 1 0 0 0 0
    0 0 0 0 0 0 0 0
    1 0 0 0 0 0 0 0
    0 0 0 0 0 1 0 0
    0 1 0 0 0 0 0 0 ];
out9 = isEightQueensSolution(in9);
assert(isequal(out9, 0));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     0     0     0     0     8     1     1     1     1     1
     0     0     8     1     2     2     1     1     1     1
     0     0     1     1     1     0     1     8     1     1
     0     0     1     8     3     1     1     3     2     1
     0     0     1     1     2     1     0     1     1     1
     8     1     2     2     2     2     2     2     0     1
     1     1     1     1     1     8     2     3     1     1
     1     8     3     2     2     2     2     3     2     0
     1     1     2     2     0     1     0     2     1     1
     1     1     0     2     1     1     0     1     1     1
     1     1     0     1     1     2     0     0     0     1
     1     1     0     0     0     2     1     0     0     0
     1     1     0     0     0     1     1     1     0     0
     0     1     0     0     0     1     0     1     0     0
     0     1     0     0     0     0     0     0     1     0
  Columns 11 through 15
     1     1     0     0     0
     0     0     0     0     0
     1     1     1     1     1
     1     0     0     0     0
     0     0     0     0     0
     1     0     0     0     0
     2     2     1     0     0
     0     1     1     0     0
     0     0     0     1     0
     0     0     0     0     1
     1     0     0     0     0
     1     0     0     0     0
     0     1     0     0     0
     0     0     1     0     0
     0     0     0     0     0
y =
     0
11
Pass
 
%%
% Row and column constraint satisfied but
% not diagonal constraint.
in10 = eye(8);
out10 = isEightQueensSolution(in10);
assert(isequal(out10, 0));
atk =
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
atk =
     8     1     1     1     1     1     1     1
     1     1     0     0     0     0     0     0
     1     0     1     0     0     0     0     0
     1     0     0     1     0     0     0     0
     1     0     0     0     1     0     0     0
     1     0     0     0     0     1     0     0
     1     0     0     0     0     0     1     0
     1     0     0     0     0     0     0     1
atk =
  Columns 1 through 10
     8     1     1     1     1     1     1     1     0     0
     1     9     1     1     1     1     1     1     1     0
     1     1    10     1     1     1     1     1     1     1
     1     1     1    11     1     1     1     1     1     1
     1     1     1     1    12     1     1     1     1     1
     1     1     1     1     1    13     1     1     1     1
     1     1     1     1     1     1    14     1     1     1
     1     1     1     1     1     1     1    15     1     1
     0     1     1     1     1     1     1     1     7     0
     0     0     1     1     1     1     1     1     0     6
     0     0     0     1     1     1     1     1     0     0
     0     0     0     0     1     1     1     1     0     0
     0     0     0     0     0     1     1     1     0     0
     0     0     0     0     0     0     1     1     0     0
     0     0     0     0     0     0     0     1     0     0
  Columns 11 through 15
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     1     0     0     0     0
     1     1     0     0     0
     1     1     1     0     0
     1     1     1     1     0
     1     1     1     1     1
     0     0     0     0     0
     0     0     0     0     0
     5     0     0     0     0
     0     4     0     0     0
     0     0     3     0     0
     0     0     0     2     0
     0     0     0     0     1
y =
     0