Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaiswalchitransh/n-queens-problem-using-backtracking
The aim of N-Queens Problem is to place N queens on an N x N chessboard, in a way so that no queen is in conflict with the others.
https://github.com/jaiswalchitransh/n-queens-problem-using-backtracking
artificial-intelligence backtracking backtracking-algorithm n-queens n-queens-problem project python python-3 python3
Last synced: 10 days ago
JSON representation
The aim of N-Queens Problem is to place N queens on an N x N chessboard, in a way so that no queen is in conflict with the others.
- Host: GitHub
- URL: https://github.com/jaiswalchitransh/n-queens-problem-using-backtracking
- Owner: jaiswalchitransh
- Created: 2024-08-02T08:18:32.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-28T20:42:18.000Z (6 months ago)
- Last Synced: 2024-10-18T13:14:58.295Z (4 months ago)
- Topics: artificial-intelligence, backtracking, backtracking-algorithm, n-queens, n-queens-problem, project, python, python-3, python3
- Language: Python
- Homepage:
- Size: 468 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# N-Queens Problem using Backtracking
## Table of Contents
- [Project Overview](#project-overview)
- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [Contribution](#contribution)## Project Overview
This Python script solves the N-Queens problem using a backtracking algorithm. The goal of the N-Queens problem is to place N queens on an N×N chessboard such that no two queens threaten each other. The script generates all possible solutions for placing the queens on the board and can handle boards of size N where N is greater than or equal to 4. It employs a depth-first search approach to explore possible placements of queens and backtracks when a conflict is detected.The script accepts the size of the chessboard from the user, then calculates and displays one of the possible solutions randomly, along with the total number of solutions.
## Installation
This project requires Python 3.12.1 or later.
To set up the project:
1. Ensure Python 3.12.1 or a later version is installed on your system. You can download Python from [python.org](https://www.python.org/downloads/).
2. Clone or download the repository to your local machine.https://github.com/jaiswalchitransh/N-Queens-Problem-using-Backtracking.git
4. Open the project in your preferred Python environment (e.g., IDE or terminal).
5. Run the script (`n-queens.py`) and observe the output.## Usage
Run the script:python n-queens.py
Follow the on-screen prompts to input the size of the chessboard. The script will then compute and display one of the solutions to the N-Queens problem and the total number of possible solutions.
## Features
- **Backtracking Algorithm**: Efficiently finds all solutions by exploring possible placements of queens.
- **Random Solution Display**: Randomly selects and prints one of the valid solutions.
- **Solution Count**: Outputs the total number of solutions for the given board size.## Contribution
I, **[Chitransh Jaiswal](https://www.linkedin.com/in/jaiswalchitransh/)** developed this Project Individually. I was responsible for all aspects of the project, including design, development, testing, and documentation.
Contributions to improve the efficiency, readability, or functionality of the code are welcome. To contribute:
1. Fork the repository.
2. Create a new branch (`git checkout -b feature/your-feature`).
3. Make your changes.
4. Commit your changes (`git commit -am 'Add some feature'`).
5. Push to the branch (`git push origin feature/your-feature`).
6. Create a new Pull Request.Please ensure your contributions adhere to the coding standards and follow the existing style and structure.
---
Thank you for your interest in the N-Queens problem solver. Explore the solutions to this classic problem and contribute to further enhancements!