N queens problem
Jonata Goulart
jonatahh@hotmail.com
Mon, 26 Aug 2002 00:41:24 +0000
This is the problem to figure out the n queens problem but I didn't
understand it very well.
Somebody can help me ?
how legal and queens functions work?
attack (l,c) (ll,cc) = l ==ll || (l+c==ll+cc) || (l-c==ll-cc)
legal p m = and [not (attack (l,c) (m, length p +1)) | (l,c) <- zip p [1..]]
queens n = r n n
where r 0 n = [[]]
r m n = [p ++ [m] | p <- r (m-1) n, m <-[1..n], legal
p m]
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com