Cody

Problem 96. Knight's Tour Checker

Solution 859218

Submitted on 30 Mar 2016 by Marvin Schmidt
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 = ... [ 7 2 5 4 0 8 1 6 3]; tf_correct = true; assert(isequal(knights_tour(a),tf_correct))

Field = 7 2 5 7 2 5 7 2 5 4 0 8 4 0 8 4 0 8 1 6 3 1 6 3 1 6 3 7 2 5 7 2 5 7 2 5 4 0 8 4 0 8 4 0 8 1 6 3 1 6 3 1 6 3 7 2 5 7 2 5 7 2 5 4 0 8 4 0 8 4 0 8 1 6 3 1 6 3 1 6 3

2   Pass
a = ... [ 1 0 0 0 0 2]; tf_correct = true; assert(isequal(knights_tour(a),tf_correct))

Field = 1 0 0 1 0 0 1 0 0 0 0 2 0 0 2 0 0 2 1 0 0 1 0 0 1 0 0 0 0 2 0 0 2 0 0 2 1 0 0 1 0 0 1 0 0 0 0 2 0 0 2 0 0 2

3   Pass
a = ... [ 15 5 12 3 0 2 9 6 8 11 4 13 1 14 7 10]; tf_correct = false; assert(isequal(knights_tour(a),tf_correct))

Field = 15 5 12 3 15 5 12 3 15 5 12 3 0 2 9 6 0 2 9 6 0 2 9 6 8 11 4 13 8 11 4 13 8 11 4 13 1 14 7 10 1 14 7 10 1 14 7 10 15 5 12 3 15 5 12 3 15 5 12 3 0 2 9 6 0 2 9 6 0 2 9 6 8 11 4 13 8 11 4 13 8 11 4 13 1 14 7 10 1 14 7 10 1 14 7 10 15 5 12 3 15 5 12 3 15 5 12 3 0 2 9 6 0 2 9 6 0 2 9 6 8 11 4 13 8 11 4 13 8 11 4 13 1 14 7 10 1 14 7 10 1 14 7 10

4   Pass
a = ... [ 0 5 12 3 15 2 9 6 8 11 4 13 1 14 7 10]; tf_correct = true; assert(isequal(knights_tour(a),tf_correct))

Field = 0 5 12 3 0 5 12 3 0 5 12 3 15 2 9 6 15 2 9 6 15 2 9 6 8 11 4 13 8 11 4 13 8 11 4 13 1 14 7 10 1 14 7 10 1 14 7 10 0 5 12 3 0 5 12 3 0 5 12 3 15 2 9 6 15 2 9 6 15 2 9 6 8 11 4 13 8 11 4 13 8 11 4 13 1 14 7 10 1 14 7 10 1 14 7 10 0 5 12 3 0 5 12 3 0 5 12 3 15 2 9 6 15 2 9 6 15 2 9 6 8 11 4 13 8 11 4 13 8 11 4 13 1 14 7 10 1 14 7 10 1 14 7 10

5   Pass
a = [22 29 4 31 16 35;3 32 23 34 5 14;28 21 30 15 36 17;9 2 33 24 13 6;20 27 8 11 18 25;1 10 19 26 7 12]; tf_correct = true; assert(isequal(knights_tour(a),tf_correct))

Field = Columns 1 through 16 22 29 4 31 16 35 22 29 4 31 16 35 22 29 4 31 3 32 23 34 5 14 3 32 23 34 5 14 3 32 23 34 28 21 30 15 36 17 28 21 30 15 36 17 28 21 30 15 9 2 33 24 13 6 9 2 33 24 13 6 9 2 33 24 20 27 8 11 18 25 20 27 8 11 18 25 20 27 8 11 1 10 19 26 7 12 1 10 19 26 7 12 1 10 19 26 22 29 4 31 16 35 22 29 4 31 16 35 22 29 4 31 3 32 23 34 5 14 3 32 23 34 5 14 3 32 23 34 28 21 30 15 36 17 28 21 30 15 36 17 28 21 30 15 9 2 33 24 13 6 9 2 33 24 13 6 9 2 33 24 20 27 8 11 18 25 20 27 8 11 18 25 20 27 8 11 1 10 19 26 7 12 1 10 19 26 7 12 1 10 19 26 22 29 4 31 16 35 22 29 4 31 16 35 22 29 4 31 3 32 23 34 5 14 3 32 23 34 5 14 3 32 23 34 28 21 30 15 36 17 28 21 30 15 36 17 28 21 30 15 9 2 33 24 13 6 9 2 33 24 13 6 9 2 33 24 20 27 8 11 18 25 20 27 8 11 18 25 20 27 8 11 1 10 19 26 7 12 1 10 19 26 7 12 1 10 19 26 Columns 17 through 18 16 35 5 14 36 17 13 6 18 25 7 12 16 35 5 14 36 17 13 6 18 25 7 12 16 35 5 14 36 17 13 6 18 25 7 12

6   Pass
a = [22 29 4 31 16 35;3 32 23 34 5 14;28 21 30 15 0 17;2 9 33 24 13 6;20 27 8 11 18 25;1 10 19 26 7 12]; tf_correct = false; assert(isequal(knights_tour(a),tf_correct))

Field = Columns 1 through 16 22 29 4 31 16 35 22 29 4 31 16 35 22 29 4 31 3 32 23 34 5 14 3 32 23 34 5 14 3 32 23 34 28 21 30 15 0 17 28 21 30 15 0 17 28 21 30 15 2 9 33 24 13 6 2 9 33 24 13 6 2 9 33 24 20 27 8 11 18 25 20 27 8 11 18 25 20 27 8 11 1 10 19 26 7 12 1 10 19 26 7 12 1 10 19 26 22 29 4 31 16 35 22 29 4 31 16 35 22 29 4 31 3 32 23 34 5 14 3 32 23 34 5 14 3 32 23 34 28 21 30 15 0 17 28 21 30 15 0 17 28 21 30 15 2 9 33 24 13 6 2 9 33 24 13 6 2 9 33 24 20 27 8 11 18 25 20 27 8 11 18 25 20 27 8 11 1 10 19 26 7 12 1 10 19 26 7 12 1 10 19 26 22 29 4 31 16 35 22 29 4 31 16 35 22 29 4 31 3 32 23 34 5 14 3 32 23 34 5 14 3 32 23 34 28 21 30 15 0 17 28 21 30 15 0 17 28 21 30 15 2 9 33 24 13 6 2 9 33 24 13 6 2 9 33 24 20 27 8 11 18 25 20 27 8 11 18 25 20 27 8 11 1 10 19 26 7 12 1 10 19 26 7 12 1 10 19 26 Columns 17 through 18 16 35 5 14 0 17 13 6 18 25 7 12 16 35 5 14 0 17 13 6 18 25 7 12 16 35 5 14 0 17 13 6 18 25 7 12

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

Field = 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0