Cody

Problem 96. Knight's Tour Checker

Solution 2954566

Submitted on 16 Sep 2020 by Drake Madison
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))

step = 2 re = 1 ce = 2 r_diff = 2 c_diff = 1 step = 3 re = 3 ce = 3 r_diff = 2 c_diff = 1 step = 4 re = 2 ce = 1 r_diff = 1 c_diff = 2 step = 5 re = 1 ce = 3 r_diff = 1 c_diff = 2 step = 6 re = 3 ce = 2 r_diff = 2 c_diff = 1 step = 7 re = 1 ce = 1 r_diff = 2 c_diff = 1 step = 8 re = 2 ce = 3 r_diff = 1 c_diff = 2 step = 9 re = 0×1 empty double column vector ce = 0×1 empty double column vector done = logical 1

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

step = 2 re = 2 ce = 3 r_diff = 1 c_diff = 2 step = 3 re = 0×1 empty double column vector ce = 0×1 empty double column vector done = 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))

step = 2 re = 2 ce = 2 r_diff = 2 c_diff = 1 step = 3 re = 1 ce = 4 r_diff = 1 c_diff = 2 step = 4 re = 3 ce = 3 r_diff = 2 c_diff = 1 step = 5 re = 1 ce = 2 r_diff = 2 c_diff = 1 step = 6 re = 2 ce = 4 r_diff = 1 c_diff = 2 step = 7 re = 4 ce = 3 r_diff = 2 c_diff = 1 step = 8 re = 3 ce = 1 r_diff = 1 c_diff = 2 step = 9 re = 2 ce = 3 r_diff = 1 c_diff = 2 step = 10 re = 4 ce = 4 r_diff = 2 c_diff = 1 step = 11 re = 3 ce = 2 r_diff = 1 c_diff = 2 step = 12 re = 1 ce = 3 r_diff = 2 c_diff = 1 step = 13 re = 3 ce = 4 r_diff = 2 c_diff = 1 step = 14 re = 4 ce = 2 r_diff = 1 c_diff = 2 step = 15 re = 1 ce = 1 r_diff = 3 c_diff = 1

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

step = 2 re = 2 ce = 2 r_diff = 2 c_diff = 1 step = 3 re = 1 ce = 4 r_diff = 1 c_diff = 2 step = 4 re = 3 ce = 3 r_diff = 2 c_diff = 1 step = 5 re = 1 ce = 2 r_diff = 2 c_diff = 1 step = 6 re = 2 ce = 4 r_diff = 1 c_diff = 2 step = 7 re = 4 ce = 3 r_diff = 2 c_diff = 1 step = 8 re = 3 ce = 1 r_diff = 1 c_diff = 2 step = 9 re = 2 ce = 3 r_diff = 1 c_diff = 2 step = 10 re = 4 ce = 4 r_diff = 2 c_diff = 1 step = 11 re = 3 ce = 2 r_diff = 1 c_diff = 2 step = 12 re = 1 ce = 3 r_diff = 2 c_diff = 1 step = 13 re = 3 ce = 4 r_diff = 2 c_diff = 1 step = 14 re = 4 ce = 2 r_diff = 1 c_diff = 2 step = 15 re = 2 ce = 1 r_diff = 2 c_diff = 1 step = 16 re = 0×1 empty double column vector ce = 0×1 empty double column vector done = 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))

step = 2 re = 4 ce = 2 r_diff = 2 c_diff = 1 step = 3 re = 2 ce = 1 r_diff = 2 c_diff = 1 step = 4 re = 1 ce = 3 r_diff = 1 c_diff = 2 step = 5 re = 2 ce = 5 r_diff = 1 c_diff = 2 step = 6 re = 4 ce = 6 r_diff = 2 c_diff = 1 step = 7 re = 6 ce = 5 r_diff = 2 c_diff = 1 step = 8 re = 5 ce = 3 r_diff = 1 c_diff = 2 step = 9 re = 4 ce = 1 r_diff = 1 c_diff = 2 step = 10 re = 6 ce = 2 r_diff = 2 c_diff = 1 step = 11 re = 5 ce = 4 r_diff = 1 c_diff = 2 step = 12 re = 6 ce = 6 r_diff = 1 c_diff = 2 step = 13 re = 4 ce = 5 r_diff = 2 c_diff = 1 step = 14 re = 2 ce = 6 r_diff = 2 c_diff = 1 step = 15 re = 3 ce = 4 r_diff = 1 c_diff = 2 step = 16 re = 1 ce = 5 r_diff = 2 c_diff = 1 step = 17 re = 3 ce = 6 r_diff = 2 c_diff = 1 step = 18 re = 5 ce = 5 r_diff = 2 c_diff = 1 step = 19 re = 6 ce = 3 r_diff = 1 c_diff = 2 step = 20 re = 5 ce = 1 r_diff = 1 c_diff = 2 step = 21 re = 3 ce = 2 r_diff = 2 c_diff = 1 step = 22 re = 1 ce = 1 r_diff = 2 c_diff = 1 step = 23 re = 2 ce = 3 r_diff = 1 c_diff = 2 step = 24 re = 4 ce = 4 r_diff = 2 c_diff = 1 step = 25 re = 5 ce = 6 r_diff = 1 c_diff = 2 step = 26 re = 6 ce = 4 r_diff = 1 c_diff = 2 step = 27 re = 5 ce = 2 r_diff = 1 c_diff = 2 step = 28 re = 3 ce = 1 r_diff = 2 c_diff = 1 step = 29 re = 1 ce = 2 r_diff = 2 c_diff = 1 step = 30 re = 3 ce = 3 r_diff = 2 c_diff = 1 step = 31 re = 1 ce = 4 r_diff = 2 c_diff = 1 step = 32 re = 2 ce = 2 r_diff = 1 c_diff = 2 step = 33 re = 4 ce = 3 r_diff = 2 c_diff = 1 step = 34 re = 2 ce = 4 r_diff = 2 c_diff = 1 step = 35 re = 1 ce = 6 r_diff = 1 c_diff = 2 step = 36 re = 3 ce = 5 r_diff = 2 c_diff = 1 step = 37 re = 0×1 empty double column vector ce = 0×1 empty double column vector done = 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))

step = 2 re = 4 ce = 1 r_diff = 2 c_diff = 0

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

step = 2 re = 3 ce = 1 r_diff = 2 c_diff = 0

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!