Sudoku: Difference between revisions

m
Line 4,440:
this.S = 1;
this.H = H || this;
if (H) {&& (H.S += 1); }
}
}
Line 4,455:
n.L = e;
e.R.L = n;
return e.R = n;
return n;
};
 
Line 4,469 ⟶ 4,468:
n.U = e;
e.D.U = n;
return e.D = n;
return n;
};
 
Line 4,502 ⟶ 4,500:
/**
* Verbatim copy of DK's algorithm for choosing the next column object.
* @param {!DoX} h
* @return {!DoX}
*/
Line 4,553 ⟶ 4,551:
 
//-----------------------------------------------------------[ Print Helpers ]--
 
/**
* Given the standard string format of a grid, print a formatted view of it.
* @param {!string|!Array} gStringa
*/
const printGrid = function(gStringa) {
let gArr = (typeof gString == 'string') ? gString.split('') : gString;
 
const getChar = c => {
let U = Math.sqrt(gArr.length);
let r = Number(c);
if (isNaN(r)) { return c }
 
let o = 48;
if (r > 9 && r < 36) { o = 55 }
if (hDr >= 36) { po = `${p}${div}|61 `}
return String.fromCharCode(r + o)
};
 
a = 'string' == typeof a ? a.split('') : a;
 
let U = Math.sqrt(gArra.length);
let N = Math.sqrt(U);
let divline = new Array(N).fill('+').reduce((p, c) => {
p.push(... Array.from(new Array(1 + N*2).fill('-')));
p.push(c);
Line 4,568 ⟶ 4,578:
}, ['\n+']).join('') + '\n';
 
let ga = gArra.reduce(function(p, c, i) => {
let nld = i && !(i % U), G = i && !(i % N);
let vD = i &&= !(i % (U * N));
let hD =d && !(i %&& (Up += *'|\n| N)');
if (nl d && !hD)i {&& (p += `${p}'|\n| ` }');
if (nl i && hD) { (p = `${'' + p} + line + '|` }');
return '' + p + (G && !d ? '| ' : '') + getChar(c) + ' ';
if (hD) { p = `${p}${div}| `}
p = `${p}${vD, &&'') !nl ?+ '| ' : ''}${c}+ `line;
console.log(ga);
return p;
 
}, '') + '|' + div;
console.log(g);
};
 
Line 4,603 ⟶ 4,612:
const gridMeta = s => {
const g = s.split('');
const numCellscellCount = g.length;
const nCandidtokenCount = Math.sqrt(numCellscellCount);
const N = Math.sqrt(nCandidtokenCount);
const g2D = g.map(e => isNaN(e * 1) ?
new Array(nCandidtokenCount).fill(1).map((_, i) => i + 1) :
[e * 1]);
return [numCellscellCount, N, nCandidtokenCount, g2D];
};
 
Line 4,723 ⟶ 4,732:
'..3......4...8..36..8...1...4..6..73...9..........2..5..4.7..686........7..6..5..'
].forEach(reduceGrid);
 
// Or of you want to create all the grids of a particular n-size.
// I run out of stack space at n = 9
let n = 2;
let s = new Array(Math.pow(n, 4)).fill('.').join('');
reduceGrid(s);
</lang>
 
Anonymous user