summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/profcollege/latex/PfCJeuRangement.tex
blob: 09b1dc7d68741cbe10a576c54179047d3939f016 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
\setKVdefault[JeuRgt]{Creation=false,Deno=12,Graines=false,Largeur=15pt,Hauteur=20pt,Negatif=false,Decimaux=false,Solution=false,ValeurMin=2,ValeurMax=50}
\defKV[JeuRgt]{Graine=\setKV[JeuRgt]{Graines}}%

\newlength{\PfCJeuRgtH}

\NewDocumentCommand\DefiRangement{omm}{%
  \useKVdefault[JeuRgt]%
  \setKV[JeuRgt]{#1}%
  \setlength{\PfCJeuRgtH}{\useKV[JeuRgt]{Hauteur}+\tabcolsep}%
  \ifboolKV[JeuRgt]{Graines}{\PfCGraineAlea{\useKV[JeuRgt]{Graine}}}{}%
  % On décompose la phrase
  \xdef\PfCFooDepart{}%
  \StrLen{#2}[\LongueurMot]%
  \xintFor* ##1 in{\xintSeq{1}{\LongueurMot}}\do{%
    \StrChar{#2}{##1}[\LettreMot]%
    \xdef\PfCFooDepart{\PfCFooDepart\LettreMot/}%
  }%
  \setsepchar[*]{/}\reademptyitems%
  \readlist*\ListeDesLettres{\PfCFooDepart}%
%  La liste des Lettres est \showitems\ListeDesLettres[]%
  % Liste des nombres
  \ifboolKV[JeuRgt]{Creation}{%
    \xdef\ListeDesChoix{}%
    \ifboolKV[JeuRgt]{Negatif}{%
      \xdef\ListeDesChoix{-1}%
      \xintFor* ##1 in{\xintSeq{\useKV[JeuRgt]{ValeurMin}}{\useKV[JeuRgt]{ValeurMax}}}\do{%
        \xdef\ListeDesChoix{\ListeDesChoix,-##1}%
      }%
      \xintFor* ##1 in{\xintSeq{\useKV[JeuRgt]{ValeurMin}}{\useKV[JeuRgt]{ValeurMax}}}\do{%
        \xdef\ListeDesChoix{\ListeDesChoix,##1}%
      }%
    }{%
      \xintFor* ##1 in{\xintSeq{\useKV[JeuRgt]{ValeurMin}}{\useKV[JeuRgt]{ValeurMax}}}\do{%
        \xdef\ListeDesChoix{\ListeDesChoix,##1}%
      }%
    }%
    \MelangeListe{\ListeDesChoix}{\LongueurMot}%
    % Liste des nombres \faa et maintenant rangée
    \Rangement[Seul]{\faa}% \PfCListeRgtRecup
    \setsepchar{,}%
    % Liste des nombres
    % \readlist*\ListeDesNombres{\PfCListeRgtRecup}
    \readlist*\ListeDesNombres{\PfCRetiensRangement}
  }{%
    \setsepchar{,}%
    % Liste des nombres
    \readlist*\ListeDesNombres{#3}
  }%
  % \\La liste des nombres est \showitems\ListeDesNombres[]
  % On crée la liste des compteurs mélangés
  \xdef\PfCFooListe{}%
  \xintFor* ##1 in{\xintSeq{1}{\LongueurMot}}\do{%
    \xdef\PfCFooListe{\PfCFooListe ##1,}
  }%
  % On mélange la liste des compteurs
  \MelangeListe{\PfCFooListe}{\LongueurMot}
  % On obtient la liste demandée
  \setsepchar{,}\ignoreemptyitems%
  \readlist*\ListeCompteursMelanges{\faa}
  \reademptyitems
  % \\La liste des compteurs mélangés est \showitems\ListeCompteursMelanges[]
  % Les associations
  % \foreachitem\Lettre\in\ListeCompteursMelanges{%
  % \xdef\Compteur{\ListeCompteursMelanges[\Lettrecnt]}
  % \ListeDesLettres[\Compteur] -- \ListeDesNombres[\Compteur]\\
  % }%
  \begin{center}
    \begin{NiceTabular}{*{\LongueurMot}{m{\useKV[JeuRgt]{Largeur}}}}[vlines]%
      \hline
      \rule{0pt}{\PfCJeuRgtH}\xintFor* ##1 in{\xintSeq{1}{\LongueurMot}}\do{%
      \xintifForFirst{}{&}\Block{}{\xdef\Compteur{\ListeCompteursMelanges[##1]}\ListeDesLettres[\Compteur]}%
    }%
    \\
    \hline
    \rule{0pt}{\PfCJeuRgtH}\xintFor* ##1 in{\xintSeq{1}{\LongueurMot}}\do{%
      \xintifForFirst{}{&}\Block{}{%
        \xdef\Compteur{\ListeCompteursMelanges[##1]}%
        \ifboolKV[JeuRgt]{Creation}{%
          \ifboolKV[JeuRgt]{Decimaux}{\num{\fpeval{\ListeDesNombres[\Compteur]/\useKV[JeuRgt]{Deno}}}}{\Simplification{\ListeDesNombres[\Compteur]}{\useKV[JeuRgt]{Deno}}}}{%
          \ListeDesNombres[\Compteur]%
        }%
      }
    }%
    \\
    \ifboolKV[JeuRgt]{Solution}{%
      \hline
      \rule{0pt}{\PfCJeuRgtH}\xintFor* ##1 in{\xintSeq{1}{\LongueurMot}}\do{%
        \xintifForFirst{}{&}\Block{}{\ListeDesLettres[##1]}%
      }%
      \\
      \hline
      \rule{0pt}{\PfCJeuRgtH}\xintFor* ##1 in{\xintSeq{1}{\LongueurMot}}\do{%
        \xintifForFirst{}{&}\Block{}{%
          \ifboolKV[JeuRgt]{Creation}{%
            \ifboolKV[JeuRgt]{Decimaux}{\num{\fpeval{\ListeDesNombres[##1]/\useKV[JeuRgt]{Deno}}}}{\Simplification{\ListeDesNombres[##1]}{\useKV[JeuRgt]{Deno}}}}{%
            \ListeDesNombres[##1]%
          }%
        }%
      }%
      \\
    }{}%
    \hline
  \end{NiceTabular}
\end{center}
}