Diffing "TweakStream V" and "no_name"

Title: TweakStream V no_name
Author: Peter Acklam Sharath Manjunath
Submitted: 1998-12-17 11:40:17 UTC 1998-12-17 14:02:43 UTC
Status: Passed Passed
Score: 83.0244 83.2999
Result: 0.39% blank 0.39% blank
CPU Time: 9.453 9.433
Code:
function indexList = binpack(songList,mediaLength)
[s,t] = sort(songList);
a = size(s,2);
b = min(a,round(4*a*mediaLength/sum(s)));
c = max(round(5.7*a^0.6875),10);
[d,e] = sort(rand(b,c));
q = 0.25*(a-b);
if q > 1
   r = floor(q*rand(1,c));
   e = e+r(ones(1,b),:);
else
   r = rand(1,c);
end
f = cumsum(s(e));
g = sum(f<=mediaLength);
[d,h] = max(f(g+(0:b:b*c-b)));
indexList = t(e(1:g(h),h));
leftOff = t(e(g(h)+1:end,h));
remTime = mediaLength-d;
onez1 = ones(1,g(h));
onez2 = ones(b-g(h),1);
newFree = remTime + songList(onez2,indexList) - songList(onez1,leftOff)';
x = songList(onez2,indexList);
y = songList(onez1,leftOff)';
newFree = remTime + x - y;
newFree(newFree<0) = 9e9;
[m,i] = min(newFree);
[m,j] = min(m);
if m<remTime
   better = 1;
   while better
      aux = indexList(j);
      indexList(j) = leftOff(i(j));
      leftOff(i(j)) = aux;
      x(:,j)=songList(indexList(j));
      y(i(j),:)=songList(aux);
      remTime = m;
      newFree = remTime + songList(onez2,indexList) - songList(onez1,leftOff)';
      newFree = remTime + x - y;
      newFree(newFree<0) = 9e9;
      [m,i] = min(newFree);
      [m,j] = min(m);
      better = (m<remTime);
   end
end