Cody

# Problem 113. N-Queens Checker

Solution 106933

Submitted on 5 Jul 2012 by James
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
%% a = [1 0 0; 0 0 1; 0 0 0]; tf_correct = true; assert(isequal(queens(a),tf_correct))

h = 1 2 3 4 5 7 9 h = 2 4 5 6 7 8 9

2   Pass
%% a = [0 0 0 1; 1 0 0 0; 0 0 1 0; 0 1 0 0]; tf_correct = false; assert(isequal(queens(a),tf_correct))

h = 1 2 3 4 5 6 7 10 12 14 h = 3 4 5 6 7 8 11 12 14 16

3   Pass
%% a = [1 0 0 0 0; 0 0 0 1 1]; tf_correct = false; assert(isequal(queens(a),tf_correct))

h = 1 2 3 4 5 7 9 h = 2 4 5 6 7 8 9 10

4   Pass
%% a = [ ... 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 0 0 0 0 1; 0 0 0 0 0 1 0 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]; tf_correct = true; assert(isequal(queens(a),tf_correct))

h = Columns 1 through 10 1 2 3 4 5 6 7 8 14 15 Columns 11 through 20 16 21 23 28 31 35 39 42 47 49 Columns 21 through 22 55 63 h = Columns 1 through 10 2 3 4 9 10 11 12 13 14 15 Columns 11 through 20 16 18 19 20 25 27 29 35 38 43 Columns 21 through 24 47 51 56 59 h = Columns 1 through 10 1 3 9 10 17 18 19 20 21 22 Columns 11 through 20 23 24 25 26 33 35 41 44 49 53 Columns 21 through 22 57 62 h = Columns 1 through 10 3 6 12 14 16 21 22 23 25 26 Columns 11 through 20 27 28 29 30 31 32 37 38 39 44 Columns 21 through 26 46 48 51 54 58 62 h = Columns 1 through 10 4 8 13 16 22 24 31 32 33 34 Columns 11 through 20 35 36 37 38 39 40 47 48 54 56 Columns 21 through 22 61 64 h = Columns 1 through 10 5 9 13 18 21 24 27 29 31 36 Columns 11 through 20 37 38 41 42 43 44 45 46 47 48 Columns 21 through 26 52 53 54 59 61 63 h = Columns 1 through 10 2 8 10 15 18 22 26 29 34 36 Columns 11 through 20 41 42 43 49 50 51 52 53 54 55 Columns 21 through 24 56 57 58 59 h = Columns 1 through 10 4 12 20 28 32 33 36 39 42 44 Columns 11 through 20 46 51 52 53 57 58 59 60 61 62 Columns 21 through 22 63 64

5   Pass
%% a = ones(15,7); tf_correct = false; assert(isequal(queens(a),tf_correct))

h = Columns 1 through 10 1 2 3 4 5 6 7 8 9 10 Columns 11 through 20 11 12 13 14 15 16 17 31 33 46 Columns 21 through 27 49 61 65 76 81 91 97

6   Pass
%% a = zeros(20,23); a(1,22) = 1; a(2,23) = 1; tf_correct = false; assert(isequal(queens(a),tf_correct))

h = Columns 1 through 10 1 21 41 60 61 79 81 98 101 117 Columns 11 through 20 121 136 141 155 161 174 181 193 201 212 Columns 21 through 30 221 231 241 250 261 269 281 288 301 307 Columns 31 through 40 321 326 341 345 361 364 381 383 401 402 Columns 41 through 50 421 422 423 424 425 426 427 428 429 430 Columns 51 through 60 431 432 433 434 435 436 437 438 439 440 Columns 61 through 62 441 442

7   Pass
%% a = [1 0; 0 1]; tf_correct = false; assert(isequal(queens(a),tf_correct))

h = 1 2 3 4

### Community Treasure Hunt

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

Start Hunting!