Eight Queens Count
Eight Queens Count
Write n_queens_count(n: int) -> int that returns how many ways n queens can be placed on an n by n board so that no two share a row, column or diagonal, by backtracking. Keep the board as a list queens where queens[r] is the column of the queen in row r. Write is_safe(queens, row, col) that checks the new square against every earlier row (same column, or the row distance equal to the column distance in either direction), and a recursive place_queens(queens, row, n) that returns 1 when row equals n (a full board) and otherwise tries every col in range(n): when it is safe, append() the column, add the count from the next row, then pop() it to undo the move. The known answers are 2 for 4 queens, 10 for 5, 4 for 6 and 92 for 8. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one integer n; the tests print the count your function returns.
Expected Output:
2= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...