Solve a 'Simple' Chess Puzzle, Win $1 Million (st-andrews.ac.uk) 125
An anonymous reader brings an important announcement:
Researchers at the University of St Andrews have thrown down the gauntlet to computer programmers to find a solution to a "simple" chess puzzle which could, in fact, take thousands of years to solve, and net a $1 million prize. Computer Scientist Professor Ian Gent and his colleagues, at the University of St Andrews, believe any program capable of solving the famous "Queens Puzzle" efficiently would be so powerful, it would be capable of solving tasks currently considered impossible, such as decrypting the toughest security on the internet. In a paper [PDF] published in the Journal of Artificial Intelligence Research today, the team conclude the rewards to be reaped by such a program would be immense, not least in financial terms with firms rushing to use it to offer technological solutions, and also a $1 million prize offered by the Clay Mathematics Institute in America.
Devised in 1850, the Queens Puzzle originally challenged a player to place eight queens on a standard chessboard so that no two queens could attack each other. This means putting one queen in each row, so that no two queens are in the same column, and no two queens in the same diagonal. Although the problem has been solved by human beings, once the chess board increases to a large size no computer program can solve it.
Devised in 1850, the Queens Puzzle originally challenged a player to place eight queens on a standard chessboard so that no two queens could attack each other. This means putting one queen in each row, so that no two queens are in the same column, and no two queens in the same diagonal. Although the problem has been solved by human beings, once the chess board increases to a large size no computer program can solve it.
Large size? (Score:3)
How large is that? Many algorithms for simpler problems would fail if the size is multiplied by a big number.
Re: (Score:3)
"once the chess board increases to a large size no computer program can solve it"
How large is that? Many algorithms for simpler problems would fail if the size is multiplied by a big number.
More to the point, anything larger that 8x8 isn't a chess board - problem solved, where's my money?
8 queens? (Score:3)
Not only that, but if an 8-queen solution works on an 8x8 board, it'll work just as well on a 1000x1000 or a 10k x 10k board, etc. board. Move it over, put it in the same relative location in the 8x8 group at the corner of the larger board, done. So solve for 8x8 and move.
So you'll need to split that money with me, pal. :)
Of course, it's just slightly possible that TFS is not an accurate summary of the actual article / problem,
Re: (Score:3)
Re: (Score:2)
Since this is all really backed by the discussion about NP != P, what you need to do is create a polynomial time solution for it and then that will be "fast enough". If your algorithm executes in exponential time it won't be fast enough.
If you don't understand what I just said, welcome to Slashdot, we (used to) talk tech stuff here. Read this: en.wikipedia.org/wiki/Time_complexity [wikipedia.org].
Re: (Score:3)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
"I honestly don't know what is the matter with some people online, labelling themselves as software developers but being scared of code! Not even understanding a simple algorithm! And reacting aggressively with anyone on account of their own lacks! Constantly lying and thinking that everyone lies to them?!"
methinks he doth protest too much.
seriously, you're out of your fucking league on this one and really don't know what you're talking about. fwiw, it's out of my league too, but i'm at least smart and educ
Re: (Score:2)
Re: (Score:2)
holy shit dude you are fucked up.
i was just kidding before. your solution in PHP is genius & you're one of the few on the right track.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
But when I am asked about "why did you choose a regex here instead of simply comparing strings" and I explain algorithmic complexity of compilation of a refer into either a DFA or NFA as well the computational complexity of the execution of the compiler result vs the computational complexity of searching string, they look at me like "I thought I was getting good at programming but if you're what a real programmer is, I have a really long way to go."
The reason for choosing to use a regex over
Re: (Score:2)
You can try a recursive solution. For each queen, place that queen somewhere on the board, mark off those squares that are blocked, for the next queen, repeat the same process. Repeat until you have filled the entire grid. You can exploit symmetry. For the first queen, you only need to try 1/8th of the board due to symmetry due to reflection/rotations.
Perhaps there is some number sequence that only applies to boards of given sizes.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
(C++14 using gcc on Linux)
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
int s[1000];
double energy() {
int result = 0;
for (int i = 1; i < 1000; ++i) {
for (int j = 0; j < i; ++j) {
if (std::abs(s[i]-s[j]) == i - j)
Re: (Score:2)
Re: (Score:2)
The program I wrote works. It's a straightforward implementation of simulated annealing (look it up) for this problem, where the word "energy" is the standard term for the thing you are trying to minimize. I didn't bother making it for general n (although you can
Re: (Score:2)
I confess I didn't understand the code, but that doesn't prevent me asking:
How long did it take to run for n=1,000?
How long will it take to run for n=1,000,000?
Re: (Score:2)
Re: (Score:1)
I confess I didn't understand the code
It's fairly straight forward. The "s" array holds numbers from 0 to N, and represents the positions of queens on the board, for example if s[3]==5 then there's a queen at position (3,5). This method of representing the board automatically ensures no two queens share a row or column, so you just have to worry about diagonals.
The "energy" function compares every queen with every other queen to see if they are on the same diagonal, and returns the number that are.
The code starts with numbers all in order in th
Re: (Score:2)
Thanks. That was very informative.
I don't think 1,000,000 is feasible with this algorithm.
You might be right. It might not be productive either.
Re: (Score:2)
Re: (Score:2)
Re: (Score:1)
They are clear: "What would be necessary would be either a proof that there is an algorithm that can solve the n-Queens Completion puzzle in polynomial time, or a proof that no such algorithm exists.”
Re: (Score:2)
Re: (Score:2)
Re: (Score:1)
Re: (Score:2)
Re: (Score:1)
Re: (Score:2)
Re: (Score:2)
Re: (Score:1)
Re: (Score:2)
Re: (Score:2)
Re: (Score:1)
I'm not trying to justify anything. I'm trying to explain the problem. You're approaching it from a programming point of view. That's the wrong point of view. The prize is being offered for a mathematical proof, not for an algorithm, no matter how clever it might be.
Re: (Score:1)
Yes, I knew what you meant. But considering that the non-completion problem has a straightforward and known solution, and yet the completion version is the basis for this mathematical prize, I think you are underestimating the relevance of it.
Re: (Score:2)
Re: (Score:2)
Re: (Score:1)
Re: (Score:2)
Re: (Score:3)
Not only that, but if an 8-queen solution works on an 8x8 board, it'll work just as well on a 1000x1000 or a 10k x 10k board, etc. board. Move it over, put it in the same relative location in the 8x8 group at the corner of the larger board, done. So solve for 8x8 and move.
So you'll need to split that money with me, pal. :)
Of course, it's just slightly possible that TFS is not an accurate summary of the actual article / problem, but...
Nah. Besides, everyone knows that reading TFA is un-American. Even reading the summary raises red flags with Homeland Security, and may result in a National Security Letter (which you can read, but can't discuss.)
You are correct, the article and the summary are misleading/wrong.
Here's those guys explaining the problem and prize again.
https://www.claymath.org/event... [claymath.org]
Re: (Score:1)
I'm not sure whether or not I understood your "solution", but if I did, I don't think it works quite as easily as you suggest.
What I think you proposed, was dividing the larger board into a grid of sub-grids, and then just filling them in recursively (so, for example, to get a 64x64 solution, start with an 8x8 solution, replace each empty square with an empty 8x8 grid inside of it, and each queen with an 8x8 solution). If that's your method, it doesn't work because the diagonals on the higher order board sp
Re: (Score:2)
The same could be said about factorizing large integer numbers in encryption or bitcoin mining with 256-bit hashes based on SHA-256. But it's the ratio to the vast combination size relative to the actual available solutions. Universities have a similar challenge in finding a campus wide timetable that guarantees that no student has a set of courses that clash in terms of tutorials/lectures/lab times, but that all students can attend tutorials/lectures/labs that are common to many subjects.
The story is mis-worded. You did it again editors. (Score:5, Informative)
> Dr Jefferson added: “There is a $1,000,000 prize for anyone who can prove whether or not the Queens Puzzle can be solved quickly so the rewards are high.”
It's not the solution that gets you the prize, but the proof that the solution can be done quickly (without exploring nearly every permutation).
Re: (Score:3)
Yes it would. The Queen's Puzzle is an NP-complete problem, hence a solution to it would solve every other NP-complete problem.
Re: The story is mis-worded. You did it again edit (Score:1)
Re: (Score:2)
More to the point, anything larger that 8x8 isn't a chess board
Well... [wikipedia.org]
Re: (Score:1)
To slashdot's apparent surprise, once again the article happens to provide the answer. Amazing run of good fortune there.
-- "What would be necessary would be either a proof that there is an algorithm that can solve the n-Queens Completion puzzle in polynomial time, or a proof that no such algorithm exists.”
misleading title and rebranded P vs NP (Score:5, Insightful)
Second of all, the $1m prize is exactly the clay millennium prize for the resolution of P vs NP. If n-qeens has a solution in P, being NP-complete, this implies P=NP.
tldr Sensationalist title is sensationalist
Re: (Score:2)
Moreover, you can write a headline like this every single day and never exhaust the number P vs NP equivalent problems.
How Sudoku could win you a million dollars [unimelb.edu.au]
Finding others is an exercise for the reader.
Re: (Score:2)
P=NP is easy to do in Python (Score:2, Offtopic)
I don't understand the fuss, I found not only one but TWO ways to figure out P=NP using Python. Doesn't even require numpy or a GPU and it works even with super big numbers.
#Solution 1:
for N in range(sys.maxsize):
P = 0
if P == N * P:
print("it works.")
#Solution 2:
for P in range(sys.maxsize):
N = 1
if P == N * P:
Re: (Score:3)
It's not necessarily the issue of P=NP, though such a solution absolutely would resolve this issue.
The "problem" here is that there is no cost function. This is an Ariadne's Thread dilemma in that you can only verify your solution once you have placed as many queens as your placement will allow. You cannot place a single queen on an n x n board and then conclude that you are one step closer to a solution. There is no way to subdivide this problem, hence no way to solve it in a "sufficiently" fast manner (i.
Re: (Score:2)
Solve P=NP win $$$ (Score:1)
Also something about chess.
I solved it (Score:2, Funny)
I have discovered a truly remarkable program which this box is too small to contain. I'll complete it after I get back from a duel I have later today.
Re: I solved it (Score:2)
The actual content of the article (Score:4, Informative)
Three researchers proved that the queen problem is NP-complete. The prize is the millennium prize for P=NP. The journal publication is at http://jair.org/papers/paper5512.html.
Re: (Score:1)
I haven't read the paper, but I have a suspicion that this paper's conclusion that partially-filled N-queens is NP complete will be shown to be false.
Why? Because my gut tells me that you can probably permute the board and convert partially-filled n-queens problem to a "normalized" form that can be solved as efficiently as the empty board n-queens problem: "can this input be rearranged into a prefix substring of the normalized solution for NxN?"
Re: (Score:1)
Because my gut tells me that you can probably permute the board and convert partially-filled n-queens problem to a "normalized" form that can be solved as efficiently as the empty board n-queens problem: "can this input be rearranged into a prefix substring of the normalized solution for NxN?"
Interesting idea, but JOTTOMH I'm concerned about the normalization step. Permutation grows super-polynomially, of course, so naive normalization won't get you out of NP-Complete.
Or from the other direction: assuming one-way functions exist, then starting with a normal-form partial-N-queens solution, shuffling into any of the non-normal permutations is poly-time, but reversing that shuffle looks at first glance like it might be orthogonal to some other one-way functions.
But that's based on, like, 30 seconds
Re: (Score:3)
too bad that with Prolog solving the queen problem using CLP(FD) (using gprolog for instance) 500 queens can be solved in less than a second...
The problem is that, as the the paper shows, the n-queen problem is NP-complete, which in layman's terms means that the best algorithm that we know of would take exponential time to solve it.
To illustrate it, let's assume a hypothetical problem that has an (exponential) algorithm which takes 1 second to solve it with an input of 500 (queens or otherwise), and that the base of the exponent is 2 -- meaning that it would take 2 seconds to solve for an input of 501, 4 seconds for an input of 502, and so on.
Cont
Define "quick" (Score:2)
Serious question... I've written something like that before, and although it wasn't speedy... I don't recall it being particularly long either.
Also, does it have to come up with all solutions quickly, or just one?
Re: (Score:2)
Re: (Score:2)
Perhaps you had failed to notice that I had said never mind in the above reply to my own post. I realized what they were talking about after I had already posted the first comment. Slashdot doesn't allow deletion of posts, so....
Clearly I should have paid more attention before posting, but I would have figured that my previous comment would make it obvious that I was aware of that mistake.
Anyways, telling me to shut up after I already admitted my bad is at best only making you look like you are too
Re: (Score:2)
Re: (Score:3)
"Quick" is defined in terms of how the running time for the solver scales with the size of the board. If you plot the time it takes to place N queens on an NxN board, you get an exponential curve for all currently known solvers. Either of two possibilities will result in winning $1 million:
1. Proving that this is the best one can do and that there are no better algorithms.
2. Finding a queens-placing algorithm whose running time is bounded by a polynomial function on N.
Re: (Score:2)
Re: (Score:2)
Here's your algorithm (Score:2)
Start cursor in the upper left cell.
Mark/Queen location
--- Subroutine start
Shift cursor right, down 2 (like a Knight!)
Mark
if out of bounds or final Y row
break
--- Subrouting end
Shift cursor up, right 2
Mark
--- Subroutine start
Shift cursor right, up 2
Mark
if out of bounds or initial Y row
break
--- Subrouting end
Done. There is a simple solution, but the prize is about being able to prove there is a simple solution, without coming up with it (P = NP)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
I know what his algorithm does. And for n=1000, it will take more time than a billion universes put together. Thus he will get nothing -- at least not in this Universe.
Re: (Score:2)
Re: (Score:2)
I gotta say this is interesting, but maybe not workable.
Is there a simple algorithm for locating the solved 8x8 into a 10x10 and then placing the remaining 2 queens into the open squares?
We can't know ahead of time what the new location of the solved puzzle will be in the larger puzzle.
We'll have to try all the possible new locations. I doubt it can be guaranteed that if a solution for n exists, then there will be guaranteed a solution for n+1 in which that n solution can be embedded, and that is a requirem
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
It takes under a second to run this (given a fair bit of memory, since scripting languages are greedy):
$start = microtime();
$n = 1000;
$emptyVal = 0;
$queenVal = 1;
$n_by_n_array = array_fill(0, $n, array_fill(0, $n, $emptyVal));
$xptr = 0;
$yptr = 0;
$queensPlaced = 0;
while(true)
{
$n_by_n_array[$yptr][$xptr] = $queenVal;
$queensPlaced++;
$xptr += 1;
$yptr += 2;
if ($yptr
Re: (Score:2)
Re: (Score:2)
I share CustomSolvers2's reserve in your apparent assumption that a technique that works specifically(?) on an 8*8 board would work for larger boards. A simple, and obvious test would be to try it with a 9*9 grid, and eyeball the result - though you'd have to implement some way to view the proposed solution for that board size. I don't even know, does the particular algorithm you're using work for all the smaller board sizes as well? FWIW, I'm a bit ashamed to admit I do not currently understand your code,
Re: (Score:2)
My solution does not satisfy as a solution for n queens in an n x n board for many different values. Notably, there is no solution for n=4, n=3, n=2.
The problem is deceptively easy for n/2+1 placements. Once past that, it takes an increasingly (maybe infinitely) complex perturbation to get a stable algorithm as size increases. See 8x8 below, where 8/2+1 placements are algorithmically simple.
1 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 -- 1, ceil(n/2) always a valid placement starting from 0 index
0 1 0 0 0 0 0 0
0 0 0 0 0
Re: (Score:2)
Thanks.
If you were able to come up with a relatively simple general solution, it's not very hard for a computer to calculate 1mil x 1mil grid (https://www.quora.com/How-many-operations-per-second-can-a-computer-do-How-is-it-related-to-GHz). If you can parallelize this problem (which will do so nicely), the processing time of that experiment won't be noticeable. Proving that it's properly parallelized is another NP problem.
And I tend to agree.
Where is my Beowulf cluster joke (Score:2)
Re: (Score:2)
Re: (Score:1)
with 100M cores in a compute cluster I imagine this problem simplifies into a few months worth of cluster time...
It depends. Do the nodes in the cluster run systemd?
When will slashdot hit rock bottom? (Score:2)
So, prove P=NP, win $1 million. Makes sense, why is this nonsense even here?
Visualizer of different algos (Score:3, Interesting)
Really cool in-browser visualizer of 5 different algorithms for solving this problem...
http://haseebq.com/n-queens-visualizer/ [haseebq.com]
The summary and article are crap (Score:2)
Both the summary and the article are crap.
The important part is the following line from the abstract:
We show that n-Queens Completion is both NP-Complete and #P-Complete.
All the rest (other than the math in the actual paper) is fluff.
Obviously, (Score:2)
feels like (Score:2)
Re: (Score:2)
Complexity of base solution is O(n!). If you think that going possibly 2-3 faster with your favorite toy language compared to java is going to change much for n=1000, you are seriously confused.