Algorithm for checking diagonal in N queens algortihm
<p>I am trying to implement N- Queens problem in python. I need a small help in designing the algorithm to check if given a position of Queen check whether any other queen on the board is present on its diagonal or not.</p>

<p>I am trying to design a function diagonal_check(board, row, col) where board is N*N matrix of arrays where '1' represents presence of queen and '0' represents absence.
I will pass array and position of queen (row,col) to the function. My function must return false if any other queen is present on its diagonal or else return true.</p>

<p>If anyone could help me with algorithm for diagonal_check function. Not looking for any specific language code.</p>

<pre><code>boolean diagonalCheck(board, row, col) {

    int tempRow ;
    int tempCol ;

    //algorithm to check left diagonal
    if (row &gt;= col) {
        tempRow = row-col;
        tempCol = 0;
    } else {
         tempRow = 0;
         tempCol = col-row;
    }

    while (tempRow != N-1 &amp;&amp; tempCol != N-1) {
        if (tempRow == row &amp;&amp; tempCol ==col ){
            //no need to check 
        } else if(queen(tempRow,tempCol) == 1 ) {
            return true;
        }
        tempRow++;
        tempCol++;
    }

    //algorithm to check right diagonal
    if (row + col &gt;= N-1) {
        tempCol = N-1;
        tempRow = (row + col) -(N-1)
    } else {
        tempRow = 0;
        tempCol = row + col;
    }


    while (tempRow != N-1 &amp;&amp; tempCol != 0) {
        if (tempRow == row &amp;&amp; tempCol ==col ) {
            //no need to check 
        } else if(queen(tempRow,tempCol) == 1 ) {
          return true;
        }
        tempRow++;
        tempCol--;
    }
    return false;
}
</code></pre>

python algorithm language-agnostic n-queens