Skip to content

Commit dca7e2a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a9eb6de commit dca7e2a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

backtracking/n_queens_math.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181

8282
from typing import List
8383

84+
8485
def depth_first_search(
8586
possible_board: List[int],
8687
diagonal_right_collisions: List[int],
@@ -141,16 +142,21 @@ def depth_first_search(
141142
diagonal_right_collisions.append(row - col)
142143
diagonal_left_collisions.append(row + col)
143144

144-
# Recursive call with updated lists
145-
depth_first_search(possible_board, diagonal_right_collisions, diagonal_left_collisions, boards, n)
145+
# Recursive call with updated lists
146+
depth_first_search(
147+
possible_board,
148+
diagonal_right_collisions,
149+
diagonal_left_collisions,
150+
boards,
151+
n,
152+
)
146153

147-
# Backtrack by removing the last added values after returning from recursion
154+
# Backtrack by removing the last added values after returning from recursion
148155
possible_board.pop()
149156
diagonal_right_collisions.pop()
150157
diagonal_left_collisions.pop()
151158

152159

153-
154160
def n_queens_solution(n: int) -> None:
155161
boards: list[list[str]] = []
156162
depth_first_search([], [], [], boards, n)

0 commit comments

Comments
 (0)