Diffing "7th try!" and "Imre 5"

Title: 7th try! Imre 5
Author: Mohsen Nosratinia Imre Polik
Submitted: 2003-11-06 11:53:36 UTC 2003-11-06 11:55:24 UTC
Status: Passed Passed
Score: 240.0 235.0
Result: pass pass
CPU Time: 29.032 36.492
Code:
n = size(a, 1);
S = {1};
D = (1:n)/0;
P = cell(1,n);
while numel(S)
   p = S{end};
   S(end)=[];
   t = a(p(end),:);
   k = setdiff(find(t), p);
   for q = k
      r = [p q];
      S{end+1} = r;
      d = 0;
      for i = 2:numel(r)
         d = d + norm(b(r(i),:) - b(r(i-1),:));
      end
      u=r(end);
      if d < D(u)
         D(u) = d;
         P{u} = r;
      end
   end
end

D(isinf(D))=0;
      for i = 2:nnz(r)

         d = d + norm(b(r(i),:) - b(r(i-1),:));

      end

      u=r(end);

      if d < D(u)

         D(u) = d;

         P{u} = r;

      end

   end

end



D(D>9e9)=0;

[i j]=max(D);
c=P{j};