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

Navicular

by Pavan

Status: Passed
Results: 12242 (cyc: 2, node: 183)
CPU Time: 38.935
Score: 12248.8
Submitted at: 2012-10-31 18:21:12 UTC
Scored at: 2012-11-01 14:59:26 UTC

Current Rank: 1597th (Highest: 1st )
Based on: Talus (diff)

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

s = 100;
zmax = 50;
tweakdir = [1 0 ; 0 -1];

xyIn = round((xyIn - ones(length(xyIn), 1)*mean(xyIn)).*s + ones(length(xyIn), 1)*mean(xyIn));
for z = 1:zmax
   xyIn = round(cell2mat(cellfun(@(a_row) mean(xyIn(a_row==1, :), 1), num2cell(a, 1), 'uni', false)'));
   tweak_overlap
end

xyOut = xyIn;

    function tweak_overlap
        [u I J] = unique(xyIn, 'rows');
        n = size(xyIn, 1) - size(u, 1);
        while(n>0)
            xyIn(setdiff(1:length(xyIn), I), :) = xyIn(setdiff(1:length(xyIn), I), :) + ones(n, 2) * tweakdir;
            [u I J] = unique(xyIn, 'rows');
            n = size(xyIn, 1) - size(u, 1);
        end
    end

end