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

Miser Willy

by Nicholas Howe

Status: Passed
Results: 7691879 (cyc: 3, node: 152)
CPU Time: 2.82
Score: 19229.8
Submitted at: 2011-04-13 19:03:28 UTC
Scored at: 2011-04-13 19:06:37 UTC

Current Rank: 1342nd (Highest: 1st )

Comments
Nicholas Howe
13 Apr 2011
Name from WillyNilly, which I never submitted.
Please login or create a profile.
Code
function board = miserwilly(words, weights, n, penalty)

board = zeros(n);

wlen = cellfun(@numel,words);
wcost = weights./(wlen+1);
[~,r] = sort(-wcost);
wlen = wlen(r);
words = words(r);
open = true(1,numel(words));
for i = [1:2:n,2:2:n]
    j = 1;
    k = find(open&(wlen<n-j),1);
    while ~isempty(k)
        open(k) = false;
        word = words{k};
        board(i,j:j+numel(word)-1) = word;
        j = j+numel(word)+1;
        k = find(open&(wlen<n-j),1);
    end;
end;

end