N-Queen Problem

The "N-Queens Problem" is a classical problem of chess. Here N Queens are to be placed on an N * N chessboard in such a way that no queens attack each other. A Queen can attack other Queens if its placed on the same row, column or on its diagonals. We use Backtracking in the backend to solve this problem .

Usage

To Install this package. Use :

  pip install nqueens

Class Definition

class Queen:
     def __init__(self, n = 0, algo = "backtrack", pos = []):
          self.n = int(n)
          self.algo = algo
          self.pos = []
          self.count = 0
          self.queen_data = []

Use the below snippit to start using the package.

 from nqueens import * 

NQueens Possible Solution Space

qq = Queen(5)
qq.pprint()

Use scan_queen() class function to solve NQueens problem with image input.

image

qq = Queen(4, algo = "backtrack")
qq.scan_queen("q5.PNG")

NQueens Solution space as Voice output

  qq = Queen(4)
  qq.alexa()

NQueens Solution space as image output

  qq = Queen(4, algo = "backtrack")
  qq.display()

NQueens Solution space as PNG File output

  qq = Queen(4)
  qq.save()
Special Credits: https://python-packaging-tutorial.readthedocs.io/en/latest/setup_py.html
References: https://www.geeksforgeeks.org/printing-solutions-n-queen-problem/
Visit our GitHub Repository for more information: https://github.com/toshihiroryuu/nqueens---PyPI-Package