queens n = queens' n nqueens' n 0 = [[]]queens' n k = [x:xs | xs <- queens' n (k - 1), x <- [1..n], isSafeColumn x xs, isSafeDiagonal x xs]isSafeColumn x xs = not $ elem x xsisSafeDiagonal x xs = all (\(a, b) -> abs(x - a) /= b) $ zip xs [1..]showLine n k = replicate (k - 1) '.' ++ "X" ++ replicate (n - k) '.'showSolution s = (mapM_ putStrLn [showLine (length s) k | k <- s]) >> putStrLn ""main = mapM_ showSolution $ queens 4

Recent Public Pastes

Untitled
- *19 hours ago*
Untitled
- *2 days ago*
test
- *3 days ago*
Banktransfer, dumps, warez, fullz,cvv
- *3 days ago*
Banktransfer, dumps, warez, fullz,cvv
- *3 days ago*
Banktransfer, dumps, warez, fullz,cvv
- *3 days ago*
Banktransfer, dumps, warez, fullz,cvv
- *3 days ago*
Banktransfer, dumps, warez, fullz,cvv
- *3 days ago*
Untitled
- *4 days ago*
pippo
- *5 days ago*