Copyright | Copyright (C) 2021 Yoo Chung |
---|---|

License | GPL-3.0-or-later |

Maintainer | dev@chungyc.org |

Safe Haskell | Safe-Inferred |

Language | GHC2021 |

Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P90.

# Documentation

queens :: Int -> [[Int]] Source #

The eight queens problem is a classical problem in computer science. The objective is to place eight queens on a chessboard so that no two queens are attacking each other. I.e., no two queens are in the same row, the same column, or on the same diagonal. Solve the extended problem for arbitrary \(n\).

Represent the positions of the queens as a list of numbers from 1 to \(n\).
For example, `[4,2,7,3,6,8,5,1]`

means that the queen in the first column is in row 4,
the queen in the second column is in row 2, etc.

### Examples

`>>>`

92`length $ queens 8`

`>>>`

[1,5,8,6,3,7,2,4]`minimum $ queens 8`