Finish 2012-11-07 16:00:00 UTC

m006

by Peter Gal-Benedek

Status: Passed
Results: 52161 (cyc: 5, node: 152)
CPU Time: 35.37
Score: 52165.5
Submitted at: 2012-11-01 23:57:12 UTC
Scored at: 2012-11-02 00:00:24 UTC

Current Rank: 1663rd (Highest: 47th )
Based on: m005 (diff)

Comments
Please login or create a profile.
Code
function xyOut = solver(a, xyIn, wts)

% Sample solver

% Copyright 2012 The MathWorks, Inc.

xyOut=xyIn;
midxy=ceil(max(xyIn)/5);


for step=1:10
    for k=1:size(xyIn,1),
            baserow=k;
            basepoint=xyOut(baserow,:);
            nearpoints=xyOut(find(a(baserow,:)),:);
            
            point(1)=round(mean(nearpoints(:,1)));
            point(2)=round(mean(nearpoints(:,2)));
           if mod(step,4)==1,
               point(1)=point(1)*2-midxy(1);
               point(2)=point(2)*2-midxy(2);
           end;
            xyOut(baserow,:)=point;
            
            if ~isequal(size(xyIn,1),size(unique(xyOut,'rows'),1))
                xyOut(baserow,:)=basepoint;
            end
    end
end
end