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

yogatest03

by yoga hariman

Status: Passed
Results: 7684388 (cyc: 4, node: 181)
CPU Time: 13.708
Score: 19211.1
Submitted at: 2011-04-15 03:18:10 UTC
Scored at: 2011-04-15 03:19:48 UTC

Current Rank: 1340th (Highest: 57th )

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

% Sample solver

% Copyright 2011 The MathWorks, Inc.

board = zeros(boardSize);

rw=cell2mat(cellfun(@length, words, 'UniformOutput', false));
cw=length(rw);
select=zeros(1,cw);

temp=zeros(max(rw),cw);
for ii=1:cw
    temp(1:rw(ii),ii)=words{ii}';
end
words=temp;

weights=weights./rw;
[weights,temp]=sort(weights,'descend');
words=words(:,temp);
rw=rw(:,temp);

% %row 1.val 2.freq 3.sum(weights)
% uniqVal=unique(words);
% uniqVal=uniqVal(2:end)';
% for ii=1:size(uniqVal,2)
%     [~,idx]=find(words==uniqVal(1,ii));
%     uniqVal(2,ii)=sum(weights(idx))/length(idx);
% end

% % model Kubus
% urw=unique(rw);
% for ii=1:length(urw)
%     ind=find(rw==urw(ii)&select==0);
%     nInd=length(ind);
%     if urw(ii)>nInd,continue;end
%     res=zeros(urw(ii),urw(ii));
%     for iii=1:nInd-urw(ii)+1
%         for iv=iii+1:nInd
%             res(:)=
%         end
%     end
% end

% % model kotak
% urw=unique(rw);
% urwn=length(urw);
% for ii=1:urwn
%     for iii=ii+1:urwn
%         %disp([num2str(urw(ii)) '-' num2str(urw(iii))]);
%         lb=urw(ii);
%         pj=urw(iii);
%         
%         indLb=find(rw==lb);
%         indPj=find(rw==pj);
%         
%         % if any(rw==2)&&any(rw==3)
%     end
% end
% 
% board(1,1:rw(1))=words(1:rw(1),1)';

idw=1;
for ii=1:boardSize
    topboard=1;botboard=topboard+rw(idw)-1;
    while botboard<=boardSize
        disp([num2str(topboard) '-' num2str(botboard)]);
        board(topboard:botboard,ii)=words(1:rw(idw),idw);
        idw=idw+1;
        topboard=botboard+2;
        botboard=topboard+rw(idw)-1;
    end
end