function NumberOfAttacks = FindAttacks(A,N) NumberOfAttacks=zeros(1,N); for k=1:N AttacksTemp=0; temp=A(:,:,k); [a b]=find(temp); for i=1:7 p1=a(i); q1=b(i); for j=i+1:8 p2=a(j); q2=b(j); if ((p1==p2) || (q1==q2) || abs(p1-p2)==abs(q1-q2)) AttacksTemp=AttacksTemp+1; end end end NumberOfAttacks(k)=AttacksTemp; end end