...
/Challenge: Place N Queens on an NxN Chessboard
Challenge: Place N Queens on an NxN Chessboard
In this lesson, you will be challenged with a classic recursion problem, placing N queens on an NxN chessboard.
We'll cover the following...
Problem statement
You are given an NxN chessboard, and you are required to place N queens on this chessboard such that no queen is under threat from any other queen.
In chess a queen can move any number of steps horizontally, vertically, or diagonally.
This means that no queen should share a row, column, or diagonal with another queen.
Input
As input, your function will take a number n
, which is the size of the board, and a 2-D list of strings as board
, which is a grid where each row is a list of strings. Each string represents a cell on the board, initially set to ‘-’ to show that the cell is empty.
n = 4
board = [["-", "-", "-", "-"],
...