Skip to content

Instantly share code, notes, and snippets.

@qzchenwl
Created August 6, 2011 05:58
Show Gist options
  • Save qzchenwl/1129057 to your computer and use it in GitHub Desktop.
Save qzchenwl/1129057 to your computer and use it in GitHub Desktop.
eight queens in haskell
import Data.List
isUnique :: (Ord a) => [a] -> Bool
isUnique = all (null . drop 1) . group . sort
cols = [0..7]
solutions = [vec | vec <- permutations cols
, isUnique [vec!!i + i | i <- cols]
, isUnique [vec!!i - i | i <- cols]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment