January 2020
Intermediate to advanced
346 pages
9h 8m
English
When solving the N-Queens problem, we can take advantage of the knowledge that each row will host exactly one queen, and no two queens will share the same column. This means we can represent any candidate solution as an ordered list of integers – or a list of indices, with each index representing the column that one of the queens occupies for the current row.
For example, in a four-queen problem over a 4×4 chessboard, we have the following list of indices:
(3, 2, 0, 1)
This translate to the following positions:
Read now
Unlock full access