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

Jean

by Etienne

Status: Passed
Results: 356675 (cyc: 1, node: 817)
CPU Time: 0.148
Score: 356704.0
Submitted at: 2012-10-31 18:30:14 UTC
Scored at: 2012-11-01 15:04:34 UTC

Current Rank: 1760th (Highest: 10th )

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

% Sample solver

% Copyright 2012 The MathWorks, Inc.
xyPoss = circlePoints(xyIn);

% Sort points in order of number of connections
sumConnections=sum(a,2);

[aOrder,xyIndices]=sort(sumConnections,'descend');

xyOut=xyPoss(xyIndices,:);


    function xyPoss = circlePoints(xyIn)
        % Minimize energy by calculating max of points
        [xyMax]=max(abs(xyIn));
        % Generate points in concentric squares
        [m,n]=size(xyIn);
        x=[0 ...
            0 1 1 1 0 -1 -1 -1 ...
            1 2 2 1 -1 -2 -2 -1 ...
            0 1 2 3 3 3 3 3 3 3 2 1 0 -1 -2 -3 -3 -3 -3 -3 -3 -3 -2 -1 ...
            0 1 2 3 repmat(4,1,9) 3 2 1 0 -1 -2 -3 repmat(-4,1,9) -3 -2 -1 ...
            0 1 2 3 4 repmat(5,1,11) 4 3 2 1 0 -1 -2 -3 -4 repmat(-5,1,11) -4 -3 -2 -1 ...
            0 1 2 3 4 5 repmat(6,1,13) 5 4 3 2 1 0 -1 -2 -3 -4 -5 repmat(-6,1,13) -5 -4 -3 -2 -1 ...
            0 1 2 3 4 5 6 repmat(7,1,15) 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 repmat(-7,1,15) -6 -5 -4 -3 -2 -1 ...
            0 1 2 3 4 5 6 7 repmat(8,1,17) 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 repmat(-8,1,17) -7 -6 -5 -4 -3 -2 -1 ...
            0 1 2 3 4 5 6 7 8 repmat(9,1,19) 8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 repmat(-9,1,19) -8 -7 -6 -5 -4 -3 -2 -1]';
        y=[0 ...
            1 1 0 -1 -1 -1 0 1 ...
            2 1 -1 -2 -2 -1 1 2 ...
            3 3 3 3 2 1 0 -1 -2 -3 -3 -3 -3 -3 -3 -3 -2 -1 0 1 2 3 3 3 ...
            repmat(4,1,5) 3 2 1 0 -1 -2 -3 repmat(-4,1,9) -3 -2 -1 0 1 2 3 repmat(4,1,4) ...
            repmat(5,1,6) 4 3 2 1 0 -1 -2 -3 -4 repmat(-5,1,11) -4 -3 -2 -1 0 1 2 3 4 repmat(5,1,5) ...
            repmat(6,1,7) 5 4 3 2 1 0 -1 -2 -3 -4 -5 repmat(-6,1,13) -5 -4 -3 -2 -1 0 1 2 3 4 5 repmat(6,1,6) ...
            repmat(7,1,8) 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 repmat(-7,1,15) -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 repmat(7,1,7) ...
            repmat(8,1,9) 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 repmat(-8,1,17) -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 repmat(8,1,8) ...
            repmat(9,1,10) 8 7 6 5 4 3 2 1 0 -1 -2 -3 -4 -5 -6 -7 -8 repmat(-9,1,19) -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 repmat(9,1,9)]';
        xyPoss=[fix(x(1:m)*(xyMax(1)/max(x(1:m)))) fix(y(1:m)*(xyMax(2)/max(y(1:m))))];
    end

end