cody challenge Problem 96. Knight's Tour Checker 把L型走步规划转换为矩阵元素下角标的问题
cody challenge Problem 96. Knight's Tour Checker 代码分享
function tf = knights_tour(a) m=length(a(:,1)); n=length(a(1,:)); c=max(max(a)); tf=true; for b=1:c for i=1:n for j=1:m if b==a(j,i) z1(b)=j; z2(b)=i; break; end end end end for y=1:c-1 z11(y)=abs(z1(y)-z1(y+1)); z12(y)=abs(z2(y)-z2(y+1)); if z11(y)+z12(y)~=3 tf=false; end end end
题目