Finish 2008-05-07 12:00:00 UTC

White Noise Transfer Function v1

by PWANG

Status: Passed
Results: 390466.00 (cyc: 9, node: 420)
CPU Time: 78.9769
Score: 39434.0
Submitted at: 2008-04-30 14:24:43 UTC
Scored at: 2008-04-30 23:38:42 UTC

Current Rank: 3625th

Comments
PWANG
30 Apr 2008
WTF1
Please login or create a profile.
Code
function W = solver(B)
W = zeros(0,4);
%---------------PFW Apr 30, 2008
pad_occupied=zeros(0,2);
[r,c]=size(B);
pad_exist=(B~=0)
cleanB=pad_exist.*B  % Get a clean board that only has pad numbers
k=0;

for i=1:r
for j=1:c

 tempB=cleanB(i,j)
 if (tempB~=0)
     k=k+1; 
     padtags(k)=tempB   %Padnums accumulate non zero pads tag
     pad_occupied=[pad_occupied;[i ,j]]
 else
     disp('no hit')
 end,
disp('nmber of pads')
k
end,
end,

%Start connectingfist tag
for pid=1:k,   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%BIG K LOOP   
%wire pads
%Move imaginary pad around
%Move east c+
%Move west c-
%Move North r-
%Move south r+

oldi=pad_occupied(pid,1);
oldj=pad_occupied(pid,2);
%If did not hit another pad
%go east
[newi,newj,nogo]=padcinc(oldi,oldj,r,c);
if nogo ~=1
W=[W;[oldi,oldj,newi, newj]]
end,
%Go west
[newi,newj,nogo]=padcdec(oldi,oldj,r,c);
if nogo ~=1
W=[W;[oldi,oldj,newi, newj]]
end,
%Go north
[newi,newj,nogo]=padrdec(oldi,oldj,r,c);
if nogo ~=1
W=[W;[oldi,oldj,newi, newj]]
end,

%Go DOWN
[newi,newj,nogo]=padrinc(oldi,oldj,r,c);
if nogo ~=1
W=[W;[oldi,oldj,newi, newj]]
end,

end,    %%%%%%%%%%%%%%%%%%%%%For Pad=1:K BIG LOOP


function [newi, newj,nogo]=padcinc(oldi,oldj,r,c)

% No change in i
newi=oldi;

    tempj=oldj+1;
    if (tempj>=1) &(tempj<=c) 
    newj=tempj;
    nogo=0;
    else
        newj=oldj
     nogo=1;   
    end,
    
 function [newi, newj,nogo]=padcdec(oldi,oldj,r,c)

% No change in i
newi=oldi;

    tempj=oldj-1;
    if (tempj>=1) &(tempj<=c) 
    newj=tempj;
    nogo=0;
    else
        newj=oldj;
     nogo=1;   
    end,   
    
function [newi, newj,nogo]=padrinc(oldi,oldj,r,c)

% No change in i
newj=oldj;


    tempi=oldi+1;
    if (tempi>=1) &(tempi<=r) 
    newi=tempi;
    nogo=0;
    
    else
        newi=oldi;
     nogo=1;   
    end,
    
function [newi, newj,nogo]=padrdec(oldi,oldj,r,c)

% No change in i
newj=oldj;


    tempi=oldi-1;
    if (tempi>=1) &(tempi<=r) 
    newi=tempi;
    nogo=0;
    else
       newi=oldi;
     nogo=1;   
    end,