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

Tarsal

by Pavan

Status: Passed
Results: 11351 (cyc: 2, node: 218)
CPU Time: 38.566
Score: 11359.1
Submitted at: 2012-10-31 22:10:12 UTC
Scored at: 2012-11-01 16:07:08 UTC

Current Rank: 1595th (Highest: 2nd )
Based on: Pelvis (diff)
Basis for: Metatarsal (diff)

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

s = 100;
zmax = 50;
orig_mean = mean(xyIn, 1);
len = length(xyIn);

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

xyOut = xyIn;
%shift mean back
xyOut = round(xyOut + repmat(orig_mean - mean(xyOut, 1), length(xyIn), 1));
tweak_overlap;

    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), :) + (randi(2, n, 2)- 1.5)*2;
            [u I J] = unique(xyIn, 'rows');
            n = size(xyIn, 1) - size(u, 1);
        end
    end

end