Skip to content

Commit 0fd4b92

Browse files
committed
preparing for pull
1 parent b792be6 commit 0fd4b92

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

sudoku.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ var printer = require('./boardprinter.js');
99
var boardString = "8 2 5 97 4 25 1 9 2 7 96 3 1 52 6 1 8 4 73 7 65 3 8 9"
1010
var boardArray = boardString.split('');
1111
var cycleCount = 0;
12-
var cycleCountLimit = 20;
12+
var cycleCountLimit = 6;
1313
var masterCycleCount = 0;
14-
var masterCycleCountLimit = 1000;
14+
var masterCycleCountLimit = 15;
1515
var arrayDepot = [];
1616
var arrayDepotIndex = 0;
1717
var iterateControl = [' '];
@@ -29,8 +29,9 @@ function findOptions(fullArray){
2929
var solvedSquares = 0;
3030
masterCycleCount = masterCycleCount + 1;
3131
if (masterCycleCount >= masterCycleCountLimit){
32-
return console.log('Master Cycle Limit Exceeded');
33-
}
32+
console.log('Master Cycle Limit Exceeded');
33+
34+
return }
3435
for (row=0; row<9; row++) {
3536
for (col=0; col<9; col++) {
3637

@@ -65,14 +66,10 @@ function insertSingletonValues(fullArray){
6566
if (cycleCount === cycleCountLimit) {
6667
cycleCount = 0;
6768
console.log('calling findOptions from arrayDepot')
68-
6969
arrayDepotIndex = arrayDepotIndex + 1;
7070
var arrayToPass = arrayDepotIndex - 1;
7171
buildPrinterString(arrayDepot[arrayToPass]);
7272
findOptions(arrayDepot[arrayToPass]);
73-
return;
74-
75-
7673
};
7774

7875
for (row=0; row<9; row++) {
@@ -97,11 +94,16 @@ function insertDupleValues(fullArray){
9794
for (row=0; row<9; row++) {
9895
for (col=0; col<9; col++) {
9996
if (fullArray[row][col].possibles.length === 2 && fullArray[row][col].value === null) {
100-
fullArray[row][col].value = fullArray[row][col].possibles[1];
101-
arrayDepot.push(fullArray);
97+
var secondChoice = fullArray;
98+
secondChoice[row][col].value = secondChoice[row][col].possibles[1];
99+
console.log('first possible choice ' + fullArray[row][col].value);
100+
arrayDepot.push(secondChoice);
102101
fullArray[row][col].value = fullArray[row][col].possibles[0];
103102
console.log('duple assigned at ' + (col + 1) + ', ' + (9-row));
104103
buildPrinterString(fullArray);
104+
console.log('Other dupel possible ')
105+
;
106+
buildPrinterString(arrayDepot[arrayDepotIndex]);
105107
findOptions(fullArray);
106108

107109
return;

0 commit comments

Comments
 (0)