1
0

Corrected twoValPlaces check.

This commit is contained in:
2014-01-25 22:23:02 +01:00
parent 3f918f896b
commit 1afd7e739e
2 changed files with 4 additions and 4 deletions

View File

@ -56,14 +56,14 @@ class @SudokuChecks
p = (1 << i) | (1 << j)
console.log('Now checking (%o, %o) mask: %o', i+1, j+1, p)
for k of cells
if cells[k].getValue() is '.' and (cells[k].getMask() & p) is p
if cells[k].getValue() is '.' and cells[k].getMask() is p
n++
console.log('%d: %d, %d (%o, %o)', n, p, cells[k].getMask(), (p & cells[k].getMask()), ((p & cells[k].getMask()) is p))
console.info('Have %d matches.', n) if n > 0
if n is 2
console.warn('Two matches!')
for k of cells
if cells[k].getValue() is '.' and (cells[k].getMask() & p) is p
if cells[k].getValue() is '.' and cells[k].getMask() is p
cells[k].setMask(p)
else if cells[k].getValue() is '.'
curMask = cells[k].getMask()

View File

@ -82,7 +82,7 @@
p = (1 << i) | (1 << j);
console.log('Now checking (%o, %o) mask: %o', i + 1, j + 1, p);
for (k in cells) {
if (cells[k].getValue() === '.' && (cells[k].getMask() & p) === p) {
if (cells[k].getValue() === '.' && cells[k].getMask() === p) {
n++;
console.log('%d: %d, %d (%o, %o)', n, p, cells[k].getMask(), p & cells[k].getMask(), (p & cells[k].getMask()) === p);
}
@ -93,7 +93,7 @@
if (n === 2) {
console.warn('Two matches!');
for (k in cells) {
if (cells[k].getValue() === '.' && (cells[k].getMask() & p) === p) {
if (cells[k].getValue() === '.' && cells[k].getMask() === p) {
cells[k].setMask(p);
} else if (cells[k].getValue() === '.') {
curMask = cells[k].getMask();