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

Fast & Cheap

by Michael Knauff

Status: Passed
Results: 10129219 (cyc: 5, node: 104)
CPU Time: 0.116
Score: 25323.1
Submitted at: 2011-04-16 02:42:09 UTC
Scored at: 2011-04-16 02:45:03 UTC

Current Rank: 1671st (Highest: 426th )

Comments
Michael Knauff
16 Apr 2011
Fill in rows
Please login or create a profile.
Code
function board = solver(words, weights, n, penalty)

board = zeros(n);

k = 1; % word counter
for i = 1:floor(n/2)
    flag = 0;
    wrdstart = 1;
    while flag == 0 && k <= length(words)
        word = words{k};
        wlen = length(word);
        if wlen + wrdstart <= n + 1
            board(2*i,wrdstart:wrdstart-1+length(word)) = word;
            k = k + 1;
            wrdstart = wrdstart + wlen + 1;
        else
            flag = 1;
        end
    end
end