N-Queens Javscript Recursive Solution Visualizer

A Powerful Visualization Tool To Help You Understand An Algorithm To Solve A Famous Computer Science Puzzle
Meet the creator and learn more about this project! What's going on here?

Press Enter or click on the chessboards to advance to the next stack. Click here to start over.

CountNQueensSolutions = function(n) {
  var count = 0;
  var done = Math.pow(2,n) - 1;
  var excl = Math.pow(2, Math.floor(n/2)) - 1;

  var innerRecurse = function(ld, col, rd, ex1, ex2) {

    if (col === done) {
      count++;
      return;
    }

    var poss = ~(ld | rd | col | ex1) & done;

    while (poss) {
      var bit = poss & -poss;
      poss = poss^bit;
      innerRecurse((ld|bit)>>1,col|bit,(rd|bit)<<1,ex2,0);
      x2 = 0;
    }
  };

  innerRecurse(0, 0, 0, excl, n%2 ? excl : 0);
  return count*2;
};

// Learn about this ultra fast algorithm
// at LiuJoyceC.github.io!
          
n: 6done: 111111
count x 2: 0excl: 000111