Compare commits
4 Commits
c2e4b8ae53
...
main
Author | SHA1 | Date | |
---|---|---|---|
e754e6e44b | |||
8287699a4b | |||
d3b11df015 | |||
6635adf26a |
20
Grille.php
20
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 = [];
|
||||
|
58
Trie.php
58
Trie.php
@ -52,10 +52,40 @@ class Trie implements ArrayAccess, IteratorAggregate, Countable {
|
||||
}
|
||||
}
|
||||
|
||||
public function arrayIterator() {
|
||||
// ArrayAccess
|
||||
public function offsetSet($array, $valeur): void {
|
||||
if (is_string($array)) {
|
||||
$array = str_split($array);
|
||||
}
|
||||
$this->arraySet($array, $valeur);
|
||||
}
|
||||
|
||||
public function offsetExists($array): bool {
|
||||
if (is_string($array)) {
|
||||
$array = str_split($array);
|
||||
}
|
||||
return $this->arrayExists($array);
|
||||
}
|
||||
|
||||
public function &offsetGet($array): mixed {
|
||||
if (is_string($array)) {
|
||||
$array = str_split($array);
|
||||
}
|
||||
return $this->arrayGet($array);
|
||||
}
|
||||
|
||||
public function offsetUnset($array): void {
|
||||
if (is_string($array)) {
|
||||
$array = str_split($array);
|
||||
}
|
||||
$this->arrayUnset($array);
|
||||
}
|
||||
|
||||
// IteratorAggregate
|
||||
public function getIterator(): Traversable {
|
||||
foreach ($this->branches as $cle => $branche) {
|
||||
if ($branche instanceof Trie) {
|
||||
foreach($branche->arrayIterator() as $sous_cles => $feuille) {
|
||||
foreach($branche->getIterator() as $sous_cles => $feuille) {
|
||||
yield array_merge([$cle], $sous_cles) => $feuille;
|
||||
}
|
||||
} else {
|
||||
@ -64,30 +94,6 @@ class Trie implements ArrayAccess, IteratorAggregate, Countable {
|
||||
}
|
||||
}
|
||||
|
||||
// ArrayAccess
|
||||
public function offsetSet($string, $valeur): void {
|
||||
$this->arraySet(str_split($string), $valeur);
|
||||
}
|
||||
|
||||
public function offsetExists($string): bool {
|
||||
return $this->arrayExists(str_split($string));
|
||||
}
|
||||
|
||||
public function &offsetGet($string): mixed {
|
||||
return $this->arrayGet(str_split($string));
|
||||
}
|
||||
|
||||
public function offsetUnset($string): void {
|
||||
$this->arrayUnset(str_split($string));
|
||||
}
|
||||
|
||||
// IteratorAggregate
|
||||
public function getIterator(): Traversable {
|
||||
foreach($this->arrayIterator() as $array => $valeur) {
|
||||
yield implode("", $array) => $valeur;
|
||||
}
|
||||
}
|
||||
|
||||
// Countable
|
||||
public function count(): int {
|
||||
return $this->nb_branches;
|
||||
|
8
dico.csv
8
dico.csv
@ -579,8 +579,8 @@ COTON Devient souvent mauvais quand on le file@Michel Laclos
|
||||
COU S'y pendre est plus sympa que d'y mettre la corde@Thierry Larsan
|
||||
COUCHETTE Vous permet, en somme, d’être en train@Georges Perec Grâce à elle on peut être en train couenne@Tour de cochon
|
||||
COULANT S’accorde à nœud@Lionel Leteur
|
||||
COUP DE FOUDRE Ce qui arrive lorsque se rencontrent deux personnes très excitées, mais peu sélectives
|
||||
COUPEPAPIER Lame pour "les trois mousquetaires"@Thierry Larsan
|
||||
COUP DE FOUDRE Ce qui arrive lorsque se rencontrent deux personnes très excitées, mais peu sélectives
|
||||
COUPE PAPIER Lame pour "les trois mousquetaires"@Thierry Larsan
|
||||
COUPEROSE Ne désigne absolument pas une espèce de sécateur@Georges Perec
|
||||
COUR Plat agréable à faire@Michel Laclos S'annonce aux messieurs, se fait aux dames@Bernard Philippet
|
||||
COURAGE N’écouter que le sien@Alain Schifres dans Les Hexagons Art d'avoir peur sans que cela paraisse
|
||||
@ -1807,7 +1807,7 @@ OPPOSITION En politique, le parti qui empêche le gouvernement d'aller battre la
|
||||
OPTICIEN Deux verres chez lui pour éviter les dégâts@Philippe Dupuis
|
||||
OPTIMISTE Adepte de la doctrine selon laquelle le noir est blanc@Ambrose Bierce Personne qui commence à faire ses mots croisés au stylo-bille
|
||||
OPULENTES Avec avantages en nature ou en espèces@Corinne Beltz
|
||||
OR Son pont nous permet de rouler dessus@Georges Perec Matière pour un livre mais plus pour une livre@Robert Scipion A été veau avant d’être étalon@Dédale Brillante conjonction@Michel Laclos Pour un bridge ou un pont@Philippe Dupuis Prix fort@Philippe Harang Massif apprécié@Lucien Lacau Une eau s'en régale@Guy Hachette Plut à danaé@Thierry Larsan Le massif des écrins@Bernard Philippet Précieuse conjonction
|
||||
OR Son pont nous permet de rouler dessus@Georges Perec Matière pour un livre mais plus pour une livre@Robert Scipion A été veau avant d’être étalon@Dédale Brillante conjonction@Michel Laclos Pour un bridge ou un pont@Philippe Dupuis Prix fort@Philippe Harang Massif apprécié@Lucien Lacau Une eau s'en régale@Guy Hachette Plut à Danaé@Thierry Larsan Le massif des écrins@Bernard Philippet Précieuse conjonction
|
||||
ORACLE Il se mouille parfois mais ne sèche jamais@Bernard Philippet
|
||||
ORAL Procès-verbal@Michel Laclos
|
||||
ORANGE Souvent pressée dès le réveil@Michel Laclos Réunion de quartier
|
||||
@ -2158,7 +2158,7 @@ RENGAINE Un air qui commence par vous entrer par une oreille et qui finit par vo
|
||||
RENI Guide pour amateur d’art@Corinne Beltz
|
||||
RENTABLES Quand les choses le sont c’est qu’il y a un certain rapport@Georges Perec
|
||||
RENTREE Revenue ou revenu@Michel Laclos
|
||||
REPAS C’est après l’avoir saut é qu’on se sent léger@Paul Roisin
|
||||
REPAS C’est après l’avoir sauté qu’on se sent léger@Paul Roisin
|
||||
REPASSEUSE Dame de fer@Michel Deineko
|
||||
REPETITION C’est du travail avant de jouer@Michel Laclos
|
||||
REPLIQUE Double sauf sur scène@Philippe Harang
|
||||
|
Can't render this file because it has a wrong number of fields in line 12.
|
5
dico.php
5
dico.php
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
include_once "Trie.php";
|
||||
|
||||
|
||||
@ -48,9 +49,9 @@ function mots_espaces($longueur_max) {
|
||||
for ($longueur = $longueur_max; $longueur >= 2; $longueur--) {
|
||||
for ($position_espace = $longueur - 1; $position_espace >= 1; $position_espace--) {
|
||||
$mots_suivants = $dico[$longueur - $position_espace - 1];
|
||||
foreach ($dico[$position_espace]->arrayIterator() as $premier_mot => $definition) {
|
||||
foreach ($dico[$position_espace] as $premier_mot => $definition) {
|
||||
$premier_mot[] = CASE_NOIRE;
|
||||
$dico[$longueur]->arraySet($premier_mot, $mots_suivants);
|
||||
$dico[$longueur][$premier_mot] = $mots_suivants;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
63
index.php
63
index.php
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
include_once "Grille.php";
|
||||
|
||||
|
||||
@ -85,33 +86,35 @@ function formatter_definition($definition) {
|
||||
<body>
|
||||
<form id="grilleForm" method="get" location=".">
|
||||
<h1 class="large width">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td>M</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>c</td>
|
||||
<td>r</td>
|
||||
<td>o</td>
|
||||
<td>i</td>
|
||||
<td>s</td>
|
||||
<td>é</td>
|
||||
<td>s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td>t</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td>s</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<a href=".">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td>M</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>c</td>
|
||||
<td>r</td>
|
||||
<td>o</td>
|
||||
<td>i</td>
|
||||
<td>s</td>
|
||||
<td>é</td>
|
||||
<td>s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td>t</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td>s</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</a>
|
||||
</h1>
|
||||
<h1 class="small width">Mots■croisés</h1>
|
||||
<h1 class="small width"><a href=".">Mots■croisés</a></h1>
|
||||
<div class="grille-et-definitions">
|
||||
<?php if ($grille_valide): ?>
|
||||
<div class="grille">
|
||||
@ -133,7 +136,7 @@ function formatter_definition($definition) {
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td class="case blanche">
|
||||
<input id="<?= chr($x + 65) . ($y + 1) ?>" type="text" maxlength="1" size="1" pattern="[A-Z]" placeholder="<?= $grille[$y][$x] ?>"
|
||||
<input id="<?= chr($x + 65) . ($y + 1) ?>" type="text" maxlength="1" size="1" pattern="[A-Z]"
|
||||
title="<?= strip_tags("→ " . implode("\n→ ", array_map("formatter_definition", $grille->definitions["horizontales"][$y] ?? [])) . "\n↓ " . implode("\n↓ ", array_map("formatter_definition", $grille->definitions["verticales"][$x] ?? []))) ?>" />
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
@ -152,9 +155,9 @@ function formatter_definition($definition) {
|
||||
<?= formatter_definition($definitions[0]) ?>
|
||||
<?php else: ?>
|
||||
<ol>
|
||||
<?php foreach ($definitions as $definition) : ?>
|
||||
<li><?= formatter_definition($definition) ?></li>
|
||||
<?php endforeach ?>
|
||||
<?php foreach ($definitions as $definition) : ?>
|
||||
<li><?= formatter_definition($definition) ?></li>
|
||||
<?php endforeach ?>
|
||||
</ol>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
42
script.js
42
script.js
@ -35,26 +35,28 @@ for (let input of inputs) {
|
||||
};
|
||||
|
||||
input.onkeydown = function (event) {
|
||||
next_input = null;
|
||||
switch (event.key) {
|
||||
case "ArrowUp":
|
||||
next_input = inputs[(input.index - largeur + nb_cases) % nb_cases];
|
||||
break;
|
||||
case "ArrowDown":
|
||||
next_input = inputs[(input.index + largeur) % nb_cases];
|
||||
break;
|
||||
case "ArrowLeft":
|
||||
next_input = inputs[(input.index - 1 + nb_cases) % nb_cases];
|
||||
break;
|
||||
case "ArrowRight":
|
||||
next_input = inputs[(input.index + 1) % nb_cases];
|
||||
break;
|
||||
}
|
||||
if (next_input) {
|
||||
next_input.focus();
|
||||
next_input.select();
|
||||
event.preventDefault();
|
||||
}
|
||||
next_input = input;
|
||||
do {
|
||||
switch (event.key) {
|
||||
case "ArrowUp":
|
||||
next_input = inputs[(next_input.index - largeur + nb_cases) % nb_cases];
|
||||
break;
|
||||
case "ArrowDown":
|
||||
next_input = inputs[(next_input.index + largeur) % nb_cases];
|
||||
break;
|
||||
case "ArrowLeft":
|
||||
next_input = inputs[(next_input.index - 1 + nb_cases) % nb_cases];
|
||||
break;
|
||||
case "ArrowRight":
|
||||
next_input = inputs[(next_input.index + 1) % nb_cases];
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
} while (next_input.disabled)
|
||||
event.preventDefault();
|
||||
next_input.focus();
|
||||
next_input.select();
|
||||
};
|
||||
|
||||
input.oninput = function (event) {
|
||||
|
@ -18,6 +18,12 @@ h1 {
|
||||
letter-spacing: 0.2em;
|
||||
}
|
||||
|
||||
h1 a {
|
||||
width: 100%;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
h1.large.width {
|
||||
display: inherit;
|
||||
padding-top: 1rem;
|
||||
@ -199,6 +205,7 @@ h2 {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
h1 a:hover,
|
||||
.nouvelle-grille button:hover {
|
||||
color: #2a6496;
|
||||
}
|
||||
@ -315,6 +322,7 @@ h2 {
|
||||
background-color: #edeeee;
|
||||
}
|
||||
|
||||
h1 a:hover,
|
||||
.nouvelle-grille button:hover {
|
||||
color: #479fec;
|
||||
}
|
||||
|
Reference in New Issue
Block a user