Skip to content

Latest commit

 

History

History
67 lines (33 loc) · 1.18 KB

README_EN.md

File metadata and controls

67 lines (33 loc) · 1.18 KB

中文文档

Description

Write an algorithm to print all ways of arranging n queens on an n x n chess board so that none of them share the same row, column, or diagonal. In this case, "diagonal" means all diagonals, not just the two that bisect the board.

Notes: This problem is a generalization of the original one in the book.

Example:

 Input: 4

 Output: [[".Q..","...Q","Q...","..Q."],["..Q.","Q...","...Q",".Q.."]]

 Explanation: 4 queens has following two solutions

[

 [".Q..",  // solution 1

  "...Q",

  "Q...",

  "..Q."],



 ["..Q.",  // solution 2

  "Q...",

  "...Q",

  ".Q.."]

]

Solutions

Python3

Java

...