473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

8 queens problem

Hi!
does anybody know an algorithm to solve the 8-queens-problem in PHP?
Jul 17 '05 #1
2 4036
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
Jul 17 '05 #2
It worked, thanks a lot! The PHP script finds all 92 solutions in
about 0.6 seconds. How long does your Java program take?

Greetings, Andreas
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: cfanatic | last post by:
Hey all, I been reading through these forums for a long time but have never posted. Well, I got a dillema. I have a program of the Eight Queen's program and I have to make it work without...
5
by: Matt | last post by:
I will be grateful if someone explians this part colfree = FALSE; upfree = FALSE; downfree = FALSE; of the code below. I don't understand how this marks the downward and upward diagonals....
9
by: totalgeekdom | last post by:
Background: The problem I'm trying to solve is. There is a 5x5 grid. You need to fit 5 queens on the board such that when placed there are three spots left that are not threatened by the queen. ...
4
by: Idea | last post by:
hi guys m new out here and need help with an assignment due next week.The assignmnet is some what related to eight queens problem but not fully, you can say the basic is taken from that problem....
2
by: angel120 | last post by:
Since this is my first post, allow me to introduce myself. My name is Angel, and I'm a 3rd year student at Queens College. I currently am taking CS211, which is the second level of C++, CS212 which...
5
by: angel120 | last post by:
So my second hw is to solve the 8 queens problem using a 1D array. The professor gave us a code that outputs the following (labeled as q): 0 2 5 7 6 3 1 4 The spaces 0-7 refer to the column #,...
18
by: cf29 | last post by:
Greetings, I designed in JavaScript a small program on my website called 5 queens. (http://www.cf29.com/design/dame5_eng.php) The goal is to control all the chess board with five queens that...
1
by: AZRebelCowgirl73 | last post by:
I am trying to develop an 8 queens program, and currently it is working however it is printing 87222211 which is obviously wrong, I am trying to print the row of the queen in order from...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.