Cody

# Problem 96. Knight's Tour Checker

Solution 2232588

Submitted on 24 Apr 2020 by shaikh akbar shaikh rasul
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))

x1 = 3 y1 = 1 x2 = 1 y2 = 2 tf = logical 1 c = 2 x1 = 1 y1 = 2 x2 = 3 y2 = 3 tf = logical 1 c = 3 x1 = 3 y1 = 3 x2 = 2 y2 = 1 tf = logical 1 c = 4 x1 = 2 y1 = 1 x2 = 1 y2 = 3 tf = logical 1 c = 5 x1 = 1 y1 = 3 x2 = 3 y2 = 2 tf = logical 1 c = 6 x1 = 3 y1 = 2 x2 = 1 y2 = 1 tf = logical 1 c = 7 x1 = 1 y1 = 1 x2 = 2 y2 = 3 tf = logical 1 c = 8

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

x1 = 1 y1 = 1 x2 = 2 y2 = 3 tf = logical 1 c = 2

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

x1 = 4 y1 = 1 x2 = 2 y2 = 2 tf = logical 1 c = 2 x1 = 2 y1 = 2 x2 = 1 y2 = 4 tf = logical 1 c = 3 x1 = 1 y1 = 4 x2 = 3 y2 = 3 tf = logical 1 c = 4 x1 = 3 y1 = 3 x2 = 1 y2 = 2 tf = logical 1 c = 5 x1 = 1 y1 = 2 x2 = 2 y2 = 4 tf = logical 1 c = 6 x1 = 2 y1 = 4 x2 = 4 y2 = 3 tf = logical 1 c = 7 x1 = 4 y1 = 3 x2 = 3 y2 = 1 tf = logical 1 c = 8 x1 = 3 y1 = 1 x2 = 2 y2 = 3 tf = logical 1 c = 9 x1 = 2 y1 = 3 x2 = 4 y2 = 4 tf = logical 1 c = 10 x1 = 4 y1 = 4 x2 = 3 y2 = 2 tf = logical 1 c = 11 x1 = 3 y1 = 2 x2 = 1 y2 = 3 tf = logical 1 c = 12 x1 = 1 y1 = 3 x2 = 3 y2 = 4 tf = logical 1 c = 13 x1 = 3 y1 = 4 x2 = 4 y2 = 2 tf = logical 1 c = 14 x1 = 4 y1 = 2 x2 = 1 y2 = 1 c = 15

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

x1 = 4 y1 = 1 x2 = 2 y2 = 2 tf = logical 1 c = 2 x1 = 2 y1 = 2 x2 = 1 y2 = 4 tf = logical 1 c = 3 x1 = 1 y1 = 4 x2 = 3 y2 = 3 tf = logical 1 c = 4 x1 = 3 y1 = 3 x2 = 1 y2 = 2 tf = logical 1 c = 5 x1 = 1 y1 = 2 x2 = 2 y2 = 4 tf = logical 1 c = 6 x1 = 2 y1 = 4 x2 = 4 y2 = 3 tf = logical 1 c = 7 x1 = 4 y1 = 3 x2 = 3 y2 = 1 tf = logical 1 c = 8 x1 = 3 y1 = 1 x2 = 2 y2 = 3 tf = logical 1 c = 9 x1 = 2 y1 = 3 x2 = 4 y2 = 4 tf = logical 1 c = 10 x1 = 4 y1 = 4 x2 = 3 y2 = 2 tf = logical 1 c = 11 x1 = 3 y1 = 2 x2 = 1 y2 = 3 tf = logical 1 c = 12 x1 = 1 y1 = 3 x2 = 3 y2 = 4 tf = logical 1 c = 13 x1 = 3 y1 = 4 x2 = 4 y2 = 2 tf = logical 1 c = 14 x1 = 4 y1 = 2 x2 = 2 y2 = 1 tf = logical 1 c = 15

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

x1 = 6 y1 = 1 x2 = 4 y2 = 2 tf = logical 1 c = 2 x1 = 4 y1 = 2 x2 = 2 y2 = 1 tf = logical 1 c = 3 x1 = 2 y1 = 1 x2 = 1 y2 = 3 tf = logical 1 c = 4 x1 = 1 y1 = 3 x2 = 2 y2 = 5 tf = logical 1 c = 5 x1 = 2 y1 = 5 x2 = 4 y2 = 6 tf = logical 1 c = 6 x1 = 4 y1 = 6 x2 = 6 y2 = 5 tf = logical 1 c = 7 x1 = 6 y1 = 5 x2 = 5 y2 = 3 tf = logical 1 c = 8 x1 = 5 y1 = 3 x2 = 4 y2 = 1 tf = logical 1 c = 9 x1 = 4 y1 = 1 x2 = 6 y2 = 2 tf = logical 1 c = 10 x1 = 6 y1 = 2 x2 = 5 y2 = 4 tf = logical 1 c = 11 x1 = 5 y1 = 4 x2 = 6 y2 = 6 tf = logical 1 c = 12 x1 = 6 y1 = 6 x2 = 4 y2 = 5 tf = logical 1 c = 13 x1 = 4 y1 = 5 x2 = 2 y2 = 6 tf = logical 1 c = 14 x1 = 2 y1 = 6 x2 = 3 y2 = 4 tf = logical 1 c = 15 x1 = 3 y1 = 4 x2 = 1 y2 = 5 tf = logical 1 c = 16 x1 = 1 y1 = 5 x2 = 3 y2 = 6 tf = logical 1 c = 17 x1 = 3 y1 = 6 x2 = 5 y2 = 5 tf = logical 1 c = 18 x1 = 5 y1 = 5 x2 = 6 y2 = 3 tf = logical 1 c = 19 x1 = 6 y1 = 3 x2 = 5 y2 = 1 tf = logical 1 c = 20 x1 = 5 y1 = 1 x2 = 3 y2 = 2 tf = logical 1 c = 21 x1 = 3 y1 = 2 x2 = 1 y2 = 1 tf = logical 1 c = 22 x1 = 1 y1 = 1 x2 = 2 y2 = 3 tf = logical 1 c = 23 x1 = 2 y1 = 3 x2 = 4 y2 = 4 tf = logical 1 c = 24 x1 = 4 y1 = 4 x2 = 5 y2 = 6 tf = logical 1 c = 25 x1 = 5 y1 = 6 x2 = 6 y2 = 4 tf = logical 1 c = 26 x1 = 6 y1 = 4 x2 = 5 y2 = 2 tf = logical 1 c = 27 x1 = 5 y1 = 2 x2 = 3 y2 = 1 tf = logical 1 c = 28 x1 = 3 y1 = 1 x2 = 1 y2 = 2 tf = logical 1 c = 29 x1 = 1 y1 = 2 x2 = 3 y2 = 3 tf = logical 1 c = 30 x1 = 3 y1 = 3 x2 = 1 y2 = 4 tf = logical 1 c = 31 x1 = 1 y1 = 4 x2 = 2 y2 = 2 tf = logical 1 c = 32 x1 = 2 y1 = 2 x2 = 4 y2 = 3 tf = logical 1 c = 33 x1 = 4 y1 = 3 x2 = 2 y2 = 4 tf = logical 1 c = 34 x1 = 2 y1 = 4 x2 = 1 y2 = 6 tf = logical 1 c = 35 x1 = 1 y1 = 6 x2 = 3 y2 = 5 tf = logical 1 c = 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))

x1 = 6 y1 = 1 x2 = 4 y2 = 1 c = 2

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

x1 = 1 y1 = 1 x2 = 3 y2 = 1 c = 2

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!