Cody

Solution 2081218

Submitted on 6 Jan 2020 by Nico Noordam
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))

s = 3 3 l = 9 m = 7 1 4 2 1 3 2 4 0 5 6 6 5 7 8 8 3 9 m = 0 5 1 3 2 4 3 9 4 2 5 7 6 6 7 1 8 8 i = 1 i = 2 tf = logical 1 r1 = 3 c1 = 1 r2 = 1 c2 = 2 i = 3 r1 = 1 c1 = 2 r2 = 3 c2 = 3 i = 4 r1 = 3 c1 = 3 r2 = 2 c2 = 1 i = 5 r1 = 2 c1 = 1 r2 = 1 c2 = 3 i = 6 r1 = 1 c1 = 3 r2 = 3 c2 = 2 i = 7 r1 = 3 c1 = 2 r2 = 1 c2 = 1 i = 8 r1 = 1 c1 = 1 r2 = 2 c2 = 3 i = 9

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

s = 2 3 l = 6 m = 1 1 0 2 0 3 0 4 0 5 2 6 m = 0 2 0 3 0 4 0 5 1 1 2 6 i = 1 i = 2 i = 3 i = 4 i = 5 tf = logical 1 r1 = 1 c1 = 1 r2 = 2 c2 = 3 i = 6

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

s = 4 4 l = 16 m = 15 1 0 2 8 3 1 4 5 5 2 6 11 7 14 8 12 9 9 10 4 11 7 12 3 13 6 14 13 15 10 16 m = 0 2 1 4 2 6 3 13 4 11 5 5 6 14 7 12 8 3 9 10 10 16 11 7 12 9 13 15 14 8 15 1 i = 1 i = 2 tf = logical 1 r1 = 4 c1 = 1 r2 = 2 c2 = 2 i = 3 r1 = 2 c1 = 2 r2 = 1 c2 = 4 i = 4 r1 = 1 c1 = 4 r2 = 3 c2 = 3 i = 5 r1 = 3 c1 = 3 r2 = 1 c2 = 2 i = 6 r1 = 1 c1 = 2 r2 = 2 c2 = 4 i = 7 r1 = 2 c1 = 4 r2 = 4 c2 = 3 i = 8 r1 = 4 c1 = 3 r2 = 3 c2 = 1 i = 9 r1 = 3 c1 = 1 r2 = 2 c2 = 3 i = 10 r1 = 2 c1 = 3 r2 = 4 c2 = 4 i = 11 r1 = 4 c1 = 4 r2 = 3 c2 = 2 i = 12 r1 = 3 c1 = 2 r2 = 1 c2 = 3 i = 13 r1 = 1 c1 = 3 r2 = 3 c2 = 4 i = 14 r1 = 3 c1 = 4 r2 = 4 c2 = 2 i = 15 r1 = 4 c1 = 2 r2 = 1 c2 = 1 tf = logical 0 i = 16 i = 17

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

s = 4 4 l = 16 m = 0 1 15 2 8 3 1 4 5 5 2 6 11 7 14 8 12 9 9 10 4 11 7 12 3 13 6 14 13 15 10 16 m = 0 1 1 4 2 6 3 13 4 11 5 5 6 14 7 12 8 3 9 10 10 16 11 7 12 9 13 15 14 8 15 2 i = 1 i = 2 tf = logical 1 r1 = 4 c1 = 1 r2 = 2 c2 = 2 i = 3 r1 = 2 c1 = 2 r2 = 1 c2 = 4 i = 4 r1 = 1 c1 = 4 r2 = 3 c2 = 3 i = 5 r1 = 3 c1 = 3 r2 = 1 c2 = 2 i = 6 r1 = 1 c1 = 2 r2 = 2 c2 = 4 i = 7 r1 = 2 c1 = 4 r2 = 4 c2 = 3 i = 8 r1 = 4 c1 = 3 r2 = 3 c2 = 1 i = 9 r1 = 3 c1 = 1 r2 = 2 c2 = 3 i = 10 r1 = 2 c1 = 3 r2 = 4 c2 = 4 i = 11 r1 = 4 c1 = 4 r2 = 3 c2 = 2 i = 12 r1 = 3 c1 = 2 r2 = 1 c2 = 3 i = 13 r1 = 1 c1 = 3 r2 = 3 c2 = 4 i = 14 r1 = 3 c1 = 4 r2 = 4 c2 = 2 i = 15 r1 = 4 c1 = 2 r2 = 2 c2 = 1 i = 16

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

