PDA

View Full Version : Recursive Function


discoverer02
May4-04, 06:56 PM
I have an assignment to write a recursive function that will safely place n Queens on an n x n chessboard. This wasn't all that difficult to figure out.

For extra credit I'm supposed to write another function(s) (recursive?) that figures out all the possible solutions. This is, so far, giving me fits.

Any nudge in the right direction would be greatly appreciated.

dduardo
May4-04, 07:19 PM
Can you be a little more specific in what you mean by figure out all the possible solutions? Do you mean once you place all the queens on the board, find all the possible moves which lead to a checkmate? That might take a while, especially if you have a bunch of queens. It is on the exponential scale.

discoverer02
May4-04, 07:22 PM
Sorry for not being clear. By solutions, I mean all the possible ways I can place the Queens safely. ie. No Queen can attack another Queen on the board.

dduardo
May4-04, 07:29 PM
Here is what a google search turned up:

http://www.math.utah.edu/~alfeld/queens/queens.html

discoverer02
May4-04, 07:45 PM
Thanks dduardo.