gestion problème de génération
This commit is contained in:
parent
50872aef31
commit
2445bfcf54
@ -38,7 +38,6 @@ class Grille {
|
||||
mt_srand();
|
||||
|
||||
$this->grilles = $this->generateur();
|
||||
$this->grilles->current();
|
||||
}
|
||||
|
||||
public function get_ligne($l, $largeur) {
|
||||
@ -133,6 +132,14 @@ class Grille {
|
||||
}
|
||||
}
|
||||
|
||||
public function current() {
|
||||
return $this->grilles->current();
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
return $this->grilles->valid();
|
||||
}
|
||||
|
||||
public function hash() {
|
||||
$string = "";
|
||||
foreach ($this->grille as $ligne) {
|
||||
|
16
dico.php
16
dico.php
@ -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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
favicon.ico
BIN
favicon.ico
Binary file not shown.
Before Width: | Height: | Size: 518 B After Width: | Height: | Size: 518 B |
@ -36,6 +36,8 @@ $largeur = filter_input(INPUT_GET, 'colonnes', FILTER_VALIDATE_INT, [
|
||||
]);
|
||||
|
||||
$grille = new Grille($hauteur, $largeur, $id);
|
||||
$grille->current();
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
@ -78,6 +80,7 @@ $grille = new Grille($hauteur, $largeur, $id);
|
||||
</tbody>
|
||||
</table>
|
||||
</h1>
|
||||
<?php if ($grille->valid()): ?>
|
||||
<table class="grille">
|
||||
<tr>
|
||||
<th></th>
|
||||
@ -141,6 +144,9 @@ $grille = new Grille($hauteur, $largeur, $id);
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<h3 class="erreur">Erreur de génération de la grille</h3>
|
||||
<?php endif ?>
|
||||
|
||||
<input type="hidden" id="lignes" <?php if (isset($_GET["lignes"])): ?>name="lignes" <?php endif ?>value="<?= $hauteur ?>" />
|
||||
<input type="hidden" id="colonnes" <?php if (isset($_GET["colonnes"])): ?>name="colonnes" <?php endif ?>value="<?= $largeur ?>" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user