
The N-Queens completion problem is NP-hard - t23
http://www.atlasobscura.com/articles/queens-puzzle-chess-problem-solution-software
======
umanwizard
The article completely misinterprets the press release[1].

The University of St Andrews isn't offering a prize; they've just shown that
the Queens puzzle on an n-by-n board (EDIT: actually, the n Queens completion
puzzle) is NP-hard.

(By the way, even the press release, though less wrong than the article, is
still pretty bad: apparently NP-complete problems are hard because they use
"backtracking". Also it seems to suggest that this is something computer
programmers would solve, rather than mathematicians...)

[1]: [https://phys.org/news/2017-09-simple-chess-puzzle-
key-1m.htm...](https://phys.org/news/2017-09-simple-chess-puzzle-
key-1m.html#jCp)

~~~
cperciva
If I'm reading it right, they haven't shown that the N Queens problem is NP-
hard, but rather that the N Queens _completion_ problem is NP-hard.

~~~
CJefferson
Yes (one of the authors here), the press release came out very badly.

The reference to the Clay prize was to try to demonstrate that lots of people
care about solving NP-complete problems in general...

N-Queens has long been known to polynomial time (although there is no known
efficient way of counting the total number of solutions).

We showed N-Queens completion is NP-hard. This is (in my opinion) interesting
to people who care about such things, because it's a long standing problem and
has the advantage of being easy to explain. However, it is mainly just a
curiosity, and provides a new easy way of demonstrating NP-completeness.

------
rdiddly
Completely off-topic: As a one-time civil engineer, mathematical dullard, and
frequent New York visitor, who is losing his mind, I thought this was about
completing a subway line. In my defense, the N train does go to Queens (though
it's not called the N-Queens), and everybody knows completing a subway line is
a really hard problem, especially if you're following the story of the new 2nd
Ave line.

------
anonetal
The million-dollar prize just appears to be the Clay Institute's prize for
solving P vs NP. I am guessing that the queens problem (a special case of
maximum independent set in a graph) is NP-Hard.

~~~
cropsieboss
Damn it. I didn't know it's NP hard. I thought I would discover the generating
function for the number of possible solutions for board sized N.

~~~
anonetal
Actually the queens problem starting with an empty board is not NP-Hard. See:
[https://cstheory.stackexchange.com/questions/12682/is-
the-n-...](https://cstheory.stackexchange.com/questions/12682/is-the-n-queens-
problem-np-hard)

The "completion" problem is the NP-Hard one. As one of the other comments
noted, the paper behind this press release is about the completion problem.

~~~
mmarx
That's just a good heuristic, though, it does not guarantee finding a
solution. Also note that NP is a class of decision problems, and finding a
solution for the n-Queens problem is not.

None of the two decision problems that arise naturally from n-queens, deciding
whether there exists solutions for a given board size, and verifying whether a
candidate is indeed a solution, are NP-hard (solutions exist for n \not\in {2,
3}; verification can clearly be done in time quadratic in n). Counting
solutions is #P-complete, though.

~~~
thomasahle
> Counting solutions is #P-complete, though.

Are you sure? Where was this proven? It could easily be that
[http://oeis.org/A000170](http://oeis.org/A000170) had a polynomial time
combinatorial formula.

Maybe some completion-counting problem could be shown to be #P-complete
though.

~~~
taeric
If you read the cites on that link, you'll see that the value for 26 was only
added in 2016. They do not have a closed form formula, or they would have
shown it.

I mean, they could just be slow revealing. I doubt it, though.

~~~
thomasahle
Computational hardness doesn't depend on whether anybody knows an efficient
algorithm. Just whether one exists.

~~~
taeric
Fair enough. I was obviously reading the above as having a polynomial time as
having an efficient time one. Where efficient was shorthand for "quick." Both
leaps, I concede were misguided.

------
imaginenore
It's currently solved for up to N=27

Both 26 and 27 solutions came from supercomputers/FPGAs and took months of
compute time.

[http://www.nqueens.de/sub/WorldRecord.en.html](http://www.nqueens.de/sub/WorldRecord.en.html)

~~~
chengsun
No, you're talking about a different problem: that of counting the total
number of n-queens solutions. The original article is talking about the
problem of deciding, given a partial placement of queens, whether it can be
completed by adding further queens to form an n-queen solution.

------
Retric
What you is fast in this case? If you can solve 1,000 x 1,000 in say 1 minute
is that fast? Or do you need to solve 1,000,000 x 1,000,000 in a second?

~~~
imaginenore
If you can solve it at all for even 50x50 would mean a revolution in certain
algorithmic fields.

~~~
fooker
That is surprising.

Can you point me to a concrete reference about the 50x50 number?

Modern SAT solvers should be able to handle that, maybe with a few problem
specific tweaks.

------
MichaelBurge
You can also claim the $1 million by being good at Mario and explaining your
techniques:

[https://arxiv.org/abs/1203.1895](https://arxiv.org/abs/1203.1895)

~~~
avaer
Only if you are provably, mathematically good at Mario. Not just you seem to
do well over the course of a measly billion games of.

------
Zarathust
Is there a proof somewhere which states that all NP hard problem can have a
similar / generic solution?

I find it more likely that the N-Queens problem will have a very specific
solution

~~~
pdpi
Problems in NP hard that are also in NP are known as NP-complete. NP complete
problems share the characteristic that all problems in P can be reduced to any
NP problem in polynomial time (which is to say: you can encode P problems as
particular instances of NP problems). Therefore, if P = NP, all problems in NP
are reducible to one another.

------
andy_ppp
Can you find an algorithm to a problem that many believe would show that P ==
NP? Probably not.

~~~
umanwizard
It's not just "believed" that showing a polynomial-time algorithm for an NP-
complete problem shows that P=NP; it's proven (in fact, this is part of the
definition of NP-complete...)

------
master_yoda_1
Thanks for telling me that :)

------
sabujp
ahh nqueens, this was my first real parallel program that I did using mpi

------
mathieubordere
I don't get why this article is getting attention here.

