[Haskell-cafe] 14-queens Problem
ajb at spamcop.net
ajb at spamcop.net
Sun Oct 2 20:29:52 EDT 2005
G'day all.
Quoting Yousry Abdallah <yousry_abdallah at hotmail.com>:
> is it fast to calculate all solutions for the 14-queens problem in 7
> minutes?
No.
% time ./queens 14
365596 solution(s).
real 0m4.045s
user 0m3.928s
sys 0m0.008s
The program is a minimal cover solver written in C++ (about 500 lines,
including the n-queens-specific part) running on a 2GHz Pentium 4.
Having said that, whether or not it's "fast" depends very strongly on
what you're doing with the solutions. In the above program, I'm just
counting them. In Haskell, please be aware that printing a result can
often be MUCH more expensive than computing it.
Cheers,
Andrew Bromage
More information about the Haskell-Cafe
mailing list