Cody

Solution 2637244

Submitted on 1 Jul 2020 by 春樹 内糸
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))

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 np = 0 4 np = 2 4 np = 3 3 cp = 3 3 cv = 3 found = logical 1 np = 1 4 np = 2 5 np = 4 5 np = 5 4 np = 5 2 np = 4 1 np = 2 1 cp = 2 1 cv = 4 found = logical 1 np = 0 2 np = 1 3 cp = 1 3 cv = 5 found = logical 1 np = -1 4 np = 0 5 np = 2 5 np = 3 4 np = 3 2 cp = 3 2 cv = 6 found = logical 1 np = 1 3 np = 2 4 np = 4 4 np = 5 3 np = 5 1 np = 4 0 np = 2 0 np = 1 1 cp = 1 1 cv = 7 found = logical 1 np = -1 2 np = 0 3 np = 2 3 cp = 2 3 cv = 8 found = logical 1 tf = logical 1

2   Pass
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 np = 0 3 np = 2 3 cp = 2 3 cv = 2 found = logical 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))

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 np = 1 4 cp = 1 4 cv = 3 found = logical 1 np = -1 5 np = 0 6 np = 2 6 np = 3 5 np = 3 3 cp = 3 3 cv = 4 found = logical 1 np = 1 4 np = 2 5 np = 4 5 np = 5 4 np = 5 2 np = 4 1 np = 2 1 np = 1 2 cp = 1 2 cv = 5 found = logical 1 np = -1 3 np = 0 4 np = 2 4 cp = 2 4 cv = 6 found = logical 1 np = 0 5 np = 1 6 np = 3 6 np = 4 5 np = 4 3 cp = 4 3 cv = 7 found = logical 1 np = 2 4 np = 3 5 np = 5 5 np = 6 4 np = 6 2 np = 5 1 np = 3 1 cp = 3 1 cv = 8 found = logical 1 np = 1 2 np = 2 3 cp = 2 3 cv = 9 found = logical 1 np = 0 4 np = 1 5 np = 3 5 np = 4 4 cp = 4 4 cv = 10 found = logical 1 np = 2 5 np = 3 6 np = 5 6 np = 6 5 np = 6 3 np = 5 2 np = 3 2 cp = 3 2 cv = 11 found = logical 1 np = 1 3 cp = 1 3 cv = 12 found = logical 1 np = -1 4 np = 0 5 np = 2 5 np = 3 4 cp = 3 4 cv = 13 found = logical 1 np = 1 5 np = 2 6 np = 4 6 np = 5 5 np = 5 3 np = 4 2 cp = 4 2 cv = 14 found = logical 1 np = 2 3 np = 3 4 np = 5 4 np = 6 3 np = 6 1 np = 5 0 np = 3 0 np = 2 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))

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 np = 1 4 cp = 1 4 cv = 3 found = logical 1 np = -1 5 np = 0 6 np = 2 6 np = 3 5 np = 3 3 cp = 3 3 cv = 4 found = logical 1 np = 1 4 np = 2 5 np = 4 5 np = 5 4 np = 5 2 np = 4 1 np = 2 1 np = 1 2 cp = 1 2 cv = 5 found = logical 1 np = -1 3 np = 0 4 np = 2 4 cp = 2 4 cv = 6 found = logical 1 np = 0 5 np = 1 6 np = 3 6 np = 4 5 np = 4 3 cp = 4 3 cv = 7 found = logical 1 np = 2 4 np = 3 5 np = 5 5 np = 6 4 np = 6 2 np = 5 1 np = 3 1 cp = 3 1 cv = 8 found = logical 1 np = 1 2 np = 2 3 cp = 2 3 cv = 9 found = logical 1 np = 0 4 np = 1 5 np = 3 5 np = 4 4 cp = 4 4 cv = 10 found = logical 1 np = 2 5 np = 3 6 np = 5 6 np = 6 5 np = 6 3 np = 5 2 np = 3 2 cp = 3 2 cv = 11 found = logical 1 np = 1 3 cp = 1 3 cv = 12 found = logical 1 np = -1 4 np = 0 5 np = 2 5 np = 3 4 cp = 3 4 cv = 13 found = logical 1 np = 1 5 np = 2 6 np = 4 6 np = 5 5 np = 5 3 np = 4 2 cp = 4 2 cv = 14 found = logical 1 np = 2 3 np = 3 4 np = 5 4 np = 6 3 np = 6 1 np = 5 0 np = 3 0 np = 2 1 cp = 2 1 cv = 15 found = logical 1 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))

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

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 np = 8 2 np = 8 0 np = 7 -1 np = 5 -1 np = 4 0

7   Pass
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 np = 0 3 np = 2 3 np = 3 2 np = 3 0 np = 2 -1 np = 0 -1 np = -1 0

Suggested Problems

More from this Author95