Cody

Problem 96. Knight's Tour Checker

Solution 442661

Submitted on 14 May 2014 by Pascal Geschwill
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))

row = 3 col = 1 row2 = 1 col2 = 2 tf = 1 row = 1 col = 2 row2 = 3 col2 = 3 tf = 1 row = 3 col = 3 row2 = 2 col2 = 1 tf = 1 row = 2 col = 1 row2 = 1 col2 = 3 tf = 1 row = 1 col = 3 row2 = 3 col2 = 2 tf = 1 row = 3 col = 2 row2 = 1 col2 = 1 tf = 1 row = 1 col = 1 row2 = 2 col2 = 3 tf = 1

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

row = 1 col = 1 row2 = 2 col2 = 3 tf = 1

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))

row = 4 col = 1 row2 = 2 col2 = 2 tf = 1 row = 2 col = 2 row2 = 1 col2 = 4 tf = 1 row = 1 col = 4 row2 = 3 col2 = 3 tf = 1 row = 3 col = 3 row2 = 1 col2 = 2 tf = 1 row = 1 col = 2 row2 = 2 col2 = 4 tf = 1 row = 2 col = 4 row2 = 4 col2 = 3 tf = 1 row = 4 col = 3 row2 = 3 col2 = 1 tf = 1 row = 3 col = 1 row2 = 2 col2 = 3 tf = 1 row = 2 col = 3 row2 = 4 col2 = 4 tf = 1 row = 4 col = 4 row2 = 3 col2 = 2 tf = 1 row = 3 col = 2 row2 = 1 col2 = 3 tf = 1 row = 1 col = 3 row2 = 3 col2 = 4 tf = 1 row = 3 col = 4 row2 = 4 col2 = 2 tf = 1 row = 4 col = 2 row2 = 1 col2 = 1 tf = 0

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))

row = 4 col = 1 row2 = 2 col2 = 2 tf = 1 row = 2 col = 2 row2 = 1 col2 = 4 tf = 1 row = 1 col = 4 row2 = 3 col2 = 3 tf = 1 row = 3 col = 3 row2 = 1 col2 = 2 tf = 1 row = 1 col = 2 row2 = 2 col2 = 4 tf = 1 row = 2 col = 4 row2 = 4 col2 = 3 tf = 1 row = 4 col = 3 row2 = 3 col2 = 1 tf = 1 row = 3 col = 1 row2 = 2 col2 = 3 tf = 1 row = 2 col = 3 row2 = 4 col2 = 4 tf = 1 row = 4 col = 4 row2 = 3 col2 = 2 tf = 1 row = 3 col = 2 row2 = 1 col2 = 3 tf = 1 row = 1 col = 3 row2 = 3 col2 = 4 tf = 1 row = 3 col = 4 row2 = 4 col2 = 2 tf = 1 row = 4 col = 2 row2 = 2 col2 = 1 tf = 1

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))

row = 6 col = 1 row2 = 4 col2 = 2 tf = 1 row = 4 col = 2 row2 = 2 col2 = 1 tf = 1 row = 2 col = 1 row2 = 1 col2 = 3 tf = 1 row = 1 col = 3 row2 = 2 col2 = 5 tf = 1 row = 2 col = 5 row2 = 4 col2 = 6 tf = 1 row = 4 col = 6 row2 = 6 col2 = 5 tf = 1 row = 6 col = 5 row2 = 5 col2 = 3 tf = 1 row = 5 col = 3 row2 = 4 col2 = 1 tf = 1 row = 4 col = 1 row2 = 6 col2 = 2 tf = 1 row = 6 col = 2 row2 = 5 col2 = 4 tf = 1 row = 5 col = 4 row2 = 6 col2 = 6 tf = 1 row = 6 col = 6 row2 = 4 col2 = 5 tf = 1 row = 4 col = 5 row2 = 2 col2 = 6 tf = 1 row = 2 col = 6 row2 = 3 col2 = 4 tf = 1 row = 3 col = 4 row2 = 1 col2 = 5 tf = 1 row = 1 col = 5 row2 = 3 col2 = 6 tf = 1 row = 3 col = 6 row2 = 5 col2 = 5 tf = 1 row = 5 col = 5 row2 = 6 col2 = 3 tf = 1 row = 6 col = 3 row2 = 5 col2 = 1 tf = 1 row = 5 col = 1 row2 = 3 col2 = 2 tf = 1 row = 3 col = 2 row2 = 1 col2 = 1 tf = 1 row = 1 col = 1 row2 = 2 col2 = 3 tf = 1 row = 2 col = 3 row2 = 4 col2 = 4 tf = 1 row = 4 col = 4 row2 = 5 col2 = 6 tf = 1 row = 5 col = 6 row2 = 6 col2 = 4 tf = 1 row = 6 col = 4 row2 = 5 col2 = 2 tf = 1 row = 5 col = 2 row2 = 3 col2 = 1 tf = 1 row = 3 col = 1 row2 = 1 col2 = 2 tf = 1 row = 1 col = 2 row2 = 3 col2 = 3 tf = 1 row = 3 col = 3 row2 = 1 col2 = 4 tf = 1 row = 1 col = 4 row2 = 2 col2 = 2 tf = 1 row = 2 col = 2 row2 = 4 col2 = 3 tf = 1 row = 4 col = 3 row2 = 2 col2 = 4 tf = 1 row = 2 col = 4 row2 = 1 col2 = 6 tf = 1 row = 1 col = 6 row2 = 3 col2 = 5 tf = 1

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))

row = 6 col = 1 row2 = 4 col2 = 1 tf = 0

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

row = 1 col = 1 row2 = 3 col2 = 1 tf = 0