Module

Data.NQueens

Package
purescript-nqueens
Repository
jrrom/purescript-nqueens

#boardSize Source

boardSize :: Board -> Int

Returns the size n :: Int of a Board.

Board { size: n, queens: _ }

#boardQueens Source

boardQueens :: Board -> List Position

Returns the qs :: List Position of queens in a Board.

Position :: { col :: Int, row :: Int }

Board { size: _, queens : qs }

The queens are in descending row order from n - 1 to 0.

#nQueensNaive Source

nQueensNaive :: Int -> List Board

To solve N-Queens using a naive backtracking approach.

Given a board size n, this function returns all valid solutions as a List Board value.

Board { size: n, queens: qs }

Use boardSize and boardQueens to get the respective values.

Re-exports from Data.NQueens.Internal

#Board Source

newtype Board

newtype Board { size :: Int, queens :: List Position }

Instances

  • Show Board

    Will display with leading and ending newline in the form below:

    _ Q _ _ _ _ _ Q Q _ _ _ _ _ Q _