Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 1.25 KB

File metadata and controls

34 lines (22 loc) · 1.25 KB

nQueens

Here's a solution to the nQueen's algorithm using bit shifting and bitwise operators.

The algorithm operates on the premise that a chessboard's current state can be represented by 8 bit binary numbers.

[i.e. given n = 4; n empty columns ==== 0000]

Academic History

The nQueens problem has been tackled by many academics who try to improve the time complexity of the algorithm that finds ways to place any number of queens (represented by n) on an n x n board size.

To see a more thorough explanation of the problem and bit solution, check out: nQueens research

Specifications

This nQueens solution is implemented in Javascript, to read more about Javascript bitwise operators -- refer to Mozilla's documentation on bitwise operators.

Installation

git clone https://github.com/bigthyme/nQueens.git
cd nQueens

After doing this, you can just copy and paste the contents of nQueens.js and paste it into your browser console (or node console) to run the code.

License

MIT License