Place n queens on an n × n board so that no two attack each other (same row, column or diagonal). This is the classic backtracking problem.
Implement:
solve_n_queens(n): all solutions, each a list of column indices by row ([1, 3, 0, 2] means row 0 has its queen in column 1, and so on), in lexicographic order.count_n_queens(n): just the number of solutions, computed without building every board. Use sets (or bitmasks) for the occupied columns and diagonals.render(solution): a list of strings like ".Q..".