fix grid generator :)

This commit is contained in:
Adrien MALINGREY 2020-10-09 01:54:56 +02:00
parent 7621d0c8a5
commit 91f55f7219

View File

@ -1,4 +1,9 @@
<?php <?php
function isKnown($box) {
return $box->value != "?";
}
function isUnknown($box) { function isUnknown($box) {
return $box->value == "?"; return $box->value == "?";
} }
@ -92,6 +97,7 @@
$testBoxes[] = $this->rows[8-$testBox->rowId][$testBox->columnId]; $testBoxes[] = $this->rows[8-$testBox->rowId][$testBox->columnId];
$testBoxes[] = $this->rows[$testBox->rowId][8-$testBox->columnId]; $testBoxes[] = $this->rows[$testBox->rowId][8-$testBox->columnId];
} }
$testBoxes = array_filter($testBoxes, "isKnown");
$erasedValues = array(); $erasedValues = array();
forEach($testBoxes as $testBox) { forEach($testBoxes as $testBox) {
$erasedValues[] = $testBox->value; $erasedValues[] = $testBox->value;
@ -117,7 +123,6 @@
$solutionsFound[$solution] = true; $solutionsFound[$solution] = true;
if (count($solutionsFound) > 1) { if (count($solutionsFound) > 1) {
$solutionsFinder->send(true); $solutionsFinder->send(true);
break;
} }
} }
return count($solutionsFound) == 1; return count($solutionsFound) == 1;