1.0.1 • Published 5 years ago

n-queens v1.0.1

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
5 years ago

n-queens

npm version

The classic N-Queens problem solved using backtracking.

How to use

import { NQueen } from 'n-queen';
const instance = new NQueen(8);
instance.solveNQ();
instance.printSolution();

Example output

Using N = 8, you'll see the next output:

instance.printSolution();

// 1  0  0  0  0  0  0  0
// 0  0  0  0  0  0  1  0
// 0  0  0  0  1  0  0  0
// 0  0  0  0  0  0  0  1
// 0  1  0  0  0  0  0  0
// 0  0  0  1  0  0  0  0
// 0  0  0  0  0  1  0  0
// 0  0  1  0  0  0  0  0