Finish 1998-12-21 00:00:00 UTC

Entry 02e

by Sohan R. Ranjan

Status: Passed
Results: 1.31% blank
CPU Time: 7.781
Score: 319.816
Submitted at: 1998-12-15 11:08:50 UTC
Scored at: 2000-03-16 16:51:51 UTC

Current Rank: 526th
Based on: entry02 trial=15 (diff)

Comments
Please login or create a profile.
Code
function indexList = binpack(songList, mediaLength)
% Arrange elements of the song list so that total play time
% is as close as possible to the target time.  In general,
% not every song will be used.
% Reduces computation to speed up Entry 02.d a bit.
%Performance would be time-dependent.

total_songs = length(songList);
rand('seed',sum(100*clock));
tmp01 = rand(15,total_songs);
for i=1:15
    [tmp02,order] = sort(tmp01(i,:));
    cums = cumsum(songList(order));
    upto = max(find(cums <= mediaLength));
    total_length = cums(upto);
    tmpList = order(1:upto);
    if ((i==1)|(best_length < total_length)) 
        indexList = tmpList;
        best_length = total_length;
    end;
end;