Winner Nicke (Revolution IV)

Finish 2003-11-13 15:00:00 UTC

Revolution I

by Nicke

Status: Failed
Results: []

Comments
Please login or create a profile.
Code
[m n]=size(a);
y=m*n;
P(y,y)=0;
for i=1:y
 [v w]=ind2sub(m,i);
 t=i+[v<m -(v>1) m*[w<n -(w>1)]];
 P(i,t(a(t)==a(i)+1))=1;
end
g=-1;
while any(t(:)),
 g=g+1;
 [b r]=find(t);
 t=P^g;
end
for m=g:-1:0
 w=P^m;
 t=find(P(b(end),:).*w(:,r)');
 b=[b; t(1)];
end