Skip to content

YusufBerki/PyEightQueen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyEightQueen

CodeFactor

A Python project for solving 8 queens problem and visualizing it using OpenCV library.

Table of Contents

  1. Introduction
  2. Requirements and Dependencies
  3. Installation
  4. Running

Introduction

Here is the Wikipedia explanation at this link for the 8 queens problem:

The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal. The eight queens puzzle is an example of the more general n queens problem of placing n non-attacking queens on an n×n chessboard, for which solutions exist for all natural numbers n with the exception of n = 2 and n = 3.

This problem can also be solved with brute force (by trying all possibilities). If we wanted to solve this problem with brute force on an 8x8 chessboard, the cost of trying all combinations would be:

Instead of trying all (4,426,165,368) possibilities with the solution in this repository; It is calculated by reducing the 2-dimensional chessboard to one dimension and using column indexes over one dimension. Cost after this reduction for 8x8 chessboard:

Requirements and Dependencies

Python 3.7 or higher is required to run the project.

Also OpenCV library is required for visualization. You can build OpenCV from source code or install it using PyPI as described in the Installation section.

Installation

Clone the project with:

git clone https://github.com/YusufBerki/PyEightQueen.git

To install the required libraries, go to project directory and run the following code:

pip install -r requirements.txt

Running

Run the following code to see the solutions for the 8x8 chessboard:

python main.py

Can change this line to see the results on different sizes of chessboard.

Contact

Yusuf Berki YAZICIOĞLU

License

See MIT License

About

A Python project for solving 8 queens problem and visualizing it using OpenCV library.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages