N-queens problem: Difference between revisions
m
→Haskell :: In terms of foldr
(SQL PL) |
|||
Line 7,148:
(\x y -> y <> foldr (go x) [] [1 .. nCols])
[]
where
go qs iCol b
Line 7,164:
qs
[0 .. iRow - 1]
--------------------------- TEST -------------------------
Line 7,170 ⟶ 7,169:
showSolutions :: Int -> Int -> [String]
showSolutions nCols nSize =
. transpose
▲ . map (intercalate " ")
. map
<$> chunksOf nCols (queenPuzzle nSize nSize)▼
▲ $ chunksOf nCols (queenPuzzle nSize nSize)
where
go r x
|