| Total Complexity | 13 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class NQueens |
||
| 10 | { |
||
| 11 | public static function solveNQueens(int $n): array |
||
| 12 | { |
||
| 13 | if ($n == 0) { |
||
| 14 | return []; |
||
| 15 | } |
||
| 16 | $positions = []; |
||
| 17 | for ($i = 0; $i < $n; $i++) { |
||
| 18 | $positions[$i] = new Position(); |
||
| 19 | } |
||
| 20 | |||
| 21 | if (self::isAttackedRange($n, 0, $positions)) { |
||
| 22 | return $positions; |
||
| 23 | } |
||
| 24 | |||
| 25 | return $positions; |
||
| 26 | } |
||
| 27 | |||
| 28 | private static function isAttackedRange(int $n, int $row, &$positions): bool |
||
| 54 | } |
||
| 55 | } |
||
| 56 |