Diffing "Tweak" and "7th try!"

Title: Tweak 7th try!
Author: Peter J. Acklam Mohsen Nosratinia
Submitted: 2003-11-06 11:15:41 UTC 2003-11-06 11:53:36 UTC
Status: Passed Passed
Score: 243.0 240.0
Result: pass pass
CPU Time: 29.082 29.032
Code:
n = size(a, 1);
S = {1};
D = Inf*(1:n);
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;
[i,j]=max(D);
[i j]=max(D);
c=P{j};