python - Algorithm for checking diagonal in N queens algorithm -


i trying implement n- queens problem in python. need small in designing algorithm check if given position of queen check whether other queen on board present on diagonal or not.

i trying design function diagonal_check(board, row, col) board n*n matrix of arrays '1' represents presence of queen , '0' represents absence. pass array , position of queen (row,col) function. function must return false if other queen present on diagonal or else return true.

if me algorithm diagonal_check function. not looking specific language code.

let top left corner (0,0)

the down-right oriented diagonal square (row,col) col-row+7

the up-right oriented diagonal square (row,col) row+col

simply check if 2 queens have same col-row+7 or row+col should tell if 2 queens on same diagonal. if still bit confused, google chessboard image.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -