gestion problème de génération

This commit is contained in:
2025-04-28 18:33:14 +02:00
parent 50872aef31
commit 2445bfcf54
5 changed files with 84 additions and 67 deletions

View File

@ -3,7 +3,7 @@
const MIN_LETTRES_MOT_1 = 2;
const MIN_LETTRES_MOT_2 = 0;
const MAX_MOTS = 100000;
// const MAX_MOTS = 100000;
$dico = [];
@ -59,9 +59,9 @@ function mots_espaces($longueur)
fisherYatesShuffle($mots_de_n_lettres[$longueur]);
foreach ($mots_de_n_lettres[$longueur] as $mot) {
yield $mot;
if (++$nb_mots > MAX_MOTS) {
return;
}
// if (++$nb_mots > MAX_MOTS) {
// return;
// }
}
for ($i = MIN_LETTRES_MOT_1; $longueur - $i - 1 >= MIN_LETTRES_MOT_2; $i++) {
foreach ($mots_de_n_lettres[$i] as $mot1) {
@ -71,10 +71,10 @@ function mots_espaces($longueur)
yield "$mot1 $mot2";
$dico["$mot2 $mot1"] = array_merge($dico[$mot2], $dico[$mot1]);
yield "$mot2 $mot1";
$nb_mots += 2;
if ($nb_mots > MAX_MOTS) {
return;
}
// $nb_mots += 2;
// if ($nb_mots > MAX_MOTS) {
// return;
// }
}
}
}