Writing a Recursive Function for Placing n Queens on an n x n Chessboard

Click For Summary

Discussion Overview

The discussion revolves around the challenge of writing a recursive function to place n Queens on an n x n chessboard, specifically focusing on finding all possible safe arrangements where no two Queens can attack each other. The scope includes programming techniques and algorithmic approaches.

Discussion Character

  • Homework-related
  • Exploratory
  • Technical explanation

Main Points Raised

  • One participant describes their assignment to write a recursive function for placing n Queens and expresses difficulty in finding all possible solutions.
  • Another participant seeks clarification on what is meant by "all the possible solutions," suggesting a potential misunderstanding regarding the nature of the problem.
  • A later reply clarifies that the intended solutions refer to all safe placements of Queens on the board, where no Queen can attack another.
  • A participant provides a link to a resource that may assist with the problem.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on the specifics of the problem initially, but there is agreement on the goal of finding safe placements for the Queens. The discussion remains somewhat unresolved regarding the best approach to achieve this.

Contextual Notes

There may be limitations in the clarity of the problem statement and assumptions about the nature of the solutions being sought. The discussion does not delve into specific mathematical or algorithmic details.

Who May Find This Useful

Individuals interested in programming, algorithm design, or those working on similar combinatorial problems may find this discussion relevant.

discoverer02
Messages
138
Reaction score
1
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.
 
Last edited:
Computer science news on Phys.org
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.
 
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.
 
Thanks dduardo.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 28 ·
Replies
28
Views
6K