Skip to content

This Python program solves the Eight Queens puzzle using a backtracking algorithm. It systematically explores all possible configurations of queens on the chessboard and finds the solutions that satisfy the puzzle constraints.

License

Notifications You must be signed in to change notification settings

Slyx737/Eight-Queens-Puzzle-Solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eight Queens Puzzle Solver

The Eight Queens puzzle is a classic problem in chessboard-based puzzles, where the goal is to place eight queens on an 8x8 chessboard in such a way that no two queens threaten each other. A queen can attack horizontally, vertically, and diagonally.

This Python program solves the Eight Queens puzzle using a backtracking algorithm. It systematically explores all possible configurations of queens on the chessboard and finds the solutions that satisfy the puzzle constraints.

How to Use

To run the Eight Queens puzzle solver, follow these steps:

  1. Install Python if you haven't already.

  2. Clone or download this repository to your local machine.

  3. Open a terminal or command prompt and navigate to the directory where you saved the files.

  4. Run the following command to execute the Python script:

python eight_queens.py

The program will output the solutions to the Eight Queens puzzle, represented as a series of chessboard configurations. Each configuration shows the positions of the queens, denoted by 'Q', and empty spaces denoted by '.'.

  1. Analyze the solutions to see how the queens are placed on the chessboard, ensuring that no two queens threaten each other.

  2. Feel free to modify the code or experiment with different board sizes to solve variations of the Eight Queens puzzle.

Sample Output

Here's an example of the output generated by the program:

. Q . . . . . .
. . . . Q . . .
. . . . . . . Q
. . . . . Q . .
Q . . . . . . .
. . Q . . . . .
. . . . . . Q .
. . . Q . . . .

Each row represents a row on the chessboard, and each column represents a column. The 'Q' symbols indicate the positions of the queens, while the '.' symbols represent empty spaces.

Contributing

If you find any issues with the program or have suggestions for improvement, feel free to contribute by submitting a pull request. Your contributions are welcome and appreciated!

License

This project is licensed under the MIT License. You are free to use, modify, and distribute the code for personal and commercial purposes.

About

This Python program solves the Eight Queens puzzle using a backtracking algorithm. It systematically explores all possible configurations of queens on the chessboard and finds the solutions that satisfy the puzzle constraints.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published