Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -7,5 +7,5 @@ main = mapM_ print $ queens 8
|
|||
queens :: Int -> [[Int]]
|
||||
queens n = foldM f [] [1..n]
|
||||
where
|
||||
f qs k = [q:qs | q <- [1..n] \\ qs, q `notDiag` qs]
|
||||
f qs _ = [q:qs | q <- [1..n] \\ qs, q `notDiag` qs]
|
||||
q `notDiag` qs = and [abs (q - qi) /= i | (qi,i) <- qs `zip` [1..]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue