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

VL_1

by Venu Lolla

Status: Passed
Results: 151464 (cyc: 6, node: 219)
CPU Time: 18.305
Score: 151468.0
Submitted at: 2012-11-01 03:23:16 UTC
Scored at: 2012-11-01 17:00:52 UTC

Current Rank: 1700th (Highest: 23rd )

Comments
Venu Lolla
01 Nov 2012
From Nothing to One Thing ...
Please login or create a profile.
Code
function xyOut = solver_1(a, xyIn, wts)

n = size(xyIn,1);
[sw, swi] = sort(wts);
xL = [min(xyIn(:,1)) max(xyIn(:,1))];
yL = [min(xyIn(:,2)) max(xyIn(:,2))];

mW = sw(end);

for j = 1:10,
    
    
    used_Z = [];
    xyOut = xyIn;
    
    for i=1:n,
        
        ti = swi(i);
        ci = logical(a(ti,:));
        
        % move points ....
        fW = sw(i) / mW;
        nZ = round(fW * xyOut(ti,:) + (1 - fW) * mean(xyOut(ci,:)));
        if (i>1)
            done = false;
            while(done == false)
                mD = sum(bsxfun(@minus,used_Z,nZ).^2,2);
                if any(mD==0)
                    dX = randi(3) - 2;
                    dY = randi(3) - 2;
                    nZ = nZ + [dX dY];
                else
                    done = true;
                end
            end
        end
        used_Z = cat(1,used_Z,nZ);
        xyIn(ti,:) = nZ;
        
    end
    
    
end

xyOut = xyIn;

end