![]() |
| | #1 |
| Captain - Lover of the C Join Date: May 2005
Posts: 337
| 8 Queens On an 8 by 8 board, place 8 chess queens so that no queen attacks any other queen. A queen can attack horizontally, vertically, or diagonally. Contest Write an algorithm that will find a solution to the 8 queens problem. Rules There will be one queen in each column. The algorithm must decide the row that each queen should be in. [edit]Since this problem lends itself to artifical intelligence, your intelligent agent cannot know anything else about the problem other than the definition. This means that it cannot know the solution. However, heuristics are allowed.[/edit] The algorithm can place the queens on the board in the correct pattern or it can start with all the queens on the board and move them to the correct pattern. If the algorithm starts with the queens on the board, it must either use an algorithm to place them or start with the queens in random rows in each column. Judging I will add this later
__________________ Don't quote me on that... ...seriously Last edited by Brad0407; 06-15-2007 at 09:38 PM. |
| Brad0407 is offline | |
| | #2 |
| aoeuhtns Join Date: Jul 2005
Posts: 581
| Your 'rules' don't much sense to me. Here's my solution: Code: head (queens 8) Edit: here's an alternate solution, in C: Code: void queens8(void) {
puts("[(1,4),(2,2),(3,7),(4,3),(5,6),(6,8),(7,5),(8,1)]");
}
__________________ There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary. Last edited by Rashakil Fol; 06-15-2007 at 01:49 PM. |
| Rashakil Fol is offline | |
| | #3 | |
| Anti-Poster Join Date: Feb 2002
Posts: 1,212
| Quote:
__________________ Rule #1: Every rule has exceptions Traveller's Dilemma Contest Site - Results posted! | |
| pianorain is offline | |
| | #4 |
| Crazy Fool Join Date: Jan 2003 Location: Canada
Posts: 2,588
| This is the most standard programming languages homework assignment around. I'm surprised the spec doesn't say to write it in Lisp.
__________________ jeff.bagu.org - Terrain rendering and other random stuff |
| Perspective is offline | |
| | #5 |
| aoeuhtns Join Date: Jul 2005
Posts: 581
| This is where I am not understanding him. What does it mean for an algorithm to start with the queens on the board? Mine doesn't, I guess, so that rule doesn't apply to my algorithm. And if by some definition it did, I am in fact using an algorithm to place the queens ("place the first at (1,4), another at (2,2)," and so on). Unless Brad would care to suggest some unorthodox definition of 'algorithm'...
__________________ There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary. |
| Rashakil Fol is offline | |
| | #6 |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,927
| I think he means 'calculation' when he says 'algorithm'. This smells awfully like a homework assignment.. so here is my solution - Code: x = 0; while(!solution(x)) x++; oh, and on a 3.2 GHz processor, it will only take a month to find a solution (maybe less), since there are only 178,462,987,637,760 (thats 178 trillion) possibilities, and more than 1 is valid.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 06-18-2007 at 10:20 AM. |
| abachler is offline | |
| | #7 |
| Captain - Lover of the C Join Date: May 2005
Posts: 337
| Guess maybe this contest was too hard... If there are no actual attempt in a week, I'll post a solution. Maybe a few.
__________________ Don't quote me on that... ...seriously |
| Brad0407 is offline | |
| | #8 |
| Registered User Join Date: Jan 2005
Posts: 7,137
| I'm not sure anybody understands what you're asking. |
| Daved is offline | |
| | #9 |
| Fear the Reaper... Join Date: Aug 2005 Location: Toronto, Ontario, Canada
Posts: 625
| Or, rather, why Rashakil Fol's answer isn't correct.
__________________ Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction |
| Happy_Reaper is offline | |
| | #10 |
| Massively Single Player Join Date: May 2007 Location: Buffalo, NY
Posts: 141
| This puzzle is straight out of The 7th Guest. The bishop puzzle is much harder, and would make a much better algorithm. If you haven't played The 7th Guest, a pox upon you!
__________________ There is no greater sign that a computing technology is worthless than the association of the word "solution" with it. |
| AverageSoftware is offline | |
| | #11 | |
| Rampaging 35 Stone Welsh Join Date: Apr 2007
Posts: 2,927
| Quote:
I misspoke, theres a simple optimization that lets you brute force it in 40,320 tries or less.
__________________ He is free, you say. Ah! That is his misfortune… These men… [have] the most terrible, the most imperious of masters, that is, need. … They must therefore find someone to hire them, or die of hunger. Is that to be free? - Simon Linguet Last edited by abachler; 06-18-2007 at 04:56 PM. | |
| abachler is offline | |
| | #12 |
| Registered Abuser Join Date: Jun 2006 Location: Toronto
Posts: 572
| Isn't this problem the "Hello World" of learning recursion? (that and string permutations)
__________________ MSDN knows exactly what you're looking for... |
| @nthony is offline | |
| | #13 |
| Captain - Lover of the C Join Date: May 2005
Posts: 337
| abachler, I don't even start college until August and won't be taking an A.I. class for at least a year after that. You jumping to conclusions is slightly insulting and annoying. You got your first solution from 64*63*62*61*60*59*58*57. However, any fool would write the loops like this: Code: for (Q1 = 0; Q1 < 57; Q1++)
{
for (Q2 = Q1; Q2 < 58; Q2++)
{
for (Q3 = Q2; Q3 < 59; Q3++)
{
for (Q4 = Q3; Q4 < 60; Q4++)
{
for (Q5 = Q4; Q5 < 61; Q5++)
{
for (Q6 = Q5; Q6 < 62; Q6++)
{
for (Q7 = Q6; Q7 < 63; Q7++)
{
for (Q8 = Q7; Q8 < 64; Q8++)
{
}
}
}
}
}
}
}
}
__________________ Don't quote me on that... ...seriously |
| Brad0407 is offline | |
| | #14 |
| Anti-Poster Join Date: Feb 2002
Posts: 1,212
| How is this a contest and not a 'please write this function for me'? How would we compete with one another? The lack of details makes this look exactly like any of the 'do my homework' threads, regardless of an actual lack of assignment. I think it's safe to say that when there's a wiki page that explains several different methods on how to solve the problem and several alternate variations of the problem that have also been studied, this one's been done. Try making this interesting.
__________________ Rule #1: Every rule has exceptions Traveller's Dilemma Contest Site - Results posted! |
| pianorain is offline | |
| | #15 |
| Tropical Coder Join Date: Mar 2005 Location: Cayman Islands
Posts: 503
| Here's some solutions that list all 92 solutions http://www.cppworld.com/forum/index.php?showtopic=852
__________________ SWinC - Simple Windows Class Last edited by Darryl; 06-19-2007 at 08:44 AM. |
| Darryl is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 8 Queens, problem with searching 2D array | Sentral | C++ Programming | 35 | 03-11-2009 04:12 PM |
| Problems with the eight queens problem | Wicket | C++ Programming | 1 | 06-12-2008 09:29 AM |
| 8 Queens problem | Dashing Boy | C++ Programming | 14 | 10-15-2007 12:12 PM |
| and this is my solution for the 8 queens puzzle | negevy | C Programming | 1 | 09-01-2005 11:45 AM |
| 8 Queens | PutoAmo | C Programming | 2 | 03-24-2003 04:45 AM |