s = 6 6 l = 36 m = 22 1 3 2 28 3 9 4 20 5 1 6 29 7 32 8 21 9 2 10 27 11 10 12 4 13 23 14 30 15 33 16 8 17 19 18 31 19 34 20 15 21 24 22 11 23 26 24 16 25 5 26 36 27 13 28 18 29 7 30 35 31 14 32 17 33 6 34 25 35 12 36 m = 1 6 2 10 3 2 4 13 5 26 6 34 7 30 8 17 9 4 10 12 11 23 12 36 13 28 14 32 15 21 16 25 17 33 18 29 19 18 20 5 21 9 22 1 23 14 24 22 25 35 26 24 27 11 28 3 29 7 30 15 31 19 32 8 33 16 34 20 35 31 36 27 i = 1 tf = logical 1 r1 = 6 c1 = 1 r2 = 4 c2 = 2 i = 2 r1 = 4 c1 = 2 r2 = 2 c2 = 1 i = 3 r1 = 2 c1 = 1 r2 = 1 c2 = 3 i = 4 r1 = 1 c1 = 3 r2 = 2 c2 = 5 i = 5 r1 = 2 c1 = 5 r2 = 4 c2 = 6 i = 6 r1 = 4 c1 = 6 r2 = 6 c2 = 5 i = 7 r1 = 6 c1 = 5 r2 = 5 c2 = 3 i = 8 r1 = 5 c1 = 3 r2 = 4 c2 = 1 i = 9 r1 = 4 c1 = 1 r2 = 6 c2 = 2 i = 10 r1 = 6 c1 = 2 r2 = 5 c2 = 4 i = 11 r1 = 5 c1 = 4 r2 = 6 c2 = 6 i = 12 r1 = 6 c1 = 6 r2 = 4 c2 = 5 i = 13 r1 = 4 c1 = 5 r2 = 2 c2 = 6 i = 14 r1 = 2 c1 = 6 r2 = 3 c2 = 4 i = 15 r1 = 3 c1 = 4 r2 = 1 c2 = 5 i = 16 r1 = 1 c1 = 5 r2 = 3 c2 = 6 i = 17 r1 = 3 c1 = 6 r2 = 5 c2 = 5 i = 18 r1 = 5 c1 = 5 r2 = 6 c2 = 3 i = 19 r1 = 6 c1 = 3 r2 = 5 c2 = 1 i = 20 r1 = 5 c1 = 1 r2 = 3 c2 = 2 i = 21 r1 = 3 c1 = 2 r2 = 1 c2 = 1 i = 22 r1 = 1 c1 = 1 r2 = 2 c2 = 3 i = 23 r1 = 2 c1 = 3 r2 = 4 c2 = 4 i = 24 r1 = 4 c1 = 4 r2 = 5 c2 = 6 i = 25 r1 = 5 c1 = 6 r2 = 6 c2 = 4 i = 26 r1 = 6 c1 = 4 r2 = 5 c2 = 2 i = 27 r1 = 5 c1 = 2 r2 = 3 c2 = 1 i = 28 r1 = 3 c1 = 1 r2 = 1 c2 = 2 i = 29 r1 = 1 c1 = 2 r2 = 3 c2 = 3 i = 30 r1 = 3 c1 = 3 r2 = 1 c2 = 4 i = 31 r1 = 1 c1 = 4 r2 = 2 c2 = 2 i = 32 r1 = 2 c1 = 2 r2 = 4 c2 = 3 i = 33 r1 = 4 c1 = 3 r2 = 2 c2 = 4 i = 34 r1 = 2 c1 = 4 r2 = 1 c2 = 6 i = 35 r1 = 1 c1 = 6 r2 = 3 c2 = 5 i = 36

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

s = 6 6 l = 36 m = 22 1 3 2 28 3 2 4 20 5 1 6 29 7 32 8 21 9 9 10 27 11 10 12 4 13 23 14 30 15 33 16 8 17 19 18 31 19 34 20 15 21 24 22 11 23 26 24 16 25 5 26 0 27 13 28 18 29 7 30 35 31 14 32 17 33 6 34 25 35 12 36 m = 0 27 1 6 2 4 3 2 4 13 5 26 6 34 7 30 8 17 9 10 10 12 11 23 12 36 13 28 14 32 15 21 16 25 17 33 18 29 19 18 20 5 21 9 22 1 23 14 24 22 25 35 26 24 27 11 28 3 29 7 30 15 31 19 32 8 33 16 34 20 35 31 i = 1 i = 2 tf = logical 1 r1 = 6 c1 = 1 r2 = 4 c2 = 1 tf = logical 0 i = 36 i = 37

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

s = 3 3 l = 9 m = 1 1 0 2 2 3 0 4 0 5 0 6 0 7 0 8 0 9 m = 0 2 0 4 0 5 0 6 0 7 0 8 0 9 1 1 2 3 i = 1 i = 2 i = 3 i = 4 i = 5 i = 6 i = 7 i = 8 tf = logical 1 r1 = 1 c1 = 1 r2 = 3 c2 = 1 tf = logical 0 i = 9 i = 10

Suggested Problems

More from this Author95