Finish 2011-04-20 12:00:00 UTC

baseline

by Guang

Status: Passed
Results: 7665625 (cyc: 7, node: 188)
CPU Time: 4.543
Score: 19164.2
Submitted at: 2011-04-15 02:41:30 UTC
Scored at: 2011-04-15 02:43:33 UTC

Current Rank: 1326th (Highest: 51st )

Comments
Please login or create a profile.
Code
function board = solver(words, weights, n, penalty)

board = zeros(n,n);
i=1;
while i < length(weights)+1;
    lw(i) = length(words{i});
    worth(i)=weights(i)/lw(i);
    i=i+1;
end
[wsort ind]=sort(worth,'descend');
lw=lw(ind);
words=words(ind);

rr=1;

while rr < n+1
    ss=1;
    tt=1;
while ss < n+1 && tt < length(lw)+1;
    if ss+lw(tt)-2 < n && lw(tt)~=0; 
    board(rr,ss:ss+lw(tt)-1)=words{tt};
    ss=ss+lw(tt)+1;
    lw(tt)=[0];
    words{tt}=[0];
    tt=tt+1;
    else tt=tt+1;
    end
end
rr=rr+1;
end