Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Codveda-Technologies-Python-Internship-Task-6

N-Queens Problem Solver

Description

This project is a Python-based N-Queens Problem Solver developed as part of the Codveda Technologies Python Development Internship.

The program uses the Backtracking algorithm to place N queens on an N × N chessboard so that no two queens attack each other. It validates user input, finds all possible solutions, and displays the total number of valid arrangements. Users can also choose to view every solution in a simple console-based board format.


Objectives

  • Solve the N-Queens problem using the Backtracking algorithm.
  • Validate user input for the board size (N).
  • Generate all valid queen arrangements.
  • Display the total number of possible solutions.
  • Print each solution in a readable chessboard format.

Technologies Used

  • Python
  • Backtracking Algorithm
  • Recursion
  • Visual Studio Code

Features

  • Accepts any valid board size (N ≥ 1).
  • Finds all possible solutions efficiently.
  • Displays the total number of solutions.
  • Option to print every valid board configuration.
  • User-friendly command-line interface.

How to Run

  1. Make sure Python 3 is installed on your system.

  2. Open the project folder in the terminal.

  3. Run the program:

python n_queens_solver.py

or

python3 n_queens_solver.py
  1. Enter the board size (N) when prompted.

  2. Choose whether to display all valid solutions.


Note

  • The program uses the Backtracking algorithm to solve the N-Queens problem.
  • The number of solutions increases significantly as the value of N becomes larger.
  • For large values of N, the program may take more time to generate all solutions.

Output

  • Accepts the board size (N) from the user.
  • Validates the user input.
  • Displays the total number of valid solutions.
  • Prints all possible board arrangements if requested.
  • Represents queens using Q and empty spaces using .

About

A Python application that solves the N-Queens problem using the Backtracking algorithm and displays all valid solutions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages