function n = bestNeighbour(x)

%% return a vector n that represent the next best move given the initial
%% configuration x for an n-queen problem; if x is a matrix  
%% computes a best neighbor state for each row separately and combines them
%% in n

M = generateConflMatrix(x)
n = x;
k=size(x,1);
if (k==1)
    [i,j] = find(M==min(M(:)))
    n(j(1)) = i(1);
else 
    for r=1:k
        M = generateConflMatrix(x(r,:))
        [i,j] = find(M==min(M(:)))
        n(r,j(1)) = i(1);
    end
end



