Cody

Solution 948751

Submitted on 1 Sep 2016 by Riazul Arefin
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))

r = 3 c = 1 p = 1 r = 1 c = 2 p = 1 1 r = 3 c = 3 p = 1 1 1 r = 2 c = 1 p = 1 1 1 1 r = 1 c = 3 p = 1 1 1 1 1 r = 3 c = 2 p = 1 1 1 1 1 1 r = 1 c = 1 p = 1 1 1 1 1 1 1

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

r = 1 c = 1 p = 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))

r = 4 c = 1 p = 1 r = 2 c = 2 p = 1 1 r = 1 c = 4 p = 1 1 1 r = 3 c = 3 p = 1 1 1 1 r = 1 c = 2 p = 1 1 1 1 1 r = 2 c = 4 p = 1 1 1 1 1 1 r = 4 c = 3 p = 1 1 1 1 1 1 1 r = 3 c = 1 p = 1 1 1 1 1 1 1 1 r = 2 c = 3 p = 1 1 1 1 1 1 1 1 1 r = 4 c = 4 p = 1 1 1 1 1 1 1 1 1 1 r = 3 c = 2 p = 1 1 1 1 1 1 1 1 1 1 1 r = 1 c = 3 p = 1 1 1 1 1 1 1 1 1 1 1 1 r = 3 c = 4 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 4 c = 2 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 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))

r = 4 c = 1 p = 1 r = 2 c = 2 p = 1 1 r = 1 c = 4 p = 1 1 1 r = 3 c = 3 p = 1 1 1 1 r = 1 c = 2 p = 1 1 1 1 1 r = 2 c = 4 p = 1 1 1 1 1 1 r = 4 c = 3 p = 1 1 1 1 1 1 1 r = 3 c = 1 p = 1 1 1 1 1 1 1 1 r = 2 c = 3 p = 1 1 1 1 1 1 1 1 1 r = 4 c = 4 p = 1 1 1 1 1 1 1 1 1 1 r = 3 c = 2 p = 1 1 1 1 1 1 1 1 1 1 1 r = 1 c = 3 p = 1 1 1 1 1 1 1 1 1 1 1 1 r = 3 c = 4 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 4 c = 2 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 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))

r = 6 c = 1 p = 1 r = 4 c = 2 p = 1 1 r = 2 c = 1 p = 1 1 1 r = 1 c = 3 p = 1 1 1 1 r = 2 c = 5 p = 1 1 1 1 1 r = 4 c = 6 p = 1 1 1 1 1 1 r = 6 c = 5 p = 1 1 1 1 1 1 1 r = 5 c = 3 p = 1 1 1 1 1 1 1 1 r = 4 c = 1 p = 1 1 1 1 1 1 1 1 1 r = 6 c = 2 p = 1 1 1 1 1 1 1 1 1 1 r = 5 c = 4 p = 1 1 1 1 1 1 1 1 1 1 1 r = 6 c = 6 p = 1 1 1 1 1 1 1 1 1 1 1 1 r = 4 c = 5 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 2 c = 6 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 3 c = 4 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 c = 5 p = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 3 c = 6 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Column 17 1 r = 5 c = 5 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 18 1 1 r = 6 c = 3 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 19 1 1 1 r = 5 c = 1 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 20 1 1 1 1 r = 3 c = 2 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 21 1 1 1 1 1 r = 1 c = 1 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 22 1 1 1 1 1 1 r = 2 c = 3 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 23 1 1 1 1 1 1 1 r = 4 c = 4 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 24 1 1 1 1 1 1 1 1 r = 5 c = 6 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 25 1 1 1 1 1 1 1 1 1 r = 6 c = 4 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 26 1 1 1 1 1 1 1 1 1 1 r = 5 c = 2 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 27 1 1 1 1 1 1 1 1 1 1 1 r = 3 c = 1 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 28 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 c = 2 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 3 c = 3 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 c = 4 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 31 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 2 c = 2 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 4 c = 3 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Column 33 1 r = 2 c = 4 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 33 through 34 1 1 r = 1 c = 6 p = Columns 1 through 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 17 through 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 33 through 35 1 1 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))

r = 6 c = 1 p = 0 r = 4 c = 1 p = 0 0 r = 2 c = 1 p = 0 0 1 r = 1 c = 3 p = 0 0 1 1 r = 2 c = 5 p = 0 0 1 1 1 r = 4 c = 6 p = 0 0 1 1 1 1 r = 6 c = 5 p = 0 0 1 1 1 1 1 r = 5 c = 3 p = 0 0 1 1 1 1 1 0 r = 4 c = 2 p = 0 0 1 1 1 1 1 0 0 r = 6 c = 2 p = 0 0 1 1 1 1 1 0 0 1 r = 5 c = 4 p = 0 0 1 1 1 1 1 0 0 1 1 r = 6 c = 6 p = 0 0 1 1 1 1 1 0 0 1 1 1 r = 4 c = 5 p = 0 0 1 1 1 1 1 0 0 1 1 1 1 r = 2 c = 6 p = 0 0 1 1 1 1 1 0 0 1 1 1 1 1 r = 3 c = 4 p = 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 r = 1 c = 5 p = 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 r = 3 c = 6 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Column 17 1 r = 5 c = 5 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 18 1 1 r = 6 c = 3 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 19 1 1 1 r = 5 c = 1 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 20 1 1 1 1 r = 3 c = 2 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 21 1 1 1 1 1 r = 1 c = 1 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 22 1 1 1 1 1 1 r = 2 c = 3 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 23 1 1 1 1 1 1 1 r = 4 c = 4 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 24 1 1 1 1 1 1 1 1 r = 5 c = 6 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 25 1 1 1 1 1 1 1 1 1 r = 6 c = 4 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 26 1 1 1 1 1 1 1 1 1 1 r = 5 c = 2 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 27 1 1 1 1 1 1 1 1 1 1 1 r = 3 c = 1 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 28 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 c = 2 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 29 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 3 c = 3 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 30 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 1 c = 4 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 31 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 2 c = 2 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 r = 4 c = 3 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Column 33 1 r = 2 c = 4 p = Columns 1 through 16 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 Columns 17 through 32 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 33 through 34 1 1

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

r = 1 c = 1 p = 0

Suggested Problems

More from this Author95