Cody

# Problem 96. Knight's Tour Checker

Solution 2615404

Submitted on 26 Jun 2020 by Li Kehan Li
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))

c = 3 d = 1 f = 1 g = 2 e = 1 c = 1 d = 2 f = 3 g = 3 e = 2 c = 3 d = 3 f = 2 g = 1 e = 3 c = 2 d = 1 f = 1 g = 3 e = 4 c = 1 d = 3 f = 3 g = 2 e = 5 c = 3 d = 2 f = 1 g = 1 e = 6 c = 1 d = 1 f = 2 g = 3 e = 7 tf = logical 1

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

c = 1 d = 1 f = 2 g = 3 e = 1 tf = logical 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))

c = 4 d = 1 f = 2 g = 2 e = 1 c = 2 d = 2 f = 1 g = 4 e = 2 c = 1 d = 4 f = 3 g = 3 e = 3 c = 3 d = 3 f = 1 g = 2 e = 4 c = 1 d = 2 f = 2 g = 4 e = 5 c = 2 d = 4 f = 4 g = 3 e = 6 c = 4 d = 3 f = 3 g = 1 e = 7 c = 3 d = 1 f = 2 g = 3 e = 8 c = 2 d = 3 f = 4 g = 4 e = 9 c = 4 d = 4 f = 3 g = 2 e = 10 c = 3 d = 2 f = 1 g = 3 e = 11 c = 1 d = 3 f = 3 g = 4 e = 12 c = 3 d = 4 f = 4 g = 2 e = 13 c = 4 d = 2 f = 1 g = 1 e = 13 tf = logical 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))

c = 4 d = 1 f = 2 g = 2 e = 1 c = 2 d = 2 f = 1 g = 4 e = 2 c = 1 d = 4 f = 3 g = 3 e = 3 c = 3 d = 3 f = 1 g = 2 e = 4 c = 1 d = 2 f = 2 g = 4 e = 5 c = 2 d = 4 f = 4 g = 3 e = 6 c = 4 d = 3 f = 3 g = 1 e = 7 c = 3 d = 1 f = 2 g = 3 e = 8 c = 2 d = 3 f = 4 g = 4 e = 9 c = 4 d = 4 f = 3 g = 2 e = 10 c = 3 d = 2 f = 1 g = 3 e = 11 c = 1 d = 3 f = 3 g = 4 e = 12 c = 3 d = 4 f = 4 g = 2 e = 13 c = 4 d = 2 f = 2 g = 1 e = 14 tf = logical 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))

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

c = 6 d = 1 f = 4 g = 1 e = 0 c = 4 d = 1 f = 2 g = 1 e = 0 c = 2 d = 1 f = 1 g = 3 e = 1 c = 1 d = 3 f = 2 g = 5 e = 2 c = 2 d = 5 f = 4 g = 6 e = 3 c = 4 d = 6 f = 6 g = 5 e = 4 c = 6 d = 5 f = 5 g = 3 e = 5 c = 5 d = 3 f = 4 g = 2 e = 6 c = 4 d = 2 f = 6 g = 2 e = 6 c = 6 d = 2 f = 5 g = 4 e = 7 c = 5 d = 4 f = 6 g = 6 e = 8 c = 6 d = 6 f = 4 g = 5 e = 9 c = 4 d = 5 f = 2 g = 6 e = 10 c = 2 d = 6 f = 3 g = 4 e = 11 c = 3 d = 4 f = 1 g = 5 e = 12 c = 1 d = 5 f = 3 g = 6 e = 13 c = 3 d = 6 f = 5 g = 5 e = 14 c = 5 d = 5 f = 6 g = 3 e = 15 c = 6 d = 3 f = 5 g = 1 e = 16 c = 5 d = 1 f = 3 g = 2 e = 17 c = 3 d = 2 f = 1 g = 1 e = 18 c = 1 d = 1 f = 2 g = 3 e = 19 c = 2 d = 3 f = 4 g = 4 e = 20 c = 4 d = 4 f = 5 g = 6 e = 21 c = 5 d = 6 f = 6 g = 4 e = 22 c = 6 d = 4 f = 5 g = 2 e = 23 c = 5 d = 2 f = 3 g = 1 e = 24 c = 3 d = 1 f = 1 g = 2 e = 25 c = 1 d = 2 f = 3 g = 3 e = 26 c = 3 d = 3 f = 1 g = 4 e = 27 c = 1 d = 4 f = 2 g = 2 e = 28 c = 2 d = 2 f = 4 g = 3 e = 29 c = 4 d = 3 f = 2 g = 4 e = 30 c = 2 d = 4 f = 1 g = 6 e = 31 tf = logical 0

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

c = 1 d = 1 f = 3 g = 1 e = 0 tf = logical 0

### Community Treasure Hunt

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

Start Hunting!