Sudoku Solving Algorithm (in progress)

Knuth's DLX algorithm implemented in JavaScript

by Taylor Lopez

HTML

<script src="https://cdn.rawgit.com/iAmMortos/JSConsole/master/console.min.js"></script>

JavaScript

function Solver()
{
	this.root = null;
  
  var solution = [];
  var solutions = [];
  
  var _self = this;
  var puzzleSize = 9;
  
  function Node(isHeader, headerType)
  {
    this.headerType = typeof headerType !== 'undefined' ? headerType : "";
  	this.isHeader = typeof isHeader !== 'undefined' ? isHeader : false;
    this.name = "";
    this.col = -1; 
    this.row = -1;
    this.num = -1;
    
  	this.right = this;
    this.left = this;
    this.down = this;
    this.up = this;
  }
  Node.prototype.setName = function(name)
  {
  	this.name = name;
  };
  Node.prototype.setInfo = function(num, row, col)
  {
  	this.num = num;
    this.row = row;
    this.col = col;
  };
  Node.prototype.insertRight = function(node)
  {
    if (this.headerType === 'row')
    {
      if (this.right === this)
      {
        this.right = node;
        this.left = node;
        node.right = node;
        node.left = node;
      }
      else
      {
        node.right = this.right;
        node.left = this.left;
        this.right.left.right = node;
        this.right.left = node;
        this.right = node;
      }
    }
    else
    {
      node.left = this;
      node.right = this.right;
      this.right.left = node;
      this.right = node;
    }
  };
  Node.prototype.insertLeft = function(node)
  {
    if (this.headerType === 'row')
    {
      if (this.left === this)
      {
        this.right = node;
        this.left = node;
        node.right = node;
        node.left = node;
      }
      else
      {
        node.left = this.left;
        node.right = this.right;
        this.left.right.left = node;
        this.left.right = node;
        this.left = node;
      }
    }
    else
    {
      node.right = this;
      node.left = this.left;
      this.left.right = node;
      this.left = node;
    }
  };
  Node.prototype.insertDown = function(node)
  {
  	node.up = this;
    node.down = this.down;
    this.down.up = node;
    this.down = node;
	};
 ...