This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get all solutions of `n queens` problem | |
* https://zh.wikipedia.org/wiki/%E5%85%AB%E7%9A%87%E5%90%8E%E9%97%AE%E9%A2%98 | |
* @param n | |
* @returns {*} | |
* @constructor | |
*/ | |
const Nqueens = n => { | |
if (typeof n !== 'number') { | |
console.warn('Expect `n` to be a number got ' + typeof n + '.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const a1 = {name: 'a1', child: null, sibling: null, return: null}; | |
const b1 = {name: 'b1', child: null, sibling: null, return: null}; | |
const b2 = {name: 'b2', child: null, sibling: null, return: null}; | |
const b3 = {name: 'b3', child: null, sibling: null, return: null}; | |
const c1 = {name: 'c1', child: null, sibling: null, return: null}; | |
const c2 = {name: 'c2', child: null, sibling: null, return: null}; | |
const d1 = {name: 'd1', child: null, sibling: null, return: null}; | |
const d2 = {name: 'd2', child: null, sibling: null, return: null}; | |
a1.child = b1; |