Conditions | 5 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function solve(Grid $grid): Grid |
||
21 | { |
||
22 | $this->grid = $grid; |
||
23 | for ($row = 0; $row < Grid::NUMBER_OF_ROWS; $row++) { |
||
24 | for ($column = 0; $column < Grid::NUMBER_OF_COLUMNS; $column++) { |
||
25 | $location = new Location($row, $column); |
||
26 | if ($this->grid->isEmpty($location)) { |
||
27 | $possibleValues = $this->grid->getAllPossibilitiesFor($location); |
||
28 | if (count($possibleValues) === 1) { |
||
29 | $grid->set($location, $possibleValues[0]); |
||
30 | $column = 0; |
||
31 | $row = 0; |
||
32 | } |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 | |||
37 | return $grid; |
||
38 | } |
||
40 |