From e754e6e44b4526c40b2bdf275bd143b066df13eb Mon Sep 17 00:00:00 2001 From: adrien Date: Fri, 22 Aug 2025 13:09:00 +0200 Subject: [PATCH] =?UTF-8?q?ommission=20des=20lettres=20isol=C3=A9es=20sur?= =?UTF-8?q?=20la=20derni=C3=A8re=20ligne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Grille.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Grille.php b/Grille.php index 0bc55bb..c8bb567 100644 --- a/Grille.php +++ b/Grille.php @@ -134,13 +134,19 @@ class Grille implements ArrayAccess $this->grille[$y][$x] = $lettre; // Omission des lettres isolées - if ($lettre == CASE_NOIRE - && ($y - 2 < 0 || $this->grille[$y - 2][$x] == CASE_NOIRE) - && ($y - 1 < 0 || $x - 1 < 0 || $this->grille[$y - 1][$x - 1] == CASE_NOIRE) - && ($y - 1 < 0 || $x + 1 >= $this->largeur || $this->grille[$y - 1][$x + 1] == CASE_NOIRE) - ) { - continue; - } + if ($lettre == CASE_NOIRE) { + if (($y < 2 || $this->grille[$y - 2][$x] == CASE_NOIRE) + && ($y < 1 || $x == 0 || $this->grille[$y - 1][$x - 1] == CASE_NOIRE) + && ($y < 1 || $x + 1 >= $this->largeur || $this->grille[$y - 1][$x + 1] == CASE_NOIRE) + ) continue; + if ($y == $this->hauteur - 1 + && ($x < 2 || $this[$y][$x - 2] == CASE_NOIRE) + && ($x < 1 || $this[$y - 1][$x - 1] == CASE_NOIRE) + ) continue; + } else if ($x == $this->largeur - 1 && $y == $this->hauteur - 1 + && $this[$y][$x - 1] == CASE_NOIRE + && $this[$y-1][$x] == CASE_NOIRE + ) continue; // Omission des doublons $mots = [];