Cody

Solution 122891

Submitted on 3 Aug 2012 by Saptarshi Roy
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))

[1 1] [2 3] OK [1 2] [3 3] OK [1 3] [3 2] OK [2 1] [1 3] OK [2 3] [ ] Out of bound [3 1] [1 2] OK [3 2] [1 1] OK [3 3] [2 1] OK

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

[1 1] [2 3] OK [2 3] [ ] Out of bound

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

[1 1] [ ] Out of bound [1 2] [2 4] OK [1 3] [3 4] OK [1 4] [3 3] OK [2 2] [1 4] OK [2 3] [4 4] OK [2 4] [4 3] OK [3 1] [2 3] OK [3 2] [1 3] OK [3 3] [1 2] OK [3 4] [4 2] OK [4 1] [2 2] OK [4 2] [1 1] [4 3] [3 1] OK [4 4] [3 2] OK

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

[1 2] [2 4] OK [1 3] [3 4] OK [1 4] [3 3] OK [2 1] [ ] Out of bound [2 2] [1 4] OK [2 3] [4 4] OK [2 4] [4 3] OK [3 1] [2 3] OK [3 2] [1 3] OK [3 3] [1 2] OK [3 4] [4 2] OK [4 1] [2 2] OK [4 2] [2 1] OK [4 3] [3 1] OK [4 4] [3 2] OK

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

[1 1] [2 3] OK [1 2] [3 3] OK [1 3] [2 5] OK [1 4] [2 2] OK [1 5] [3 6] OK [1 6] [3 5] OK [2 1] [1 3] OK [2 2] [4 3] OK [2 3] [4 4] OK [2 4] [1 6] OK [2 5] [4 6] OK [2 6] [3 4] OK [3 1] [1 2] OK [3 2] [1 1] OK [3 3] [1 4] OK [3 4] [1 5] OK [3 5] [ ] Out of bound [3 6] [5 5] OK [4 1] [6 2] OK [4 2] [2 1] OK [4 3] [2 4] OK [4 4] [5 6] OK [4 5] [2 6] OK [4 6] [6 5] OK [5 1] [3 2] OK [5 2] [3 1] OK [5 3] [4 1] OK [5 4] [6 6] OK [5 5] [6 3] OK [5 6] [6 4] OK [6 1] [4 2] OK [6 2] [5 4] OK [6 3] [5 1] OK [6 4] [5 2] OK [6 5] [5 3] OK [6 6] [4 5] OK

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

[1 1] [2 3] OK [1 2] [3 3] OK [1 3] [2 5] OK [1 4] [2 2] OK [1 5] [3 6] OK [1 6] [ ] Out of bound [2 1] [1 3] OK [2 2] [4 3] OK [2 3] [4 4] OK [2 4] [1 6] OK [2 5] [4 6] OK [2 6] [3 4] OK [3 1] [1 2] OK [3 2] [1 1] OK [3 3] [1 4] OK [3 4] [1 5] OK [3 6] [5 5] OK [4 1] [2 1] [4 2] [6 2] [4 3] [2 4] OK [4 4] [5 6] OK [4 5] [2 6] OK [4 6] [6 5] OK [5 1] [3 2] OK [5 2] [3 1] OK [5 3] [4 2] [5 4] [6 6] OK [5 5] [6 3] OK [5 6] [6 4] OK [6 1] [4 1] [6 2] [5 4] OK [6 3] [5 1] OK [6 4] [5 2] OK [6 5] [5 3] OK [6 6] [4 5] OK

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

[1 1] [3 1] [3 1] [ ] Out of bound