Finish 2010-05-05 12:00:00 UTC

next18

by Pushkar

Status: Passed
Results: 373149886 (cyc: 5, node: 234)
CPU Time: 38.995
Score: 746300.0
Submitted at: 2010-04-30 14:00:18 UTC
Scored at: 2010-04-30 14:01:17 UTC

Current Rank: 4224th (Highest: 662nd )

Comments
Alan Chalker
10 May 2010
This entry was submitted during the Twilight phase
Alan Chalker
11 May 2010
This entry gets a result of 597744277 on the test suite (224594391 more than the contest suite). It has a ranking of 4208 compared to all other entries run against the test suite according to the data set provided by Jan Keller.
Please login or create a profile.
Code
function Aest = solver(imageSize, queryLimit)

%Aest = queryImage(logical(ones(imageSize)))*ones(imageSize)/(imageSize*imageSize);
%TotalSum = sum(Aest(:));
%PixelCount = imageSize*imageSize;

Aest = zeros(imageSize);

if(queryLimit > 961) 
    MyqueryLimit = 961;
else
    MyqueryLimit = queryLimit;
end

    number_of_squaresx = fix(sqrt(MyqueryLimit));

    length_of_squares = fix((imageSize/number_of_squaresx));

    summask = length_of_squares*length_of_squares;

%    queryLimit
    for iter=0:number_of_squaresx*number_of_squaresx-1

        mask = randmatrix(iter,MyqueryLimit,imageSize);
        %summask = sum(mask(:));

        current_sum = queryImage(mask)/summask;
        %delta = (TotalSum*summask/PixelCount - current_sum)/2;
        %tempAest = Aest - mask*delta/summask + delta*(ones(imageSize)-mask)/(PixelCount - summask);
        Aest = Aest + mask*current_sum ;

    end
    tAest = Aest;
    for i=2:imageSize-1
        for j=2:imageSize-1
            tAest(i,j) = Aest(i-1,j-1) + Aest(i+1,j+1) +  Aest(i+1,j-1) + Aest(i-1,j+1) ;
        end
    end
    Aest = round(tAest);
end



function randmat = randmatrix(x,queryLimit,imageSize)
%    number_of_squaresx = sqrt(queryLimit);
%    if(number_of_squaresx < round(number_of_squaresx))
%        number_of_squaresx = round(number_of_squaresx) -1 ;
%    else
%        number_of_squaresx = round(number_of_squaresx);
%    end
%
%
%    length_of_squares = (imageSize/number_of_squaresx);
%    if(length_of_squares < round(length_of_squares))
%            length_of_squares = round(length_of_squares) -1;
%    else
%            length_of_squares = round(length_of_squares) ;
%    end

    number_of_squaresx = fix(sqrt(queryLimit));

    length_of_squares = fix((imageSize/number_of_squaresx));

%    length_of_squares
%    number_of_squaresx
    
    randmat = false(imageSize);
    startx = rem(x,number_of_squaresx)*length_of_squares +1;
    starty = (x-rem(x,number_of_squaresx))*length_of_squares/number_of_squaresx +1;
    randmat([startx:startx+length_of_squares-1],[starty:starty+length_of_squares-1]) = true;
%randmatrix(1,10,100)
end