Cody

Problem 96. Knight's Tour Checker

Solution 2637232

Submitted on 1 Jul 2020
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   Fail
a = ... [ 7 2 5 4 0 8 1 6 3]; tf_correct = true; assert(isequal(knights_tour(a),tf_correct))

ic = 8 5 2 3 1 7 6 9 4 cnt = 1 1 1 1 1 1 1 1 1 lastv = 8 cp = 1 1 r = 3 c = 3 cp = 3 1 np = 1 2 cp = 1 2 cv = 2 found = logical 1 np = -1 3

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in knights_tour (line 26) if a(np(1), np(2)) == cv + 1 Error in Test1 (line 6) assert(isequal(knights_tour(a),tf_correct))

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

ic = 2 1 1 1 1 3 cnt = 4 1 1 lastv = 2 cp = 1 1 r = 2 c = 3 cp = 1 1 np = -1 2

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in knights_tour (line 26) if a(np(1), np(2)) == cv + 1 Error in Test2 (line 5) assert(isequal(knights_tour(a),tf_correct))

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

ic = 16 1 9 2 6 3 12 15 13 10 5 8 4 7 14 11 cnt = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 lastv = 15 cp = 1 1 r = 4 c = 4 cp = 4 1 np = 2 2 cp = 2 2 cv = 2 found = logical 1 np = 0 3

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in knights_tour (line 26) if a(np(1), np(2)) == cv + 1 Error in Test3 (line 7) assert(isequal(knights_tour(a),tf_correct))

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

ic = 1 16 9 2 6 3 12 15 13 10 5 8 4 7 14 11 cnt = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 lastv = 15 cp = 1 1 r = 4 c = 4 cp = 4 1 np = 2 2 cp = 2 2 cv = 2 found = logical 1 np = 0 3

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in knights_tour (line 26) if a(np(1), np(2)) == cv + 1 Error in Test4 (line 7) assert(isequal(knights_tour(a),tf_correct))

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

ic = 22 3 28 9 20 1 29 32 21 2 27 10 4 23 30 33 8 19 31 34 15 24 11 26 16 5 36 13 18 7 35 14 17 6 25 12 cnt = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 lastv = 35 cp = 1 1 r = 6 c = 6 cp = 6 1 np = 4 2 cp = 4 2 cv = 2 found = logical 1 np = 2 3 np = 3 4 np = 5 4 np = 6 3 np = 6 1 np = 5 0

Index in position 2 is invalid. Array indices must be positive integers or logical values. Error in knights_tour (line 26) if a(np(1), np(2)) == cv + 1 Error in Test5 (line 3) assert(isequal(knights_tour(a),tf_correct))

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

ic = 23 4 29 3 21 2 30 33 22 10 28 11 5 24 31 34 9 20 32 35 16 25 12 27 17 6 1 14 19 8 36 15 18 7 26 13 cnt = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 lastv = 35 cp = 1 1 r = 6 c = 6 cp = 6 1 np = 4 2 np = 5 3 np = 7 3

Index in position 1 exceeds array bounds (must not exceed 6). Error in knights_tour (line 26) if a(np(1), np(2)) == cv + 1 Error in Test6 (line 3) assert(isequal(knights_tour(a),tf_correct))

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

ic = 2 1 3 1 1 1 1 1 1 cnt = 7 1 1 lastv = 2 cp = 1 1 r = 3 c = 3 cp = 1 1 np = -1 2

Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in knights_tour (line 26) if a(np(1), np(2)) == cv + 1 Error in Test7 (line 3) assert(isequal(knights_tour(a),tf_correct))