function s=scoreq(B,n)
% Compute the score for an nxn chessboard, 
% ie: Score is the number of "hits" between queens
s=0; % initial score
% score cols and not rows, because of the way we gen outcomes
a=sum(B,1);
s=s+sum((a(a>1)-1));
% score diagonal hits
a=sum(spdiags(B),1);
s=s+sum((a(a>1)-1));
a=sum(spdiags(B(n:-1:1,:)),1);
s=s+sum((a(a>1)-1));