This commit is contained in:
2025-05-02 15:15:47 +02:00
parent 63cd243e91
commit 10ea7a7f0b
2 changed files with 5 additions and 7 deletions

View File

@ -98,23 +98,21 @@ class Grille implements Iterator, ArrayAccess {
foreach ($lettres_communes as $lettre => $_) {
$this->grille[$y][$x] = $lettre;
$this->lignes[$y] = [];
if ($x == $this->largeur - 1) {
foreach (explode(" ", $this->get_ligne($y, $this->largeur)) as $rang => $mot) {
if (strlen($mot) == 1) continue;
if (in_array($mot, array_merge(...$this->lignes, ...$this->colonnes))) return;
if (in_array($mot, array_merge(...$this->lignes, ...$this->colonnes))) continue 2;
$this->lignes[$y][$rang] = $mot;
}
} else {
$this->lignes[$y] = [];
}
$this->colonnes[$x] = [];
if ($y == $this->hauteur - 1) {
foreach (explode(" ", $this->get_colonne($x, $this->hauteur)) as $rang => $mot) {
if (strlen($mot) == 1) continue;
if (in_array($mot, array_merge(...$this->lignes, ...$this->colonnes))) return;
if (in_array($mot, array_merge(...$this->lignes, ...$this->colonnes))) continue 2;
$this->colonnes[$x][$rang] = $mot;
}
} else {
$this->colonnes[$x] = [];
}
if ($i < $this->nb_positions) {