We extract a bit mask ( safe ) by rowmask , ldmask and rdmask . all set bits of ' safe ' indicates the safe column index for queen placement of this iteration for row index ( row ) .
safe = all_rows_filled & ( ~ ( rowmask ldmask rdmask ) ) NEW_LINE while ( safe > 0 ) : NEW_LINE