s-razaq / nQueens

Using a regular chess board, the challenge is to place N queens on the board such that no queen is attacking any of the others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nQueens

Using a regular chess board, the challenge is to place N queens on the board such that no queen is attacking any of the others.

What is the problem?

This problem was proposed by Max Bezzel in 1848 and solved by Franz Nauck in 1850. The problem is simple. It starts with a chess board and eight queens, then set up the board so that no two queens can attack each other. There is more than one solution, and your job is to find them all. We already know that there are 92 possible solutions.

If you've never played chess, you'll need to understand that a queen can attack by moving an unlimited number of spaces in three directions. Horizontally, vertically and diagonally. This means that no two queens can share a row or column, nor can they be located diagonally from each other.

Images

8 Queens

Solution for 8 Queens

4 Queens

Solution for 4 Queens

License

The MIT License (MIT)

Copyright (c) 2015 Saqib Razaq

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Using a regular chess board, the challenge is to place N queens on the board such that no queen is attacking any of the others.

License:MIT License


Languages

Language:Python 100.0%