mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2026-03-13 08:51:02 +08:00
Upgrade packages.
This commit is contained in:
@@ -16,16 +16,16 @@ function isSafe(queensPositions, rowIndex, columnIndex) {
|
||||
|
||||
if (
|
||||
// Check if queen has been already placed.
|
||||
currentQueenPosition &&
|
||||
(
|
||||
currentQueenPosition
|
||||
&& (
|
||||
// Check if there are any queen on the same column.
|
||||
newQueenPosition.columnIndex === currentQueenPosition.columnIndex ||
|
||||
newQueenPosition.columnIndex === currentQueenPosition.columnIndex
|
||||
// Check if there are any queen on the same row.
|
||||
newQueenPosition.rowIndex === currentQueenPosition.rowIndex ||
|
||||
|| newQueenPosition.rowIndex === currentQueenPosition.rowIndex
|
||||
// Check if there are any queen on the same left diagonal.
|
||||
newQueenPosition.leftDiagonal === currentQueenPosition.leftDiagonal ||
|
||||
|| newQueenPosition.leftDiagonal === currentQueenPosition.leftDiagonal
|
||||
// Check if there are any queen on the same right diagonal.
|
||||
newQueenPosition.rightDiagonal === currentQueenPosition.rightDiagonal
|
||||
|| newQueenPosition.rightDiagonal === currentQueenPosition.rightDiagonal
|
||||
)
|
||||
) {
|
||||
// Can't place queen into current position since there are other queens that
|
||||
|
||||
Reference in New Issue
Block a user