Cody

Solution 45277

Submitted on 19 Feb 2012 by Sven
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))

val = 0 1 2 3 4 5 6 7 8 ord = 5 3 4 9 2 7 6 1 8 i = 3 1 3 2 1 3 1 2 j = 1 2 3 1 3 2 1 3 tf = 1

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

val = 0 0 0 0 1 2 ord = 2 3 4 5 1 6 i = 1 2 j = 1 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))

val = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ord = 2 4 6 13 11 5 14 12 3 10 16 7 9 15 8 1 i = 4 2 1 3 1 2 4 3 2 4 3 1 3 4 1 j = 1 2 4 3 2 4 3 1 3 4 2 3 4 2 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))

val = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ord = 1 4 6 13 11 5 14 12 3 10 16 7 9 15 8 2 i = 4 2 1 3 1 2 4 3 2 4 3 1 3 4 2 j = 1 2 4 3 2 4 3 1 3 4 2 3 4 2 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))

val = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ord = 6 10 2 13 26 34 30 17 4 12 23 36 28 32 21 25 33 29 18 5 9 1 14 22 35 24 11 3 7 15 19 8 16 20 31 27 i = 6 4 2 1 2 4 6 5 4 6 5 6 4 2 3 1 3 5 6 5 3 1 2 4 5 6 5 3 1 3 1 2 4 2 1 3 j = 1 2 1 3 5 6 5 3 1 2 4 6 5 6 4 5 6 5 3 1 2 1 3 4 6 4 2 1 2 3 4 2 3 4 6 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))

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

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

val = 0 0 0 0 0 0 0 1 2 ord = 2 4 5 6 7 8 9 1 3 i = 1 3 j = 1 1 tf = 0