Hi Andreas
does anybody know an algorithm to solve the 8-queens-problem in PHP?
You may want to go with a backtracking algorithm. You may do a search on the
net for it and find some language-independent code, which to convert to
php-code should be almostly an easy task. I wrote something like that for
fun in Java, you may email me directly if you want the code.
Btw, make sure, that the maximum execution time of php scripts on your
server is high enough. By default, script abort after 30 seconds. With 8
queens you should get the solutions in some seconds, but if you use more
than 8 queens, by retrieving all solutions, it may take some long time...!
Put the line below on the top of your script, for a timeout of 30 seconds.
Put 0 as the second parameter and it will run without any time-limit:
ini_set('max_execution_time', 30);
Greetings, Greg