diff options
author | Norbert Preining <norbert@preining.info> | 2022-10-13 03:01:48 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-10-13 03:01:48 +0000 |
commit | ba720f8eaac74c537fb16f8556e4cf0ab4cd8235 (patch) | |
tree | e6932ca49174877c4ef511fd5c01d614b988b449 /macros/latex/contrib/profcollege/latex/ProfCollege.sty | |
parent | b9fbd9245255da7a36ca3b07890c471c708f7777 (diff) |
CTAN sync 202210130301
Diffstat (limited to 'macros/latex/contrib/profcollege/latex/ProfCollege.sty')
-rw-r--r-- | macros/latex/contrib/profcollege/latex/ProfCollege.sty | 1960 |
1 files changed, 1856 insertions, 104 deletions
diff --git a/macros/latex/contrib/profcollege/latex/ProfCollege.sty b/macros/latex/contrib/profcollege/latex/ProfCollege.sty index 8f8525a804..d45f25b5ce 100644 --- a/macros/latex/contrib/profcollege/latex/ProfCollege.sty +++ b/macros/latex/contrib/profcollege/latex/ProfCollege.sty @@ -2,9 +2,9 @@ % licence : Released under the LaTeX Project Public License v1.3c % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e}% -\def\filedate{2022/09/10}% +\def\filedate{2022/10/12}% \let\PfCfiledate\filedate% -\def\fileversion{0.99-z}% +\def\fileversion{0.99-z-a}% \let\PfCfileversion\fileversion% \ProvidesPackage{ProfCollege}[\filedate\space v\fileversion\space Aide pour utiliser LaTeX au college] @@ -347,10 +347,971 @@ } %%% +% Codage RLE +%%% +\setKVdefault[RLE]{Largeur=10pt,Taille=5,Unite=1cm,Solution=false,Enonce=true} + +\newtoks\toklisterle +\def\UpdatetoksRLE#1\nil{\addtotok\toklisterle{#1,}}% + +%\newlength\PfCRLEHeight% +\NewDocumentCommand\CodageRLE{o m}{% + \useKVdefault[RLE]% + \setKV[RLE]{#1}% + %\setlength{\PfCRLEHeight}{\useKV[RLE]{Largeur}}% + \setsepchar{,}% + \readlist*\PfCListeRLE{#2}% + \toklisterle{}% + \foreachitem\compteur\in\PfCListeRLE{\expandafter\UpdatetoksRLE\compteur\nil}% + \BuildRLE{\the\toklisterle}% +} + +\NewDocumentCommand\BuildRLE{m}{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + Taille:=\useKV[RLE]{Taille}; + u:=\useKV[RLE]{Unite}; + boolean Solution,Enonce; + Solution:=\useKV[RLE]{Solution}; + Enonce:=\useKV[RLE]{Enonce}; + + color RLEFill; + RLEFill=white; + + numeric nbretenir[][]; + + vardef NombreLigne(text t)= + retiens:=0; + nblignes:=0; + for p_=t: + retiens:=retiens+p_; + if retiens=Taille: + nblignes:=nblignes+1; + retiens:=0; + fi; + endfor; + enddef; + + path Square; + Square=unitsquare scaled u; + + vardef RLE(text t)= + nbcoups:=0; + nbcases:=0; + nbcaseslignes:=0; + cptretiensnb:=0; + cptretiensnblignes:=1; + for p_=t: + if p_=0: + cptretiensnb:=cptretiensnb+1; + nbretenir[cptretiensnblignes][cptretiensnb]=p_; + RLEFill:=black; + else: + nbcoups:=nbcoups+1; + for l=0 upto p_-1: + if Solution: fill ((Square scaled 0.95) shifted(u*((nbcases mod Taille)+l,-(nbcases div Taille))+u*(0.025,0.025))) withcolor RLEFill; fi; + trace (Square shifted(u*((nbcases mod Taille)+l,-(nbcases div Taille)))); + endfor; + nbcaseslignes:=nbcaseslignes+p_; + nbcases:=nbcases+p_; + if (nbcaseslignes mod Taille)=0: + RLEFill:=white; + cptretiensnb:=cptretiensnb+1; + nbretenir[cptretiensnblignes][cptretiensnb]=p_; + cptretiensnblignes:=cptretiensnblignes+1; + cptretiensnb:=0; + else: + if RLEFill=white: RLEFill:=black else: RLEFill:=white fi; + cptretiensnb:=cptretiensnb+1; + nbretenir[cptretiensnblignes][cptretiensnb]=p_; + fi; + fi; + endfor; + enddef; + + string Sequence[]; + + boolean STOP; + STOP:=false; + + vardef Affichage= + for k=1 upto nblignes: + Sequence[k]=decimal(nbretenir[k][1]); + n:=1; + forever: + n:=n+1; + if unknown nbretenir[k][n]: + STOP:=true; + else: + Sequence[k]:=Sequence[k]&","&decimal(nbretenir[k][n]); + fi; + exitif STOP; + endfor; + label.rt(TEX(Sequence[k]),u*(Taille+1,-k+1+0.5)); + STOP:=false; + endfor; + enddef; + + NombreLigne(#1); + RLE(#1); + if Enonce: + Affichage; + fi; + \end{mplibcode} + \else + \begin{mpost}[mpsettings={% + Taille:=\useKV[RLE]{Taille}; + u:=\useKV[RLE]{Unite}; + boolean Solution,Enonce; + Solution:=\useKV[RLE]{Solution}; + Enonce:=\useKV[RLE]{Enonce}; + }] + color RLEFill; + RLEFill=white; + + numeric nbretenir[][]; + + vardef NombreLigne(text t)= + retiens:=0; + nblignes:=0; + for p_=t: + retiens:=retiens+p_; + if retiens=Taille: + nblignes:=nblignes+1; + retiens:=0; + fi; + endfor; + enddef; + + path Square; + Square=unitsquare scaled u; + + vardef RLE(text t)= + nbcoups:=0; + nbcases:=0; + nbcaseslignes:=0; + cptretiensnb:=0; + cptretiensnblignes:=1; + for p_=t: + if p_=0: + cptretiensnb:=cptretiensnb+1; + nbretenir[cptretiensnblignes][cptretiensnb]=p_; + RLEFill:=black; + else: + nbcoups:=nbcoups+1; + for l=0 upto p_-1: + if Solution: fill ((Square scaled 0.95) shifted(u*((nbcases mod Taille)+l,-(nbcases div Taille))+u*(0.025,0.025))) withcolor RLEFill; fi; + trace (Square shifted(u*((nbcases mod Taille)+l,-(nbcases div Taille)))); + endfor; + nbcaseslignes:=nbcaseslignes+p_; + nbcases:=nbcases+p_; + if (nbcaseslignes mod Taille)=0: + RLEFill:=white; + cptretiensnb:=cptretiensnb+1; + nbretenir[cptretiensnblignes][cptretiensnb]=p_; + cptretiensnblignes:=cptretiensnblignes+1; + cptretiensnb:=0; + else: + if RLEFill=white: RLEFill:=black else: RLEFill:=white fi; + cptretiensnb:=cptretiensnb+1; + nbretenir[cptretiensnblignes][cptretiensnb]=p_; + fi; + fi; + endfor; + enddef; + + string Sequence[]; + + boolean STOP; + STOP:=false; + + vardef Affichage= + for k=1 upto nblignes: + Sequence[k]=decimal(nbretenir[k][1]); + n:=1; + forever: + n:=n+1; + if unknown nbretenir[k][n]: + STOP:=true; + else: + Sequence[k]:=Sequence[k]&","&decimal(nbretenir[k][n]); + fi; + exitif STOP; + endfor; + label.rt(LATEX(Sequence[k]),u*(Taille+1,-k+1+0.5)); + STOP:=false; + endfor; + enddef; + + NombreLigne(#1); + RLE(#1); + if Enonce: + Affichage; + fi; + \end{mpost} + \fi +} + +%%% +% Engrenages +%%% +\newtoks\tokPfCEngrenages% +\def\UpdatetoksEngrenages#1/#2\nil{\addtotok\tokPfCEngrenages{#1,#2,}}% + +\setKVdefault[Engrenages]{Couleur=LightSteelBlue,Unite=3mm} + +\NewDocumentCommand\Engrenages{o m}{% + \tokPfCEngrenages{} + \useKVdefault[Engrenages]% + \setKV[Engrenages]{#1}% + \setsepchar[*]{,*/}% + \ignoreemptyitems + \readlist*\ListePfCEngrenages{#2}% + \foreachitem\compteur\in\ListePfCEngrenages{\expandafter\UpdatetoksEngrenages\compteur\nil}% + \BuildEngrenages{\the\tokPfCEngrenages}% +}% + +\NewDocumentCommand\BuildEngrenages{m}{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + input PfCEngrenages; + + u:=\useKV[Engrenages]{Unite}; + CouleurEngrenage=\useKV[Engrenages]{Couleur}; + + vardef LectureDonnees(text t)= + n:=0;k=0;l=0; + for p_=t: + n:=n+1; + if (n mod 2)=0: + l:=l+1; + Zz[l]=p_; + else: + k:=k+1; + Mm[k]=p_; + fi; + endfor; + enddef; + + LectureDonnees(#1); + + pair K; + K=(0,0); + + trace Engrenage(Mm[1],Zz[1],(0,0)); + for w=2 upto (n div 2): + K:=K+pointarc(cercles((0,0),u*Mm[w]*(Zz[w-1]+Zz[w])*0.5+0.04*u),0); + AngleRot:=360/(2*Zz[w]); + trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot); + endfor; + \end{mplibcode} + \else + \begin{mpost}[mpsettings={input PfCEngrenages;u:=\useKV[Engrenages]{Unite};CouleurEngrenage=\useKV[Engrenages]{Couleur};}] + vardef LectureDonnees(text t)= + n:=0;k=0;l=0; + for p_=t: + n:=n+1; + if (n mod 2)=0: + l:=l+1; + Zz[l]=p_; + else: + k:=k+1; + Mm[k]=p_; + fi; + endfor; + enddef; + + LectureDonnees(#1); + + pair K; + K=(0,0); + + trace Engrenage(Mm[1],Zz[1],(0,0)); + for w=2 upto (n div 2): + K:=K+pointarc(cercles((0,0),u*Mm[w]*(Zz[w-1]+Zz[w])*0.5+0.04*u),0); + AngleRot:=360/(2*Zz[w]); + trace rotation(Engrenage(Mm[w],Zz[w],K),K,180-AngleRot); + endfor; + \end{mpost} + \fi +}% + +%%% +% Tortue +%%% +\setKVdefault[Tortue]{Pas=0.2mm,Etapes=false,Nom=\jobname,Grille=false,LargeurG=10,HauteurG=10,TortueD=false,TortueF=false,Epaisseur=1,Angle=0,Debut=false,Depart={(0,0)},Axes=false} +\defKV[Tortue]{Etape=\setKV[Tortue]{Etapes}}% + +\newcounter{PfCTortue} +\setcounter{PfCTortue}{0} + +\makeatletter +\NewDocumentCommand\TortueCreationFichier{o m}{% + \stepcounter{PfCTortue}% + \useKVdefault[Tortue]% + \setKV[Tortue]{#1}% + \setKV[Tortue]{Nom=\jobname+t\thePfCTortue}% + \setsepchar[*]{,* }% + \readlist*\PfCListeCmdTortue{#2}% + \setsepchar{,}% + \xdef\PfCNbRep{0}% + \savecomparemode% + \newwrite\turtle@out% + \immediate\openout\turtle@out \jobname+t\thePfCTortue.turtle% + \immediate\write\turtle@out{numeric ut;}% + \immediate\write\turtle@out{ut=\useKV[Tortue]{Pas};}% + \immediate\write\turtle@out{Etapes=\useKV[Tortue]{Etapes};}% + \immediate\write\turtle@out{if Etapes:Total=\useKV[Tortue]{Etape};fi;}% +% \immediate\write\turtle@out{vardef Dessin=}% +% \immediate\write\turtle@out{save Tortue; picture Tortue;}% + \ifboolKV[Tortue]{Grille}{% + \immediate\write\turtle@out{% + larg=\useKV[Tortue]{LargeurG}; haut=\useKV[Tortue]{HauteurG}; + for k=-larg upto larg: + draw 3*ut*(10k,-10haut)--3*ut*(10k,10haut) withcolor 0.75white; + endfor; + for k=-haut upto haut: + draw 3*ut*(-10larg,10k)--3*ut*(10larg,10k) withcolor 0.75white; + endfor; + if \useKV[Tortue]{Axes}: + drawarrow 3*ut*(-10larg,0)--3*ut*(10larg,0); + drawarrow 3*ut*(0,-10haut)--3*ut*(0,10haut); + label.llft(btex O etex,(0,0)); + dotlabel.lrt(btex 30 etex,(30*ut,0)); + dotlabel.ulft(btex 30 etex,(0,30*ut)); + fi; + }% + }{}% + \ifboolKV[Tortue]{Debut}{}{% + \foreachitem\compteur\in\PfCListeCmdTortue{% + \comparestrict% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{[}[\PfCTestCrochetO]% + \xintifboolexpr{\PfCTestCrochetO==0}{}{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{]}[\PfCTestCrochetF]% + \xintifboolexpr{\PfCTestCrochetF==0}{% + \immediate\write\turtle@out{TotalRemplis:=tt-1; remplis for l=1 upto TotalRemplis:B[l]--endfor cycle withcolor CouleurRemplis;}% + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{Remplis}[\PfCTestRemplis]% + \xintifboolexpr{\PfCTestRemplis==0}{% + \immediate\write\turtle@out{tt:=0; + TotalRemplis:=0; CouleurRemplis:=\PfCListeCmdTortue[\compteurcnt,2];}% + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{Fin}[\PfCTestFinPour]% + \xintifboolexpr{\PfCTestFinPour==0}{% + \immediate\write\turtle@out{enddef;k:=0;}% + \xdef\PfCNbRep{\fpeval{\PfCNbRep+1}}% + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{Pour}[\PfCTestPour]% + \xintifboolexpr{\PfCTestPour==0}{% + \immediate\write\turtle@out{vardef \PfCListeCmdTortue[\compteurcnt,2](expr \PfCListeCmdTortue[\compteurcnt,3])=}% + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{Rep}[\PfCTestRep]% + \xintifboolexpr{\PfCTestRep==0}{% + \xdef\PfCNbRep{\fpeval{\PfCNbRep+1}}% + \immediate\write\turtle@out{nb[\PfCNbRep]:=0;}% + \immediate\write\turtle@out{forever:}% + \immediate\write\turtle@out{nb[\PfCNbRep]:=nb[\PfCNbRep]+1;}% + % \immediate\write\turtle@out{nbcomp:=nbcomp+1;} + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{)}[\PfCTestParaF]% + \xintifboolexpr{\PfCTestParaF==0}{% + \immediate\write\turtle@out{exitif nb[\PfCNbRep]=\PfCListeCmdTortue[\compteurcnt,2];}% + \immediate\write\turtle@out{endfor;}% + \xdef\PfCNbRep{\fpeval{\PfCNbRep-1}}% + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{(}[\PfCTestParaO]% + \xintifboolexpr{\PfCTestParaO==0}{% + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{Bc}[\PfCTestBc]% + \xintifboolexpr{\PfCTestBc==0}{% + \immediate\write\turtle@out{Bc;}% + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{Lc}[\PfCTestLc]% + \xintifboolexpr{\PfCTestLc==0}{% + \immediate\write\turtle@out{Lc;}% + }{% + \StrCompare{\PfCListeCmdTortue[\compteurcnt,1]}{Tlp}[\PfCTestTlp]% + \xintifboolexpr{\PfCTestTlp==0}{% + \immediate\write\turtle@out{Teleporter(\PfCListeCmdTortue[\compteurcnt,2],\PfCListeCmdTortue[\compteurcnt,3]);}% + }{% + \immediate\write\turtle@out{\PfCListeCmdTortue[\compteurcnt,1](\PfCListeCmdTortue[\compteurcnt,2]);}% + }% + }% + }% + }% + }% + }% + }% + }% + }% + }% + }% + }% + }% + % \immediate\write\turtle@out{Tortue:=currentpicture;Tortue enddef;}% + % \immediate\write\turtle@out{draw Dessin;}% + \ifboolKV[Tortue]{TortueD}{% + \immediate\write\turtle@out{drawoptions(withcolor DarkGreen);label(btex \noexpand\Large\noexpand\ding{40} etex rotated RetiensAngle[0] scaled 1.5,A[0]);}% + }{}% + \ifboolKV[Tortue]{Etapes}{% + \immediate\write\turtle@out{drawoptions(withcolor DarkGreen);label(btex \noexpand\Large\noexpand\ding{40} etex rotated RetiensAngle[Total] scaled 1.5,A[Total]);}% + }{\ifboolKV[Tortue]{TortueF}{\immediate\write\turtle@out{drawoptions(withcolor DarkGreen);label(btex \noexpand\Large\noexpand\ding{40} etex rotated RetiensAngle[k] scaled 1.5,A[k]);}}{}}% + %\immediate\write\turtle@out{} + \immediate\closeout\turtle@out% + \restorecomparemode% +}% +\makeatother + +\NewDocumentCommand\Tortue{o m}{% + \useKVdefault[Tortue]% + \setKV[Tortue]{#1}% + \TortueCreationFichier[#1]{#2}% + \TortueDessinFinal% +} + +\NewDocumentCommand\TortueDessinFinal{}{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + input PfCTurtleTestRemplis.mp; + + pair Depart; + Depart=\useKV[Tortue]{Depart}; + pair A[],B[]; + A[0]=\useKV[Tortue]{Pas}*(xpart(Depart),ypart(Depart)); + B[0]=A[0]; + Epaisseur:=0.25;%\useKV[Tortue]{Epaisseur}; + Angle:=0; + numeric RetiensAngle[]; + RetiensAngle[0]=\useKV[Tortue]{Angle}; + + pair VecteurDpt; + VecteurDpt=(1,0) rotated RetiensAngle[0]; + input \useKV[Tortue]{Nom}.turtle; + \end{mplibcode} + \else + \fi +}% + +%%% +% Le compte est bon +%%% +\setKVdefault[CompteBon]{NombreCalculs=5,NombrePlaques=4,Solution=false,Relatifs=false,Original=false,Graines=false,Plaques=6} +\defKV[CompteBon]{Graine=\setKV[CompteBon]{Graines}}% + +\makeatletter + +\newcommand\PfC@CreerListeCalculs[4]{% + \xdef\PfC@ListeCalculs{% + #1+#2+#3+#4,% + #1+#2+#3*#4/#1+#3*#4+#2/#3*#4+#1+#2,% + #1+#3+#2*#4/#1+#2*#4+#3/#2*#4+#1+#3,% + #1+#4+#2*#3/#1+#2*#3+#4/#2*#3+#1+#4,% + #2+#3+#1*#4/#2+#1*#4+#3/#1*#4+#2+#3,% + #2+#4+#1*#3/#2+#1*#3+#4/#2+#4+#1*#3,% + #3+#4+#1*#2/#3+#1*#2+#4/#3+#4+#1*#2,% + #1*#2+#3*#4/#3*#4+#1*#2,% + #1*#3+#2*#4/#2*#4+#1*#3,% + #1*#4+#2*#3/#2*#3+#1*#4,% + #1*#2*#3+#4/#4+#1*#2*#3, + #1*#2*#4+#3/#3+#1*#2*#4,% + #1*#3*#4+#2/#2+#1*#3*#4,% + #2*#3*#4+#1/#1+#2*#3*#4,% + #1*#2*#3*#4,% + #1+(#2+#3)*#4/(#2+#3)*#4+#1/#1+#4*(#2+#3)/#4*(#2+#3)+#1,% + #1+(#2+#4)*#3/(#2+#4)*#3+#1/#1+#3*(#2+#4)/#3*(#2+#4)+#1,% + #1+(#3+#4)*#2/(#3+#4)*#2+#1/#1+#2*(#3+#4)/#2*(#3+#4)+#1,% + #2+(#1+#3)*#4,% + #2+(#1+#4)*#3,% + #2+(#3+#4)*#1,% + #3+(#1+#2)*#4,% + #3+(#1+#4)*#2,% + #3+(#2+#4)*#1,% + #4+(#1+#2)*#3,% + #4+(#1+#3)*#2,% + #4+(#2+#3)*#1,% + (#1+#2+#3)*#4,% + (#1+#2+#4)*#3,% + (#1+#3+#4)*#2,% + (#2+#3+#4)*#1,% + (#1+#2)*(#3+#4),% + (#1+#3)*(#2+#4),% + (#1+#4)*(#2+#3)% + }% + \ifboolKV[CompteBon]{Relatifs}{% + \xdef\PfC@ListeCalculs{% + \PfC@ListeCalculs,% + #1-#2-#3-#4,% + #1-#2-#3*#4/#1-#3*#4-#2/#3*#4-#1-#2,% + #1-#3-#2*#4/#1-#2*#4-#3/#2*#4-#1-#3,% + #1-#4-#2*#3/#1-#2*#3-#4/#2*#3-#1-#4,% + #2-#3-#1*#4/#2-#1*#4-#3/#1*#4-#2-#3,% + #2-#4-#1*#3/#2-#1*#3-#4/#2-#4-#1*#3,% + #3-#4-#1*#2/#3-#1*#2-#4/#3-#4-#1*#2,% + #1*#2-#3*#4/#3*#4-#1*#2,% + #1*#3-#2*#4/#2*#4-#1*#3,% + #1*#4-#2*#3/#2*#3-#1*#4,% + #1*#2*#3-#4/#4-#1*#2*#3, + #1*#2*#4-#3/#3-#1*#2*#4,% + #1*#3*#4-#2/#2-#1*#3*#4,% + #2*#3*#4-#1/#1-#2*#3*#4,% + #1*#2*#3*#4,% + #1-(#2-#3)*#4/(#2-#3)*#4-#1/#1-#4*(#2-#3)/#4*(#2-#3)-#1,% + #1-(#2-#4)*#3/(#2-#4)*#3-#1/#1-#3*(#2-#4)/#3*(#2-#4)-#1,% + #1-(#3-#4)*#2/(#3-#4)*#2-#1/#1-#2*(#3-#4)/#2*(#3-#4)-#1,% + #2-(#1-#3)*#4,% + #2-(#1-#4)*#3,% + #2-(#3-#4)*#1,% + #3-(#1-#2)*#4,% + #3-(#1-#4)*#2,% + #3-(#2-#4)*#1,% + #4-(#1-#2)*#3,% + #4-(#1-#3)*#2,% + #4-(#2-#3)*#1,% + (#1-#2-#3)*#4,% + (#1-#2-#4)*#3,% + (#1-#3-#4)*#2,% + (#2-#3-#4)*#1,% + (#1-#2)*(#3-#4),% + (#1-#3)*(#2-#4),% + (#1-#4)*(#2-#3)% + }% + }{}% +}% + +\newtoks\tokPfCCBRappels +\def\UpdatetoksCB#1\nil{\addtotok\tokPfCCBRappels{#1,}}% + +\NewDocumentCommand\PfCCompteBonOriginal{o}{% + \useKVdefault[CompteBon] + \setKV[CompteBon]{#1}% + %On définit la liste des cartes + \xdef\PfCCBListeCartes{1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,25,50,75,100}% + \MelangeListe{\PfCCBListeCartes}{\useKV[CompteBon]{Plaques}} + \readlist*\PfCCBListeTirage{\faa} + \MelangeListe{\faa}{\useKV[CompteBon]{Plaques}} + \readlist*\PfCCBListeTirageAffiche{\faa} + %%Tirage ok + \xdef\PfCCBResultatFinal{1001}% + \whiledo{\PfCCBResultatFinal>1000}{% + \xdef\PfCListeATrier{\PfCCBListeTirage[1]}% + \xintFor* ##1 in{\xintSeq{2}{\useKV[CompteBon]{Plaques}}}\do{% + \xdef\PfCListeATrier{\PfCListeATrier,\PfCCBListeTirage[##1]}% + }% + % + \tokPfCCBRappels{}% + \xintFor* ##1 in{\xintSeq{1}{\fpeval{\useKV[CompteBon]{Plaques}-1}}}\do{% + \MelangeListe{\PfCListeATrier}{2} + \readlist*\PfCCBListeTirageIntermediaire{\faa} + \xintifboolexpr{\PfCCBListeTirageIntermediaire[1]==1 || \PfCCBListeTirageIntermediaire[2]==1}{% + % On ne fait pas de multiplication par 1 + \xdef\PfCCBAlea{\fpeval{randint(1,2)}}% + \xintifboolexpr{\PfCCBAlea==1}{% + \xdef\PfCCBTest{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]=\fpeval{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]}}% + \expandafter\UpdatetoksCB\PfCCBTest\nil% + \xdef\PfCCBResultat{\fpeval{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]}} + \xintifboolexpr{\PfCCBResultat>10000}{\xintBreakFor\xdef\PfCCBResultat{10000}}{}% + }{% + \xintifboolexpr{\PfCCBListeTirageIntermediaire[1]==\PfCCBListeTirageIntermediaire[2]}{% + \xdef\PfCCBTest{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]=\fpeval{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]}}% + \expandafter\UpdatetoksCB\PfCCBTest\nil% + \xdef\PfCCBResultat{\fpeval{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]}} + }{% + \xdef\PfCCBTest{\fpeval{max(\PfCCBListeTirageIntermediaire[1],\PfCCBListeTirageIntermediaire[2])}-\fpeval{min(\PfCCBListeTirageIntermediaire[1],\PfCCBListeTirageIntermediaire[2])}=\fpeval{max(\PfCCBListeTirageIntermediaire[1],\PfCCBListeTirageIntermediaire[2])-min(\PfCCBListeTirageIntermediaire[1],\PfCCBListeTirageIntermediaire[2])}} + \expandafter\UpdatetoksCB\PfCCBTest\nil% + \xdef\PfCCBResultat{\fpeval{abs(\PfCCBListeTirageIntermediaire[1]-\PfCCBListeTirageIntermediaire[2])}} + }% + \xintifboolexpr{\PfCCBResultat>10000}{\xintBreakFor\xdef\PfCCBResultat{10000}}{}% + }% + \xdef\PfCListeATrier{\fii,\PfCCBResultat}% + }{% + \xdef\PfCCBAlea{\fpeval{randint(1,3)}}% + \xintifboolexpr{\PfCCBAlea==1}{% + \xdef\PfCCBTest{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]=\fpeval{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]}}% + \expandafter\UpdatetoksCB\PfCCBTest\nil% + \xdef\PfCCBResultat{\fpeval{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]}} + \xintifboolexpr{\PfCCBResultat>10000}{\xintBreakFor\xdef\PfCCBResultat{10000}}{}% + }{% + \xintifboolexpr{\PfCCBAlea==2}{% + \xintifboolexpr{\PfCCBListeTirageIntermediaire[1]==\PfCCBListeTirageIntermediaire[2]}{% + \xdef\PfCCBTest{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]=\fpeval{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]}}% + \expandafter\UpdatetoksCB\PfCCBTest\nil% + \xdef\PfCCBResultat{\fpeval{\PfCCBListeTirageIntermediaire[1]+\PfCCBListeTirageIntermediaire[2]}} + }{% + \xdef\PfCCBTest{\fpeval{max(\PfCCBListeTirageIntermediaire[1],\PfCCBListeTirageIntermediaire[2])}-\fpeval{min(\PfCCBListeTirageIntermediaire[1],\PfCCBListeTirageIntermediaire[2])}=\fpeval{max(\PfCCBListeTirageIntermediaire[1],\PfCCBListeTirageIntermediaire[2])-min(\PfCCBListeTirageIntermediaire[1],\PfCCBListeTirageIntermediaire[2])}} + \expandafter\UpdatetoksCB\PfCCBTest\nil% + \xdef\PfCCBResultat{\fpeval{abs(\PfCCBListeTirageIntermediaire[1]-\PfCCBListeTirageIntermediaire[2])}} + }% + \xintifboolexpr{\PfCCBResultat>10000}{\xintBreakFor\xdef\PfCCBResultat{10000}}{}% + }{% + \xdef\PfCCBTest{\PfCCBListeTirageIntermediaire[1]*\PfCCBListeTirageIntermediaire[2]=\fpeval{\PfCCBListeTirageIntermediaire[1]*\PfCCBListeTirageIntermediaire[2]}} + \expandafter\UpdatetoksCB\PfCCBTest\nil% + \xdef\PfCCBResultat{\fpeval{\PfCCBListeTirageIntermediaire[1]*\PfCCBListeTirageIntermediaire[2]}} + \xintifboolexpr{\PfCCBResultat>10000}{\xintBreakFor\xdef\PfCCBResultat{10000}}{}% + } + }% + \xdef\PfCListeATrier{\fii,\PfCCBResultat}% + }% + }% + \xintifboolexpr{\useKV[CompteBon]{Plaques}>5}{\xintifboolexpr{\PfCCBResultat<100}{\xdef\PfCCBResultat{1001}}{}}{}% + \xdef\PfCCBResultatFinal{\PfCCBResultat}% + }% + \begin{center} + \textbf{\PfCCBResultatFinal} + + \fbox{\PfCCBListeTirage[1]} \xintFor* ##1 in{\xintSeq{2}{\useKV[CompteBon]{Plaques}}}\do{\qquad \fbox{\PfCCBListeTirage[##1]}}% + \end{center} + \xdef\PfCCBListeRappels{\the\tokPfCCBRappels} + \setsepchar[*]{,*=}\ignoreemptyitems + \readlist*\PfCCBDecompositionEtapes{\PfCCBListeRappels} + \reademptyitems + \ifboolKV[CompteBon]{Solution}{% + \begin{align*} + \xintFor* ##1 in{\xintSeq{1}{\fpeval{\useKV[CompteBon]{Plaques}-1}}}\do{ + \StrSubstitute{\PfCCBDecompositionEtapes[##1,1]}{*}{\times}[\PfCCBAffiche]\PfCCBAffiche&=\PfCCBDecompositionEtapes[##1,2]\xintifForLast{\\}{} + } + \end{align*} + }{}% +}% + +\NewDocumentCommand\CompteBon{o}{% + \useKVdefault[CompteBon]% + \setKV[CompteBon]{#1}% + \ifboolKV[CompteBon]{Graines}{\PfCGraineAlea{\useKV[CompteBon]{Graine}}}{}% + \ifboolKV[CompteBon]{Original}{% + \PfCCompteBonOriginal[#1]% + }{% + % on choisit NombrePlaques parmi la liste des nombres 1 à 9, 10/25/50/75/100, La moitié +1 devant appartenir à 1..9 + \xdef\PfCCBListeEntiers{2,3,4,5,6,7,8,9}% + \xdef\PfCCBListeMultiples{10,25,50,75,100}% + \xdef\PfCCBNbPlaqueEntiers{\fpeval{floor(\useKV[CompteBon]{NombrePlaques}/2)+1}}% + \xdef\PfCCBNbPlaqueMultiples{\useKV[CompteBon]{NombrePlaques}-\PfCCBNbPlaqueEntiers}% + \MelangeListe{\PfCCBListeEntiers}{\PfCCBNbPlaqueEntiers}% + \setsepchar{,}% + \ignoreemptyitems% + \readlist*\PfCCBListeEntiersChoisis{\faa}% + \MelangeListe{\PfCCBListeMultiples}{\PfCCBNbPlaqueMultiples}% + \ignoreemptyitems% + \readlist*\PfCCBListeMultiplesChoisis{\faa}% + \reademptyitems% + \xdef\PfCCBListeToutesCartes{}% + \foreachitem\compteur\in\PfCCBListeEntiersChoisis{% + \xdef\PfCCBListeToutesCartes{\PfCCBListeToutesCartes{},\PfCCBListeEntiersChoisis[\compteurcnt]}% + }% + \foreachitem\compteur\in\PfCCBListeMultiplesChoisis{% + \xdef\PfCCBListeToutesCartes{\PfCCBListeToutesCartes{},\PfCCBListeMultiplesChoisis[\compteurcnt]}% + }% + \MelangeListe{\PfCCBListeToutesCartes}{4}% + \readlist*\PfCCBListeFinaleCartes{\faa}% + % Choix des calculs + \xdef\PfC@CalculUn{\PfCCBListeFinaleCartes[1]}% + \xdef\PfC@CalculDeux{\PfCCBListeFinaleCartes[2]}% + \xdef\PfC@CalculTrois{\PfCCBListeFinaleCartes[3]}% + \xdef\PfC@CalculQuatre{\PfCCBListeFinaleCartes[4]}% + \PfC@CreerListeCalculs{\PfC@CalculUn}{\PfC@CalculDeux}{\PfC@CalculTrois}{\PfC@CalculQuatre} + \MelangeListe{\PfC@ListeCalculs}{\useKV[CompteBon]{NombreCalculs}}% + \setsepchar[*]{,*/}% + \readlist*\PfC@ListeCalculsChoisis{\faa}% + \begin{center} + \setlength{\tabcolsep}{0.5\tabcolsep} + % Le tableau des nombres + \begin{NiceTabular}{m{20pt}m{10pt}m{20pt}m{10pt}m{20pt}m{10pt}m{20pt}} + \Block[draw]{}{\PfCCBListeFinaleCartes[1]}&&\Block[draw]{}{\PfCCBListeFinaleCartes[2]}&&\Block[draw]{}{\PfCCBListeFinaleCartes[3]}&&\Block[draw]{}{\PfCCBListeFinaleCartes[4]} + \end{NiceTabular} + + \bigskip + + % Le tableau des calculs% + \begin{NiceTabular}{m{30pt}cccm{20pt}m{10pt}m{20pt}m{10pt}m{20pt}m{10pt}m{20pt}} + \xintFor* ##1 in{\xintSeq{1}{\useKV[CompteBon]{NombreCalculs}}}\do{% + \Block[draw]{}{\num{\fpeval{\PfC@ListeCalculsChoisis[##1,1]}}}&&$=$&&\Block[draw]{}{~}&\Block{}{~}&\Block[draw]{}{~}&\Block{}{~}&\Block[draw]{}{~}&\Block{}{~}&\Block[draw]{}{~}\\ + \ifboolKV[CompteBon]{Solution}{\Block{1-11}{\footnotesize Une solution : \StrSubstitute[0]{\PfC@ListeCalculsChoisis[##1,1]}{*}{\times}[\PfCEcritureCalcul]$\PfCEcritureCalcul$}}{}\\ + }% + \end{NiceTabular} + \end{center} + }% +}% + +%%% +% Nombre Astral +%%% +\setKVdefault[NombreAstral]{Solution=false,Graines=false,Echelle=1} +\defKV[NombreAstral]{Graine=\setKV[NombreAstral]{Graines}}% + +\newtoks\toklisteNANombres% +\newtoks\toklisteNAMelange% +\def\UpdatetoksNANombres#1\nil{\addtotok\toklisteNANombres{"#1",}}% +\def\UpdatetoksNAMelange#1\nil{\addtotok\toklisteNAMelange{#1,}}% + +\NewDocumentCommand\NombreAstral{o}{% + \toklisteNANombres{}% + \toklisteNAMelange{}% + \useKVdefault[NombreAstral]% + \setKV[NombreAstral]{#1}% + \ifboolKV[NombreAstral]{Graines}{\PfCGraineAlea{\useKV[NombreAstral]{Graine}}}{}% + \xdef\PfCNACible{\fpeval{2*randint(25,45)}}% + \xdef\PfCNAListeNombres{}% + \xintFor* ##1 in{\xintSeq{11}{\fpeval{floor(\PfCNACible/3)}}}\do{% + \xdef\PfCNAListeNombres{\PfCNAListeNombres ##1,}% + }% + \MelangeListe{\PfCNAListeNombres}{5}% + \setsepchar{,}\ignoreemptyitems% + \readlist*\PfCNAListeNombresBase{\faa}% + \reademptyitems + \readlist*\PfCNAListeNombres{% + \PfCNAListeNombresBase[1],% + \PfCNAListeNombresBase[2],% + \fpeval{0.5*\PfCNACible+\PfCNAListeNombresBase[5]-\PfCNAListeNombresBase[4]-\PfCNAListeNombresBase[3]},% + \fpeval{0.5*\PfCNACible+\PfCNAListeNombresBase[4]-\PfCNAListeNombresBase[2]-\PfCNAListeNombresBase[5]},% + \PfCNAListeNombresBase[3],% + \fpeval{0.5*\PfCNACible+\PfCNAListeNombresBase[3]-\PfCNAListeNombresBase[5]-\PfCNAListeNombresBase[1]},% + \fpeval{0.5*\PfCNACible+\PfCNAListeNombresBase[2]-\PfCNAListeNombresBase[4]-\PfCNAListeNombresBase[1]},% + \fpeval{0.5*\PfCNACible+\PfCNAListeNombresBase[1]-\PfCNAListeNombresBase[2]-\PfCNAListeNombresBase[3]},% + \PfCNAListeNombresBase[4],% + \PfCNAListeNombresBase[5]% + }% + \foreachitem\compteur\in\PfCNAListeNombres{\expandafter\UpdatetoksNANombres\compteur\nil}% + \xdef\PfCNAListeAEffacer{1,2,3,4,5,6,7,8,9,10}% + \MelangeListe{\PfCNAListeAEffacer}{6}% + \ignoreemptyitems% + \readlist*\PfCNAListeMelange{\faa}% + \reademptyitems% + \foreachitem\compteur\in\PfCNAListeMelange{\expandafter\UpdatetoksNAMelange\compteur\nil}% + \BuildNombreAstral{\the\toklisteNANombres}{\the\toklisteNAMelange}% +}% + +\NewDocumentCommand\BuildNombreAstral{m m}{% + \ifluatex + \mplibforcehmode + \begin{mplibcode} + Cible=\PfCNACible; + + boolean Solution; + Solution:=\useKV[NombreAstral]{Solution}; + + Echelle:=\useKV[NombreAstral]{Echelle}; + + string Rappel[]; + Rayon:=4cm; + + path cc,ca[]; + cc=cercles((0,0),Rayon); + + pair A[],C[],D[]; + for k=1 upto 5: + C[k]=pointarc(cc,90+(k-1)*72); + endfor; + + D1=C2+30*unitvector(C2-C4); + D2=C2+30*unitvector(C2-C5); + D3=C3+30*unitvector(C3-C1); + D4=C4+30*unitvector(C4-C1); + D5=C5+30*unitvector(C5-C3); + + drawarrow C2--D1; + drawarrow C2--D2; + drawarrow C3--D3; + drawarrow C4--D4; + drawarrow C5--D5; + + label.ulft(TEX("\bfseries\Large"&decimal(Cible)),D1); + label.lft(TEX("\bfseries\Large"&decimal(Cible)),D2); + label.llft(TEX("\bfseries\Large"&decimal(Cible)),D3); + label.lrt(TEX("\bfseries\Large"&decimal(Cible)),D4); + label.urt(TEX("\bfseries\Large"&decimal(Cible)),D5); + + trace polygone(C1,C3,C5,C2,C4) withpen (pencircle scaled 8); + A1=C1; + A2=C2; + A9=C3; + A10=C4; + A5=C5; + A3=segment(C1,C3) intersectionpoint segment(C2,C5); + A4=segment(C1,C4) intersectionpoint segment(C2,C5); + A6=segment(C1,C3) intersectionpoint segment(C2,C4); + A7=segment(C1,C4) intersectionpoint segment(C3,C5); + A8=segment(C2,C4) intersectionpoint segment(C3,C5); + for k=1 upto 10: + ca[k]=cercles(A[k],0.6u); + fill ca[k] withcolor white; + trace ca[k]; + endfor; + vardef Affichage(text t)= + n:=0; + for p_=t: + n:=n+1; + Rappel[n]=p_; + label(TEX("\Large"&p_),A[n]); + endfor; + enddef; + + vardef Suppression(text t)= + k:=0; + for p_=t: + k:=k+1; + fill ca[p_] withcolor white; + trace ca[p_]; + label(TEX("\Large"&Rappel[p_]),u*(-7,5.6-1.5k)); + trace cercles(u*(-7,5.6-1.5k),0.6u); + endfor; + enddef; + + Affichage(#1); + if Solution=false: + Suppression(#2); + fi; + picture recap;% + recap:=currentpicture scaled Echelle;% + currentpicture:=nullpicture;% + draw recap;% + \end{mplibcode} + \else + \begin{mpost}[mpsettings={% + Echelle:=\useKV[NombreAstral]{Echelle}; + Cible=\PfCNACible;boolean Solution;Solution:=\useKV[NombreAstral]{Solution}; + string Rappel[]; + n:=0; + for p_=#1: + n:=n+1; + Rappel[n]=p_; + endfor; + }] + + Rayon:=4cm; + + path cc,ca[]; + cc=cercles((0,0),Rayon); + + pair A[],C[],D[]; + for k=1 upto 5: + C[k]=pointarc(cc,90+(k-1)*72); + endfor; + + D1=C2+30*unitvector(C2-C4); + D2=C2+30*unitvector(C2-C5); + D3=C3+30*unitvector(C3-C1); + D4=C4+30*unitvector(C4-C1); + D5=C5+30*unitvector(C5-C3); + + drawarrow C2--D1; + drawarrow C2--D2; + drawarrow C3--D3; + drawarrow C4--D4; + drawarrow C5--D5; + + label.ulft(LATEX("\noexpand\bfseries\noexpand\Large"&decimal(Cible)&""),D1); + label.lft(LATEX("\noexpand\bfseries\noexpand\Large"&decimal(Cible)),D2); + label.llft(LATEX("\noexpand\bfseries\noexpand\Large"&decimal(Cible)),D3); + label.lrt(LATEX("\noexpand\bfseries\noexpand\Large"&decimal(Cible)),D4); + label.urt(LATEX("\noexpand\bfseries\noexpand\Large"&decimal(Cible)),D5); + + trace polygone(C1,C3,C5,C2,C4) withpen (pencircle scaled 8); + A1=C1; + A2=C2; + A9=C3; + A10=C4; + A5=C5; + A3=segment(C1,C3) intersectionpoint segment(C2,C5); + A4=segment(C1,C4) intersectionpoint segment(C2,C5); + A6=segment(C1,C3) intersectionpoint segment(C2,C4); + A7=segment(C1,C4) intersectionpoint segment(C3,C5); + A8=segment(C2,C4) intersectionpoint segment(C3,C5); + for k=1 upto 10: + ca[k]=cercles(A[k],0.6u); + fill ca[k] withcolor white; + trace ca[k]; + endfor; + vardef Affichage(text t)= + n:=0; + for p_=t: + n:=n+1; + label(LATEX("\noexpand\Large"&Rappel[n]),A[n]); + endfor; + enddef; + + vardef Suppression(text t)= + k:=0; + for p_=t: + k:=k+1; + fill ca[p_] withcolor white; + trace ca[p_]; + label(LATEX("\noexpand\Large"&Rappel[p_]),u*(-7,5.6-1.5k)); + trace cercles(u*(-7,5.6-1.5k),0.6u); + endfor; + enddef; + + Affichage(#1); + if Solution=false: + Suppression(#2); + fi; + + picture recap;% + recap:=currentpicture scaled Echelle;% + currentpicture:=nullpicture;% + draw recap;% + \end{mpost} + \fi +}% + +%%% +% Mentalo +%%% +\NewDocumentCommand\PfCNum{m}{% + \xintifboolexpr{#1<0}{(\num{#1})}{\num{#1}}% +}% + +\setKVdefault[Mentalo]{Questions=10,ValeurMin=1,ValeurMax=15} + +\NewDocumentCommand\Mentalo{o m}{% + \useKVdefault[Mentalo]% + \setKV[Mentalo]{#1}% + \xdef\PfCMentaloEtages{\fpeval{\useKV[Mentalo]{Questions}+1}} + \setsepchar{,}\ignoreemptyitems% + \readlist*\PfCMentaloListeOperations{#2}% + \reademptyitems% + \setlength{\tabcolsep}{0.25\tabcolsep} + \renewcommand{\arraystretch}{1.5} + \begin{NiceTabular}{*{\fpeval{\PfCMentaloEtages}}{m{5pt}}m{20pt}cm{20pt}cl*{\fpeval{\PfCMentaloEtages}}{m{5pt}}*{5}{m{15pt}}*{2}{m{10pt}}} + \Block{1-\fpeval{\PfCMentaloEtages}}{~}\xintFor* ##2 in{\xintSeq{1}{\fpeval{\PfCMentaloEtages}}}\do{&}% + \Block[draw,fill=gray!15]{1-5}{Arrivée}&&&&&\Block{1-\fpeval{\PfCMentaloEtages}}{~}\xintFor* ##2 in{\xintSeq{1}{\fpeval{\PfCMentaloEtages}}}\do{&}\\ + \xintFor* ##1 in{\xintSeq{1}{\fpeval{\PfCMentaloEtages-1}}}\do{% + \Block{1-\fpeval{\PfCMentaloEtages-##1}}{~}\xintFor* ##2 in{\xintSeq{1}{\fpeval{\PfCMentaloEtages-##1}}}\do{&}% + \Block[borders={top,left,bottom}]{1-\fpeval{##1}}{~}\xintFor* ##2 in{\xintSeq{1}{\fpeval{##1}}}\do{&}% + \Block[borders={top,bottom}]{1-1}{% + \xdef\PfCMentaloPremierTerme{\fpeval{randint(\useKV[Mentalo]{ValeurMin},\useKV[Mentalo]{ValeurMax})}}% + \num{\PfCMentaloPremierTerme}}&\Block[borders={top,bottom}]{1-1}{% + \xintifboolexpr{\PfCMentaloListeOperationslen==1}{% + \StrSubstitute{\PfCMentaloListeOperations[1]}{*}{\times}[\PfCCBAffiche]$\PfCCBAffiche$% + }{% + \StrSubstitute{\PfCMentaloListeOperations[##1]}{*}{\times}[\PfCCBAffiche]$\PfCCBAffiche$% + }% + }&% + \Block[borders={top,bottom}]{1-1}{\xdef\PfCMentaloDeuxiemeTerme{\fpeval{randint(\useKV[Mentalo]{ValeurMin},\useKV[Mentalo]{ValeurMax})}}% + \PfCNum{\PfCMentaloDeuxiemeTerme}}&\Block[borders={top,bottom}]{1-1}{$=$}&\Block[borders={top,bottom}]{1-1}{\pointilles[20pt]}&% + \Block[borders={top,right,bottom}]{1-\fpeval{##1}}{~}\xintFor* ##2 in{\xintSeq{1}{\fpeval{##1}}}\do{&}% + \Block{1-\fpeval{\PfCMentaloEtages-##1}}{~}\xintFor* ##2 in{\xintSeq{1}{\fpeval{\PfCMentaloEtages-##1}}}\do{&}% + &&&&\Block{1-2}{% + \xintifboolexpr{\PfCMentaloListeOperationslen==1}{% + \num{\fpeval{\PfCMentaloPremierTerme\PfCMentaloListeOperations[1]\PfCMentaloDeuxiemeTerme}} + }{% + \num{\fpeval{\PfCMentaloPremierTerme\PfCMentaloListeOperations[##1]\PfCMentaloDeuxiemeTerme}} + }% + }&\\ + }% + \Block[draw,fill=gray!15]{1-\fpeval{2*\PfCMentaloEtages+5}}{Départ}\xintFor* ##2 in{\xintSeq{1}{\fpeval{2*\PfCMentaloEtages+5}}}\do{&}\\% + \CodeAfter + \tikz\draw[dashed] (1-|\fpeval{5+5+2+2*\PfCMentaloEtages-2})--(last-|\fpeval{5+5+2+2*\PfCMentaloEtages-2}); + \end{NiceTabular} +}% + +%%% % Calculs Croises %%% -\setKVdefault[CalculsCroises]{Largeur=20pt,Solution=false,Inverse=false,Creation=false,Graines=false,Vide=false,Couleur=LightGray,Negatifs=false} +\setKVdefault[CalculsCroises]{Largeur=20pt,Solution=false,Inverse=false,Creation=false,Graines=false,Vide=false,Couleur=LightGray,Negatifs=false,Aide=false} \defKV[CalculsCroises]{Graine=\setKV[CalculsCroises]{Graines}}% +\defKV[CalculsCroises]{ListeNombres=\setKV[CalculsCroises]{Aide}}% \newlength\PfCCalculsCroises% \NewDocumentCommand\CalculsCroises{o m}{% @@ -372,12 +1333,68 @@ \setsepchar{,}% \readlist*\PfCListeCCNb{\faa}% \readlist*\PfCListeCCOp{#2}% + \xdef\PfCCCfoo{\useKV[CalculsCroises]{ListeNombres}}% + \readlist*\PfCListeCCAide{\PfCCCfoo}% \begin{NiceTabular}{*{6}{m{\useKV[CalculsCroises]{Largeur}}}} - \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[1]}}{~}}&\StrCompare{\PfCListeCCOp[1]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[1]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[2]}}{~}}&\StrCompare{\PfCListeCCOp[2]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[2]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[3]}}{~}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[1]\PfCListeCCOp[1]\PfCListeCCNb[2]\PfCListeCCOp[2]\PfCListeCCNb[3]}}}}\\ + \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[1]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[1]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[1]}}{}% + }% + }{}% + }}&\StrCompare{\PfCListeCCOp[1]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[1]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[2]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[2]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[2]}}{}% + }% + }{}% + }}&\StrCompare{\PfCListeCCOp[2]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[2]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[3]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[3]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[3]}}{}% + }% + }{}% + }}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[1]\PfCListeCCOp[1]\PfCListeCCNb[2]\PfCListeCCOp[2]\PfCListeCCNb[3]}}}}\\ \rule{0pt}{\PfCCalculsCroises}\StrCompare{\PfCListeCCOp[3]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[3]$}}&\Block[fill=black]{}{~}&\StrCompare{\PfCListeCCOp[4]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[4]$}}&\Block[fill=black]{}{~}&\StrCompare{\PfCListeCCOp[5]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[5]$}}\\ - \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[4]}}{~}}&\StrCompare{\PfCListeCCOp[6]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[6]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[5]}}{~}}&\StrCompare{\PfCListeCCOp[7]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[7]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[6]}}{~}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[4]\PfCListeCCOp[6]\PfCListeCCNb[5]\PfCListeCCOp[7]\PfCListeCCNb[6]}}}}\\ + \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[4]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[4]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[4]}}{}% + }% + }{}% + }}&\StrCompare{\PfCListeCCOp[6]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[6]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[5]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[5]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[5]}}{}% + }% + }{}% + }}&\StrCompare{\PfCListeCCOp[7]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[7]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[6]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[6]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[6]}}{}% + }% + }{}% + }}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[4]\PfCListeCCOp[6]\PfCListeCCNb[5]\PfCListeCCOp[7]\PfCListeCCNb[6]}}}}\\ \rule{0pt}{\PfCCalculsCroises}\StrCompare{\PfCListeCCOp[8]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[8]$}}&\Block[fill=black]{}{~}&\StrCompare{\PfCListeCCOp[9]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[9]$}}&\Block[fill=black]{}{~}&\StrCompare{\PfCListeCCOp[10]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[10]$}}\\ - \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[7]}}{~}}&\StrCompare{\PfCListeCCOp[11]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[11]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[8]}}{~}}&\StrCompare{\PfCListeCCOp[12]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[12]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[9]}}{~}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[7]\PfCListeCCOp[11]\PfCListeCCNb[8]\PfCListeCCOp[12]\PfCListeCCNb[9]}}}}\\ + \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[7]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[7]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[7]}}{}% + }% + }{}% + }}&\StrCompare{\PfCListeCCOp[11]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[11]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[8]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[8]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[8]}}{}% + }% + }{}% + }}&\StrCompare{\PfCListeCCOp[12]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[12]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCNb[9]}}{% + \ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCNb[9]==\PfCListeCCAide[##1]}{\num{\PfCListeCCNb[9]}}{}% + }% + }{}% + }}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[7]\PfCListeCCOp[11]\PfCListeCCNb[8]\PfCListeCCOp[12]\PfCListeCCNb[9]}}}}\\ \rule{0pt}{\PfCCalculsCroises}\Block[borders={left,bottom,right},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[1]\PfCListeCCOp[3]\PfCListeCCNb[4]\PfCListeCCOp[8]\PfCListeCCNb[7]}}}}&&\Block[borders={left,bottom,right},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[2]\PfCListeCCOp[4]\PfCListeCCNb[5]\PfCListeCCOp[9]\PfCListeCCNb[8]}}}}&&\Block[borders={left,bottom,right},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCNb[3]\PfCListeCCOp[5]\PfCListeCCNb[6]\PfCListeCCOp[10]\PfCListeCCNb[9]}}}}\\ \CodeAfter \tikz\draw (1-|1) rectangle (6-|6); @@ -408,12 +1425,59 @@ \end{NiceTabular} }{% \readlist*\PfCListeCCOp{#2}% + \xdef\PfCCCfoo{\useKV[CalculsCroises]{ListeNombres}}% + \readlist*\PfCListeCCAide{\PfCCCfoo}% \begin{NiceTabular}{*{6}{m{\useKV[CalculsCroises]{Largeur}}}} - \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[1]}}{~}}&\StrCompare{\PfCListeCCOp[2]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[2]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[3]}}{~}}&\StrCompare{\PfCListeCCOp[4]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[4]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[5]}}{~}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[1]\PfCListeCCOp[2]\PfCListeCCOp[3]\PfCListeCCOp[4]\PfCListeCCOp[5]}}}}\\ + \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[1]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[1]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[1]}}{}% + }% + }{}% +}}&\StrCompare{\PfCListeCCOp[2]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[2]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[3]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[3]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[3]}}{}% + }% + }{}% +}}&\StrCompare{\PfCListeCCOp[4]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[4]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[5]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[5]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[5]}}{}% + }% + }{}% +}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[1]\PfCListeCCOp[2]\PfCListeCCOp[3]\PfCListeCCOp[4]\PfCListeCCOp[5]}}}}\\ \rule{0pt}{\PfCCalculsCroises}\StrCompare{\PfCListeCCOp[6]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[6]$}}&\Block[fill=black]{}{~}&\StrCompare{\PfCListeCCOp[7]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[7]$}}&\Block[fill=black]{}{~}&\StrCompare{\PfCListeCCOp[8]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[8]$}}\\ - \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[9]}}{~}}&\StrCompare{\PfCListeCCOp[10]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[10]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[11]}}{~}}&\StrCompare{\PfCListeCCOp[12]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[12]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[13]}}{~}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[9]\PfCListeCCOp[10]\PfCListeCCOp[11]\PfCListeCCOp[12]\PfCListeCCOp[13]}}}}\\ + \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[9]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[9]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[9]}}{}% + }% + }{}% +}}&\StrCompare{\PfCListeCCOp[10]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[10]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[11]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[11]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[11]}}{}% + }% + }{}% +}}&\StrCompare{\PfCListeCCOp[12]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[12]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[13]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[13]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[13]}}{}% + }% + }{}% +}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[9]\PfCListeCCOp[10]\PfCListeCCOp[11]\PfCListeCCOp[12]\PfCListeCCOp[13]}}}}\\ \rule{0pt}{\PfCCalculsCroises}\StrCompare{\PfCListeCCOp[14]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[14]$}}&\Block[fill=black]{}{~}&\StrCompare{\PfCListeCCOp[15]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[15]$}}&\Block[fill=black]{}{~}&\StrCompare{\PfCListeCCOp[16]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[16]$}}\\ - \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[17]}}{~}}&\StrCompare{\PfCListeCCOp[18]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[18]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[19]}}{~}}&\StrCompare{\PfCListeCCOp[20]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[20]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[21]}}{~}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[17]\PfCListeCCOp[18]\PfCListeCCOp[19]\PfCListeCCOp[20]\PfCListeCCOp[21]}}}}\\ + \rule{0pt}{\PfCCalculsCroises}\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[17]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[17]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[17]}}{}% + }% + }{}% +}}&\StrCompare{\PfCListeCCOp[18]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[18]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[19]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[19]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[19]}}{}% + }% + }{}% +}}&\StrCompare{\PfCListeCCOp[20]}{*}[\PfCTestEtoile]\Block{}{\xintifboolexpr{\PfCTestEtoile==0}{$\times$}{$\PfCListeCCOp[20]$}}&\Block{}{\ifboolKV[CalculsCroises]{Solution}{\num{\PfCListeCCOp[21]}}{\ifboolKV[CalculsCroises]{Aide}{% + \xintFor* ##1 in{\xintSeq{1}{\PfCListeCCAidelen}}\do{% + \xintifboolexpr{\PfCListeCCOp[21]==\PfCListeCCAide[##1]}{\num{\PfCListeCCOp[21]}}{}% + }% + }{}% +}}&\Block[borders={bottom,right,top},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[17]\PfCListeCCOp[18]\PfCListeCCOp[19]\PfCListeCCOp[20]\PfCListeCCOp[21]}}}}\\ \rule{0pt}{\PfCCalculsCroises}\Block[borders={left,bottom,right},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[1]\PfCListeCCOp[6]\PfCListeCCOp[9]\PfCListeCCOp[14]\PfCListeCCOp[17]}}}}&&\Block[borders={left,bottom,right},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[3]\PfCListeCCOp[7]\PfCListeCCOp[11]\PfCListeCCOp[15]\PfCListeCCOp[19]}}}}&&\Block[borders={left,bottom,right},fill=PfCCouleurCC]{}{\ifboolKV[CalculsCroises]{Inverse}{}{\num{\fpeval{\PfCListeCCOp[5]\PfCListeCCOp[8]\PfCListeCCOp[13]\PfCListeCCOp[16]\PfCListeCCOp[21]}}}}\\ \CodeAfter \tikz\draw (1-|1) rectangle (6-|6); @@ -732,14 +1796,19 @@ %%% % Kakuro %%% -\setKVdefault[Kakuro]{CouleurCase=LightGray,Taille=5,Solution=false,Largeur=2em,Aide=false,CouleurSolution=Black} +\setKVdefault[Kakuro]{CouleurCase=LightGray,TLargeur=5,THauteur=5,Solution=false,Largeur=2em,Aide=false,CouleurSolution=Black,Tailles=false}%,Taille=5 \defKV[Kakuro]{ListeNombres=\setKV[Kakuro]{Aide}}% +\defKV[Kakuro]{Taille=\setKV[Kakuro]{Tailles}}% \newlength\PfCKakuro% \NewDocumentCommand\Kakuro{o m}{% \useKVdefault[Kakuro]% \setKV[Kakuro]{#1}% + \ifboolKV[Kakuro]{Tailles}{% + \setKV[Kakuro]{THauteur=\useKV[Kakuro]{Taille}}% + \setKV[Kakuro]{TLargeur=\useKV[Kakuro]{Taille}}% + }{}% \setlength{\PfCKakuro}{\useKV[Kakuro]{Largeur}+\tabcolsep}% \setsepchar[*]{,*/}% \readlist*\ListeCasesKK{#2}% @@ -748,21 +1817,21 @@ \readlist*\ListeKakuroNombres{\ListeAvantNombres}% \savecomparemode% \comparestrict% - \begin{NiceTabular}{*{\useKV[Kakuro]{Taille}}{m{\useKV[Kakuro]{Largeur}}}}[hvlines] - \xintFor* ##1 in {\xintSeq{0}{\fpeval{\useKV[Kakuro]{Taille}-1}}}\do{% - \xintFor* ##2 in {\xintSeq{1}{\useKV[Kakuro]{Taille}}}\do{% + \begin{NiceTabular}{*{\useKV[Kakuro]{TLargeur}}{m{\useKV[Kakuro]{Largeur}}}}[hvlines] + \xintFor* ##1 in {\xintSeq{0}{\fpeval{\useKV[Kakuro]{THauteur}-1}}}\do{% + \xintFor* ##2 in {\xintSeq{1}{\useKV[Kakuro]{TLargeur}}}\do{% \rule{0pt}{\PfCKakuro}% - \StrCompare{\ListeCasesKK[\fpeval{\useKV[Kakuro]{Taille}*##1+##2},1]}{*}[\PfCTestBlack] + \StrCompare{\ListeCasesKK[\fpeval{\useKV[Kakuro]{TLargeur}*##1+##2},1]}{*}[\PfCTestBlack] \xintifboolexpr{\PfCTestBlack==0}{% \Block[fill=black]{1-1}{}% }{% - \xintifboolexpr{\listlen\ListeCasesKK[\fpeval{\useKV[Kakuro]{Taille}*##1+##2}]==2}{ - \Block[fill=\useKV[Kakuro]{CouleurCase}]{1-1}{\diagbox{\ListeCasesKK[\fpeval{\useKV[Kakuro]{Taille}*##1+##2},1]}{\ListeCasesKK[\fpeval{\useKV[Kakuro]{Taille}*##1+##2},2]}}% + \xintifboolexpr{\listlen\ListeCasesKK[\fpeval{\useKV[Kakuro]{TLargeur}*##1+##2}]==2}{ + \Block[fill=\useKV[Kakuro]{CouleurCase}]{1-1}{\diagbox{\ListeCasesKK[\fpeval{\useKV[Kakuro]{TLargeur}*##1+##2},1]}{\ListeCasesKK[\fpeval{\useKV[Kakuro]{TLargeur}*##1+##2},2]}}% }{% - \Block{1-1}{\ifboolKV[Kakuro]{Solution}{\Large\color{\useKV[Kakuro]{CouleurSolution}}\num{\ListeCasesKK[\fpeval{\useKV[Kakuro]{Taille}*##1+##2},1]}}{% + \Block{1-1}{\ifboolKV[Kakuro]{Solution}{\Large\color{\useKV[Kakuro]{CouleurSolution}}\num{\ListeCasesKK[\fpeval{\useKV[Kakuro]{TLargeur}*##1+##2},1]}}{% \ifboolKV[Kakuro]{Aide}{% \xintFor* ##3 in{\xintSeq{1}{\ListeKakuroNombreslen}}\do{% - \Block{1-1}{\xintifboolexpr{\ListeCasesKK[\fpeval{\useKV[Kakuro]{Taille}*##1+##2},1]==\ListeKakuroNombres[##3]}{\Large\color{\useKV[Kakuro]{CouleurSolution}}\num{\ListeCasesKK[\fpeval{\useKV[Kakuro]{Taille}*##1+##2},1]}}{}}% + \Block{1-1}{\xintifboolexpr{\ListeCasesKK[\fpeval{\useKV[Kakuro]{TLargeur}*##1+##2},1]==\ListeKakuroNombres[##3]}{\Large\color{\useKV[Kakuro]{CouleurSolution}}\num{\ListeCasesKK[\fpeval{\useKV[Kakuro]{TLargeur}*##1+##2},1]}}{}}% }% }{}% }% @@ -5381,18 +6450,458 @@ transform canvas={xshift=0em,yshift=0em}},rectangle,rounded corners,ultra thick, %%% % Labyrinthe Nombre %%% -\setKVdefault[ClesLabyNb]{Multiple=5,XDepart=0,YDepart=0,Longueur=7,Largeur=4,XArrivee=6,YArrivee=3,Solution=false,Echelle=1,Angle=0,Couleur=red,Murs=false,Nom=Ex1,CouleurChemin=LightSteelBlue} +\setKVdefault[ClesLabyNb]{Multiple=5,XDepart=0,YDepart=0,Longueur=7,Largeur=4,XArrivee=6,YArrivee=3,Solution=false,Echelle=1,Angle=0,Couleur=red,Murs=false,Nom=Ex1,CouleurChemin=Brown,DoubleOperation=false,Chemin=false,EntreeSortie=false,Entree="Nord",Sortie="Sud",SortieUnique=true} \newcommand\LabyNombre[1][]{% \useKVdefault[ClesLabyNb]% \setKV[ClesLabyNb]{#1}% - \ifboolKV[ClesLabyNb]{Solution}{% - \TraceSolution{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}} + \ifboolKV[ClesLabyNb]{EntreeSortie}{% + \ifboolKV[ClesLabyNb]{Solution}{% + \TraceLabyMathAleaSolution{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}}% + }{% + \TraceLabyMathAlea{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}}% + }% }{% - \TraceLabyNombre{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}} + \ifboolKV[ClesLabyNb]{DoubleOperation}{% + \ifboolKV[ClesLabyNb]{Solution}{% + \TraceDoubleSolution{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}}% + }{% + \TraceLabyNombreDouble{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}}% + }% + }{% + \ifboolKV[ClesLabyNb]{Solution}{% + \TraceSolution{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}}% + }{% + \TraceLabyNombre{\useKV[ClesLabyNb]{Multiple}}{\useKV[ClesLabyNb]{Longueur}}{\useKV[ClesLabyNb]{Largeur}}{(\useKV[ClesLabyNb]{YDepart},\useKV[ClesLabyNb]{XDepart})}{(\useKV[ClesLabyNb]{YArrivee},\useKV[ClesLabyNb]{XArrivee})}{\useKV[ClesLabyNb]{Solution}}% + }% + }% }% +}% + +\newcommand\TraceLabyMathAlea[6]{% + \mplibforcehmode% + \xdef\PfCNomLabyrinthe{\useKV[ClesLabyNb]{Nom}}% + \begin{mplibcode}[\PfCNomLabyrinthe] + input PfCLabyNombre; + + boolean Murs; + Murs=\useKV[ClesLabyNb]{Murs}; + + string Entree,Sortie; + Entree=\useKV[ClesLabyNb]{Entree}; + Sortie=\useKV[ClesLabyNb]{Sortie}; + boolean SortieUnique; + SortieUnique:=\useKV[ClesLabyNb]{SortieUnique}; + picture Square; + Square=image( + path Test; + Test=unitsquare scaled 10mm; + trace subpath(0.85,1.15) of Test; + trace subpath(1.85,2.15) of Test; + trace subpath(2.85,3.15) of Test; + trace subpath(3.85,4.15) of Test; + ); + + numeric Multiple; + Multiple=#1; + % Initialisation du labyrinthe + InitialisationLabyrinthe(#2,#3); + % On initialise les paramètres du parcours + numeric choixligneD,choixligneA,choixcolonneD,choixcolonneA; + choixligneD=xpart(#4); + choixcolonneD=ypart(#4); + choixligneA=xpart(#5); + choixcolonneA=ypart(#5);% + pair Depart; + Depart=N[choixligneD][choixcolonneD]; + pair Arrivee; + Arrivee=N[choixligneA][choixcolonneA]; + pair Mobile; + Mobile=Depart; + % + RAZPileChemin; + + if \useKV[ClesLabyNb]{SortieUnique}: + if (Sortie="Est") or (Sortie="Ouest"): + for k=0 upto LargeurLaby-1: + if k<>choixligneA: + CaseExploree[k][choixcolonneA]:=true; + fi; + endfor; + elseif (Sortie="Nord") or (Sortie="Sud"): + for k=0 upto LongueurLaby-1: + if k<>choixcolonneA: + CaseExploree[choixligneA][k]:=true; + fi; + endfor; + fi; + fi; + % Exploration du labyrinthe + if Entree="Nord": + CaseExploree[choixligneD-1][choixcolonneD]:=true; + elseif Entree="Sud": + CaseExploree[choixligneD+1][choixcolonneD]:=true; + elseif Entree="Est": + CaseExploree[choixligneD][choixcolonneD+1]:=true; + elseif Entree="Ouest": + CaseExploree[choixligneD][choixcolonneD-1]:=true; + fi; + % + PushChemin((choixligneD,choixcolonneD)); + CaseExploree[choixligneD][choixcolonneD]:=true; + VoisinDispo(choixligneD,choixcolonneD); + forever: exitif Mobile=Arrivee;%nb=0; + nb:=ceiling(uniformdeviate(nbvoisin)); + if nb>0: + for k=1 upto nbvoisin: + CaseExploree[xpart(PileVoisin[k])][ypart(PileVoisin[k])]:=true; + endfor; + PushChemin((xpart(PileVoisin[nb]),ypart(PileVoisin[nb]))); + Mobile:=N[xpart(PileChemin[indiceChemin])][ypart(PileChemin[indiceChemin])]; + VoisinDispo(xpart(PileChemin[indiceChemin]),ypart(PileChemin[indiceChemin])); + else: + PopCheminMathAlea; + fi; + endfor; + % Affichagefinal + % on sauvegarde les nombres aléatoires + numeric NbAffiche[]; + numeric NbSol[]; + % on écrit des nombres au hasard, mais sans être multiple du nombre choisi + numeric nbaffiche; + nbaffiche=0; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + nbaffiche:=nbaffiche+1; + NbAffiche[nbaffiche]:=(50+ceiling(uniformdeviate(100)))*Multiple+ceiling(uniformdeviate(Multiple-1)); + endfor; + endfor; + % On crée des multiples du nombre choisi + for k=1 upto indiceChemin: + NbSol[k]=(50+ceiling(uniformdeviate(100)))*Multiple; + endfor; + % On affiche + picture Corps; + Corps=image( + nbaffiche:=0; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + nbaffiche:=nbaffiche+1; + label(TEX("\num{"&decimal(NbAffiche[nbaffiche])&"}"),M[k][l]); + endfor; + endfor; + for k=1 upto indiceChemin: + remplis ((unitsquare scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) withcolor white; + label(TEX("\num{"&decimal(NbSol[k])&"}"),M[xpart(PileChemin[k])][ypart(PileChemin[k])]); + endfor; + % trace TraceLabyrinthe; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + trace Square shifted N[k][l]; + endfor; + endfor; + trace u*(0,0)--u*(LongueurLaby,0)--u*(LongueurLaby,-LargeurLaby)--u*(0,-LargeurLaby)--cycle; + % On dessine l'entrée. + if Entree="Nord": + N[-1][-1]:=Depart+(0,10mm); + fill ((unitsquare scaled 10mm) shifted N[-1][-1]) withcolor white; + draw (subpath(1,4) of unitsquare scaled 10mm) shifted N[-1][-1]; + undraw (subpath(0.18,0.82) of unitsquare scaled 10mm) shifted N[-1][-1] withpen pencircle scaled 1.25; + label(btex \footnotesize Départ etex,(center Square) shifted N[-1][-1]); + elseif Entree="Ouest": + N[-1][-1]:=Depart+(-10mm,0); + fill ((unitsquare scaled 10mm) shifted N[-1][-1]) withcolor white; + draw (subpath(2,5) of unitsquare scaled 10mm) shifted N[-1][-1]; + undraw (subpath(1.15,1.85) of unitsquare scaled 10mm) shifted N[-1][-1] withpen pencircle scaled 1.25; + label(btex \footnotesize Départ etex,(center Square) shifted N[-1][-1]); + elseif Entree="Sud": + N[-1][-1]:=Depart+(0,-10mm); + fill ((unitsquare scaled 10mm) shifted N[-1][-1]) withcolor white; + draw (subpath(3,6) of unitsquare scaled 10mm) shifted N[-1][-1]; + undraw (subpath(2.15,2.85) of unitsquare scaled 10mm) shifted N[-1][-1] withpen pencircle scaled 1.25; + label(btex \footnotesize Départ etex,(center Square) shifted N[-1][-1]); + elseif Entree="Est": + N[-1][-1]:=Depart+(10mm,0); + fill ((unitsquare scaled 10mm) shifted N[-1][-1]) withcolor white; + draw (subpath(0,3) of unitsquare scaled 10mm) shifted N[-1][-1]; + undraw (subpath(3.18,3.82) of unitsquare scaled 10mm) shifted N[-1][-1] withpen pencircle scaled 1.25; + label(btex \footnotesize Départ etex,(center Square) shifted N[-1][-1]); + fi; + % On dessine les sorties + if Sortie="Nord": + N[-2][-2]=Arrivee+(5mm,20mm); + for k=0 upto LongueurLaby-1: + draw ((point(0.15) of unitsquare scaled 10mm)--0.5[(point(0.15) of unitsquare scaled 10mm),(point(2.85) of unitsquare scaled 10mm)]) shifted (N[0][k]+(0,10mm)); + draw ((point(0.85) of unitsquare scaled 10mm)--0.5[(point(0.85) of unitsquare scaled 10mm),(point(2.15) of unitsquare scaled 10mm)]) shifted (N[0][k]+(0,10mm)); + undraw (subpath(0.18,0.82) of unitsquare scaled 10mm) shifted (N[0][k]+(0,10mm)) withpen pencircle scaled 1.25; + label(TEX("\footnotesize S"&decimal(k)),center (Square) shifted (N[0][k]+(0,10mm))); + endfor; + elseif Sortie="Ouest": + N[-2][-2]=Arrivee+(-10mm,5mm); + for k=0 upto LargeurLaby-1: + draw ((point(1.15) of unitsquare scaled 10mm)--0.5[(point(1.15) of unitsquare scaled 10mm),(point(3.85) of unitsquare scaled 10mm)]) shifted (N[k][0]+(-10mm,0)); + draw ((point(1.85) of unitsquare scaled 10mm)--0.5[(point(1.85) of unitsquare scaled 10mm),(point(3.15) of unitsquare scaled 10mm)]) shifted (N[k][0]+(-10mm,0)); + undraw (subpath(1.18,1.82) of unitsquare scaled 10mm) shifted (N[k][0]+(-10mm,0)) withpen pencircle scaled 1.25; + label(TEX("\footnotesize S"&decimal(k)),center (Square) shifted (N[k][0]+(-10mm,0))); + endfor; + elseif Sortie="Sud": + N[-2][-2]=Arrivee+(5mm,-10mm); + for k=0 upto LongueurLaby-1: + draw ((point(2.85) of unitsquare scaled 10mm)--0.5[(point(0.15) of unitsquare scaled 10mm),(point(2.85) of unitsquare scaled 10mm)]) shifted (N[LargeurLaby-1][k]+(0,-10mm)); + draw ((point(2.15) of unitsquare scaled 10mm)--0.5[(point(0.85) of unitsquare scaled 10mm),(point(2.15) of unitsquare scaled 10mm)]) shifted (N[LargeurLaby-1][k]+(0,-10mm)); + undraw (subpath(2.18,2.82) of unitsquare scaled 10mm) shifted (N[LargeurLaby-1][k]+(0,-10mm)) withpen pencircle scaled 1.25; + label(TEX("\footnotesize S"&decimal(k)),center (Square) shifted (N[LargeurLaby-1][k]+(0,-10mm))); + endfor; + elseif Sortie="Est": + N[-2][-2]=Arrivee+(20mm,5mm); + for k=0 upto LargeurLaby-1: + draw ((point(3.15) of unitsquare scaled 10mm)--0.5[(point(3.15) of unitsquare scaled 10mm),(point(1.85) of unitsquare scaled 10mm)]) shifted (N[k][LongueurLaby-1]+(10mm,0)); + draw ((point(3.85) of unitsquare scaled 10mm)--0.5[(point(3.85) of unitsquare scaled 10mm),(point(1.15) of unitsquare scaled 10mm)]) shifted (N[k][LongueurLaby-1]+(10mm,0)); + undraw (subpath(3.18,3.8) of unitsquare scaled 10mm) shifted (N[k][LongueurLaby-1]+(10mm,0)) withpen pencircle scaled 1.25; + label(TEX("\footnotesize S"&decimal(k)),center (Square) shifted (N[k][LongueurLaby-1]+(10mm,0))); + endfor; + fi; + ); + Corps:=(Corps scaled \useKV[ClesLabyNb]{Echelle}) rotated \useKV[ClesLabyNb]{Angle}; + trace Corps; + \end{mplibcode} } +\newcommand\TraceLabyMathAleaSolution[6]{% + \mplibforcehmode% + \xdef\PfCNomLabyrinthe{\useKV[ClesLabyNb]{Nom}}% + \begin{mplibcode}[\PfCNomLabyrinthe]% + color CouleurChemin; + CouleurChemin:=\useKV[ClesLabyNb]{CouleurChemin}; + picture CorpsSolution; + CorpsSolution=image( + nbaffiche:=0; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + nbaffiche:=nbaffiche+1; + label(TEX("\num{"&decimal(NbAffiche[nbaffiche])&"}"),M[k][l]); + endfor; + endfor; + for k=1 upto indiceChemin: + remplis ((unitsquare scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) withcolor white; + label(TEX("\num{"&decimal(NbSol[k])&"}"),M[xpart(PileChemin[k])][ypart(PileChemin[k])]); + endfor; + % trace TraceLabyrinthe; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + trace Square shifted N[k][l]; + endfor; + endfor; + trace u*(0,0)--u*(LongueurLaby,0)--u*(LongueurLaby,-LargeurLaby)--u*(0,-LargeurLaby)--cycle; + % On dessine l'entrée. + if Entree="Nord": + N[-1][-1]:=Depart+(0,10mm); + fill ((unitsquare scaled 10mm) shifted N[-1][-1]) withcolor white; + draw (subpath(1,4) of unitsquare scaled 10mm) shifted N[-1][-1]; + undraw (subpath(0.18,0.82) of unitsquare scaled 10mm) shifted N[-1][-1] withpen pencircle scaled 1.25; + label(btex \footnotesize Départ etex,(center Square) shifted N[-1][-1]); + elseif Entree="Ouest": + N[-1][-1]:=Depart+(-10mm,0); + fill ((unitsquare scaled 10mm) shifted N[-1][-1]) withcolor white; + draw (subpath(2,5) of unitsquare scaled 10mm) shifted N[-1][-1]; + undraw (subpath(1.15,1.85) of unitsquare scaled 10mm) shifted N[-1][-1] withpen pencircle scaled 1.25; + label(btex \footnotesize Départ etex,(center Square) shifted N[-1][-1]); + elseif Entree="Sud": + N[-1][-1]:=Depart+(0,-10mm); + fill ((unitsquare scaled 10mm) shifted N[-1][-1]) withcolor white; + draw (subpath(3,6) of unitsquare scaled 10mm) shifted N[-1][-1]; + undraw (subpath(2.15,2.85) of unitsquare scaled 10mm) shifted N[-1][-1] withpen pencircle scaled 1.25; + label(btex \footnotesize Départ etex,(center Square) shifted N[-1][-1]); + elseif Entree="Est": + N[-1][-1]:=Depart+(10mm,0); + fill ((unitsquare scaled 10mm) shifted N[-1][-1]) withcolor white; + draw (subpath(0,3) of unitsquare scaled 10mm) shifted N[-1][-1]; + undraw (subpath(3.18,3.82) of unitsquare scaled 10mm) shifted N[-1][-1] withpen pencircle scaled 1.25; + label(btex \footnotesize Départ etex,(center Square) shifted N[-1][-1]); + fi; + % On dessine les sorties + if Sortie="Nord": + N[-2][-2]=Arrivee+(5mm,20mm); + for k=0 upto LongueurLaby-1: + draw ((point(0.15) of unitsquare scaled 10mm)--0.5[(point(0.15) of unitsquare scaled 10mm),(point(2.85) of unitsquare scaled 10mm)]) shifted (N[0][k]+(0,10mm)); + draw ((point(0.85) of unitsquare scaled 10mm)--0.5[(point(0.85) of unitsquare scaled 10mm),(point(2.15) of unitsquare scaled 10mm)]) shifted (N[0][k]+(0,10mm)); + undraw (subpath(0.18,0.82) of unitsquare scaled 10mm) shifted (N[0][k]+(0,10mm)) withpen pencircle scaled 1.25; + label(TEX("\footnotesize S"&decimal(k)),center (Square) shifted (N[0][k]+(0,10mm))); + endfor; + elseif Sortie="Ouest": + N[-2][-2]=Arrivee+(-10mm,5mm); + for k=0 upto LargeurLaby-1: + draw ((point(1.15) of unitsquare scaled 10mm)--0.5[(point(1.15) of unitsquare scaled 10mm),(point(3.85) of unitsquare scaled 10mm)]) shifted (N[k][0]+(-10mm,0)); + draw ((point(1.85) of unitsquare scaled 10mm)--0.5[(point(1.85) of unitsquare scaled 10mm),(point(3.15) of unitsquare scaled 10mm)]) shifted (N[k][0]+(-10mm,0)); + undraw (subpath(1.18,1.82) of unitsquare scaled 10mm) shifted (N[k][0]+(-10mm,0)) withpen pencircle scaled 1.25; + label(TEX("\footnotesize S"&decimal(k)),center (Square) shifted (N[k][0]+(-10mm,0))); + endfor; + elseif Sortie="Sud": + N[-2][-2]=Arrivee+(5mm,-10mm); + for k=0 upto LongueurLaby-1: + % draw (Square) shifted (N[LargeurLaby-1][k]+(0,-10mm)) withcolor red; + draw ((point(2.85) of unitsquare scaled 10mm)--0.5[(point(0.15) of unitsquare scaled 10mm),(point(2.85) of unitsquare scaled 10mm)]) shifted (N[LargeurLaby-1][k]+(0,-10mm)); + draw ((point(2.15) of unitsquare scaled 10mm)--0.5[(point(0.85) of unitsquare scaled 10mm),(point(2.15) of unitsquare scaled 10mm)]) shifted (N[LargeurLaby-1][k]+(0,-10mm)); + undraw (subpath(2.18,2.82) of unitsquare scaled 10mm) shifted (N[LargeurLaby-1][k]+(0,-10mm)) withpen pencircle scaled 1.25; + label(TEX("\footnotesize S"&decimal(k)),center (Square) shifted (N[LargeurLaby-1][k]+(0,-10mm))); + endfor; + elseif Sortie="Est": + N[-2][-2]=Arrivee+(20mm,5mm); + for k=0 upto LargeurLaby-1: + draw ((point(3.15) of unitsquare scaled 10mm)--0.5[(point(3.15) of unitsquare scaled 10mm),(point(1.85) of unitsquare scaled 10mm)]) shifted (N[k][LongueurLaby-1]+(10mm,0)); + draw ((point(3.85) of unitsquare scaled 10mm)--0.5[(point(3.85) of unitsquare scaled 10mm),(point(1.15) of unitsquare scaled 10mm)]) shifted (N[k][LongueurLaby-1]+(10mm,0)); + undraw (subpath(3.18,3.8) of unitsquare scaled 10mm) shifted (N[k][LongueurLaby-1]+(10mm,0)) withpen pencircle scaled 1.25; + label(TEX("\footnotesize S"&decimal(k)),center (Square) shifted (N[k][LongueurLaby-1]+(10mm,0))); + endfor; + fi; + path CheminSolution; + CheminSolution=(N[-1][-1] shifted (5mm,5mm))--((center unitsquare scaled 10mm) shifted N[choixligneD][choixcolonneD]) + for k=2 upto indiceChemin-1: + -- ((center unitsquare scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) + endfor + --((center unitsquare scaled 10mm) shifted Arrivee)--N[-2][-2]; + trace CheminSolution dashed evenly withcolor CouleurChemin; + ); + CorpsSolution:=(CorpsSolution scaled \useKV[ClesLabyNb]{Echelle}) rotated \useKV[ClesLabyNb]{Angle}; + trace CorpsSolution; + \end{mplibcode}% +}% + +\newcommand\TraceLabyNombreDouble[6]{% + \mplibforcehmode% + \xdef\PfCNomLabyrinthe{\useKV[ClesLabyNb]{Nom}}% + \begin{mplibcode}[\PfCNomLabyrinthe] + input PfCLabyNombre; + + boolean Murs; + Murs=\useKV[ClesLabyNb]{Murs}; + + numeric Multiple; + Multiple=#1; + % Initialisation du labyrinthe + InitialisationLabyrinthe(#2,#3); + % On initialise les paramètres du parcours + numeric choixligneD,choixligneA,choixcolonneD,choixcolonneA; + choixligneD=xpart(#4); + choixcolonneD=ypart(#4); + choixligneA=xpart(#5); + choixcolonneA=ypart(#5);% + pair Depart; + Depart=N[choixligneD][choixcolonneD]; + pair Arrivee; + Arrivee=N[choixligneA][choixcolonneA]; + pair Mobile; + Mobile=Depart; + RAZPileChemin; + % Exploration du labyrinthe + PushChemin((choixligneD,choixcolonneD)); + CaseExploree[choixligneD][choixcolonneD]:=true; + VoisinDispo(choixligneD,choixcolonneD); + forever: exitif Mobile=Arrivee;%nb=0; + nb:=ceiling(uniformdeviate(nbvoisin)); + if nb>0: + for k=1 upto nbvoisin: + CaseExploree[xpart(PileVoisin[k])][ypart(PileVoisin[k])]:=true; + endfor; + PushChemin((xpart(PileVoisin[nb]),ypart(PileVoisin[nb]))); + Mobile:=N[xpart(PileChemin[indiceChemin])][ypart(PileChemin[indiceChemin])]; + VoisinDispo(xpart(PileChemin[indiceChemin]),ypart(PileChemin[indiceChemin])); + else: + PopChemin; + fi; + endfor; + % Affichagefinal + % on sauvegarde les nombres aléatoires + numeric NbAffiche[]; + numeric NbSol[]; + % on écrit des nombres au hasard, mais sans être multiple du nombre choisi + numeric nbaffiche; + nbaffiche=0; + NbAffiche[0]=5+ceiling(uniformdeviate(7)); + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + nbaffiche:=nbaffiche+1; + mathalea:=uniformdeviate(1); + if mathalea<0.95: + NbAffiche[nbaffiche]=NbAffiche[nbaffiche-1]+Multiple+1; + else: + NbAffiche[nbaffiche]=NbAffiche[nbaffiche-1]*(Multiple-1); + fi; + endfor; + endfor; + % On crée des multiples du nombre choisi + NbSol[1]=5+ceiling(uniformdeviate(7)); + for k=2 upto indiceChemin-1: + mathalea:=uniformdeviate(1); + if mathalea<0.9: + NbSol[k]=NbSol[k-1]+Multiple; + else: + NbSol[k]=NbSol[k-1]*Multiple; + fi; + endfor; + % On affiche + picture Corps; + Corps=image( + nbaffiche:=0; + for k=0 upto LargeurLaby-1: + for l=0 upto LongueurLaby-1: + nbaffiche:=nbaffiche+1; + label(TEX("\num{"&decimal(NbAffiche[nbaffiche])&"}"),M[k][l]); + endfor; + endfor; + remplis ((unitsquare scaled 10mm) shifted N[choixligneD][choixcolonneD]) withcolor \useKV[ClesLabyNb]{Couleur}; + remplis ((unitsquare scaled 10mm) shifted Arrivee) withcolor \useKV[ClesLabyNb]{Couleur}; + for k=2 upto indiceChemin-1: + remplis ((unitsquare scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) withcolor white; + label(TEX("\num{"&decimal(NbSol[k])&"}"),M[xpart(PileChemin[k])][ypart(PileChemin[k])]); + endfor; + trace TraceLabyrinthe; + ); + Corps:=(Corps scaled \useKV[ClesLabyNb]{Echelle}) rotated \useKV[ClesLabyNb]{Angle}; + trace Corps; + \end{mplibcode} +} + +\newcommand\TraceDoubleSolution[6]{% + \mplibforcehmode% + \xdef\PfCNomLabyrinthe{\useKV[ClesLabyNb]{Nom}}% + \begin{mplibcode}[\PfCNomLabyrinthe] + picture CorpsSolution; + CorpsSolution=image( + nbaffiche:=0; + for k=0 upto #3-1: + for l=0 upto #2-1: + nbaffiche:=nbaffiche+1; + label(TEX("\num{"&decimal(NbAffiche[nbaffiche])&"}"),M[k][l]); + endfor; + endfor; + remplis ((unitsquare scaled 10mm) shifted N[choixligneD][choixcolonneD]) withcolor \useKV[ClesLabyNb]{Couleur}; + remplis ((unitsquare scaled 10mm) shifted Arrivee) withcolor \useKV[ClesLabyNb]{Couleur}; + if \useKV[ClesLabyNb]{Chemin}: + for k=2 upto indiceChemin-1: + remplis ((unitsquare scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) withcolor white; + endfor; + trace ((center unitsquare scaled 10mm) shifted N[choixligneD][choixcolonneD]) + for k=2 upto indiceChemin-1: + -- ((center unitsquare scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) + endfor + --((center unitsquare scaled 10mm) shifted Arrivee) dashed evenly withcolor Brown; + for k=2 upto indiceChemin-1: + label(TEX("\num{"&decimal(NbSol[k])&"}"),M[xpart(PileChemin[k])][ypart(PileChemin[k])]); + endfor; + else: + for k=2 upto indiceChemin-1: + remplis ((unitsquare scaled 10mm) shifted N[xpart(PileChemin[k])][ypart(PileChemin[k])]) withcolor \useKV[ClesLabyNb]{CouleurChemin}; + label(TEX("\num{"&decimal(NbSol[k])&"}"),M[xpart(PileChemin[k])][ypart(PileChemin[k])]); + endfor; + fi; + trace TraceLabyrinthe; + ); + CorpsSolution:=(CorpsSolution scaled \useKV[ClesLabyNb]{Echelle}) rotated \useKV[ClesLabyNb]{Angle}; + trace CorpsSolution; + \end{mplibcode} +}% + \newcommand\TraceLabyNombre[6]{% \mplibforcehmode% \xdef\PfCNomLabyrinthe{\useKV[ClesLabyNb]{Nom}}% @@ -6504,7 +8013,7 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. }% %%% Autonomie %%% -\setKVdefault[Autonomie]{AfficheMarge=false,TitreEnigme=Enigme,TitreAtoi=\`A toi,Enigme=false,TexteCorrection=\bfseries Correction,ARemplir=false,Deux=false}% +\setKVdefault[Autonomie]{AfficheMarge=false,TitreEnigme=Enigme,TitreAtoi=\`A toi,Enigme=false,TexteCorrection=\bfseries Correction,ARemplir=false,Deux=false,Landscape=false}% \newcommand\Autonomie[3][]{% \useKVdefault[Autonomie]% @@ -6541,6 +8050,10 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \draw (E\i) to (F\i);% }% }% + \coordinate (O1) at ($(D1)!0.5!(D2)$); + \coordinate (O2) at ($(D3)!0.5!(D4)$); + \coordinate (O3) at ($(E1)!0.5!(E2)$); + \coordinate (O4) at ($(E3)!0.5!(E4)$); \coordinate (Q1) at ($(F1)!0.5!(A3)$);% \coordinate (Q2) at ($(F2)!0.5!(E1)$);% \coordinate (Q3) at ($(F3)!0.5!(E2)$);% @@ -6549,20 +8062,44 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \coordinate (Q6) at ($(C2)!0.5!(D1)$);% \coordinate (Q7) at ($(C3)!0.5!(D2)$);% \coordinate (Q8) at ($(C4)!0.5!(D3)$);% - \draw[dashed] (A1) to (B1);% - \draw[dashed] (A3) to (B3);% - \ifboolKV[Autonomie]{ARemplir}{% + \ifboolKV[Autonomie]{Landscape}{% + \draw[dashed] (C1) to (F1); + \draw[dashed] (C3) to (F3); + \draw (A2) to (B2);% + }{% \ifboolKV[Autonomie]{Deux}{% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test1) at ($(Q1)!0.5!(Q2)$) {\ListeAutoQ[1,1]};% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test2) at ($(Q3)!0.5!(Q4)$) {\ListeAutoQ[2,1]};% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test3) at ($(Q5)!0.5!(Q6)$) {\ListeAutoQ[3,1]};% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test4) at ($(Q7)!0.5!(Q8)$) {\ListeAutoQ[4,1]};% + \draw (C2) to (D2); + \draw (E2) to (F2); }{% - \foreach \i in {1,...,4}{% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test\i) at (Q\i) {\ListeAutoQ[\i,1]};% + \foreach\i in{1,...,4}{% + \draw (C\i) to (D\i); + \draw (E\i) to (F\i); }% - \foreach \i in {5,...,8}{% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test\i) at (Q\i) {\ListeAutoQ[\i,1]};% + }% + \draw[dashed] (A1) to (B1);% + \draw[dashed] (A3) to (B3);% + }% + %\draw[dashed] (A1) to (B1);% + %\draw[dashed] (A3) to (B3);% + \ifboolKV[Autonomie]{ARemplir}{% + \ifboolKV[Autonomie]{Landscape}{% + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (O1) {\ListeAutoQ[1,1]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (O2) {\ListeAutoQ[2,1]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (O3) {\ListeAutoQ[3,1]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (O4) {\ListeAutoQ[4,1]}; + }{% + \ifboolKV[Autonomie]{Deux}{% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test1) at ($(Q1)!0.5!(Q2)$) {\ListeAutoQ[1,1]};% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test2) at ($(Q3)!0.5!(Q4)$) {\ListeAutoQ[2,1]};% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test3) at ($(Q5)!0.5!(Q6)$) {\ListeAutoQ[3,1]};% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test4) at ($(Q7)!0.5!(Q8)$) {\ListeAutoQ[4,1]};% + }{% + \foreach \i in {1,...,4}{% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test\i) at (Q\i) {\ListeAutoQ[\i,1]};% + }% + \foreach \i in {5,...,8}{% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] (Test\i) at (Q\i) {\ListeAutoQ[\i,1]};% + }% }% }% }{% @@ -6639,23 +8176,51 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \coordinate (V6) at ($(T6)!0.5!(U6)$);% \coordinate (V7) at ($(T7)!0.5!(U7)$);% \coordinate (V8) at ($(T8)!0.5!(U8)$);% - \draw[dashed] (A1) to (B1);% - \draw[dashed] (A2) to (B2);% - \draw[dashed] (A3) to (B3);% + \coordinate (W1) at ($(A3)!0.5!(E1)$); + \coordinate (W2) at ($(E1)!0.5!(E2)$); + \coordinate (W3) at ($(E2)!0.5!(E3)$); + \coordinate (W4) at ($(E3)!0.5!(E4)$); + \coordinate (W5) at ($(A1)!0.5!(D1)$); + \coordinate (W6) at ($(D1)!0.5!(D2)$); + \coordinate (W7) at ($(D2)!0.5!(D3)$); + \coordinate (W8) at ($(D3)!0.5!(D4)$); + \ifboolKV[Autonomie]{Landscape}{% + \draw[dashed] (C1) to (F1);% + \draw[dashed] (C3) to (F3); + \draw (A2) to (B2);% + }{% + \draw[dashed] (A1) to (B1);% + \draw[dashed] (A2) to (B2); + \draw[dashed] (A3) to (B3);% + }% + %\draw[dashed] (A1) to (B1);% + %\draw[dashed] (A2) to (B2);% + %\draw[dashed] (A3) to (B3);% \ifboolKV[Autonomie]{ARemplir}{% - \ifboolKV[Autonomie]{Deux}{% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(V1)!0.5!(V2)$) {\ListeAutoEn[1,1]};% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(V3)!0.5!(V4)$) {\ListeAutoEn[2,1]};% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(V5)!0.5!(V6)$) {\ListeAutoEn[3,1]};% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(V7)!0.5!(V8)$) {\ListeAutoEn[4,1]};% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(R1)!0.5!(R2)$) {\ListeAutoQ[1,2]};%% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(R3)!0.5!(R4)$) {\ListeAutoQ[2,2]};%% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(R5)!0.5!(R6)$) {\ListeAutoQ[3,2]};%% - \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(R7)!0.5!(R8)$) {\ListeAutoQ[4,2]};%% + \ifboolKV[Autonomie]{Landscape}{% + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (W2) {\ListeAutoEn[4,1]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (W4) {\ListeAutoEn[3,1]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (W6) {\ListeAutoEn[2,1]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (W8) {\ListeAutoEn[1,1]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (W1) {\ListeAutoQ[4,2]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (W3) {\ListeAutoQ[3,2]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (W5) {\ListeAutoQ[2,2]}; + \node[align=justify,anchor=center,text width=0.9*0.5\textwidth] at (W7) {\ListeAutoQ[1,2]}; }{% - \foreach \i in {1,...,8}{% - \node[text width=0.9*0.25\paperwidth] at (V\i) {\ListeAutoQ[\i,2]};% - \node[text width=0.9*0.25\paperwidth] at (R\i) {\ListeAutoEn[\i,1]};% + \ifboolKV[Autonomie]{Deux}{% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(V1)!0.5!(V2)$) {\ListeAutoEn[1,1]};% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(V3)!0.5!(V4)$) {\ListeAutoEn[2,1]};% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(V5)!0.5!(V6)$) {\ListeAutoEn[3,1]};% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(V7)!0.5!(V8)$) {\ListeAutoEn[4,1]};% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(R1)!0.5!(R2)$) {\ListeAutoQ[1,2]};%% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(R3)!0.5!(R4)$) {\ListeAutoQ[2,2]};%% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(R5)!0.5!(R6)$) {\ListeAutoQ[3,2]};%% + \node[align=justify,anchor=center,text width=0.9*0.25\textwidth] at ($(R7)!0.5!(R8)$) {\ListeAutoQ[4,2]};%% + }{% + \foreach \i in {1,...,8}{% + \node[text width=0.9*0.25\paperwidth] at (V\i) {\ListeAutoQ[\i,2]};% + \node[text width=0.9*0.25\paperwidth] at (R\i) {\ListeAutoEn[\i,1]};% + }% }% }% }{% @@ -9041,7 +10606,7 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. %%% % Le th\'eor\`eme de Pythagore %%% -\setKVdefault[ClesPythagore]{Exact=false,AvantRacine=false,Racine=false,Entier=false,Egalite=false,Precision=2,Soustraction=false,Figure=false,FigureSeule=false,Angle=0,Echelle=1cm,Reciproque=false,ReciColonnes=false,Faible=false,Unite=cm,EnchaineA=false,EnchaineB=false,EnchaineC=false,ValeurA=0,ValeurB=0,ValeurC=0,Perso=false,AllPerso=false} +\setKVdefault[ClesPythagore]{Exact=false,AvantRacine=false,Racine=false,Entier=false,Egalite=false,Precision=2,Soustraction=false,Figure=false,FigureSeule=false,Angle=0,Echelle=1cm,Reciproque=false,ReciColonnes=false,Faible=false,Unite=cm,EnchaineA=false,EnchaineB=false,EnchaineC=false,ValeurA=0,ValeurB=0,ValeurC=0,Perso=false,AllPerso=false,SansMots=false} % On d\'efinit les figures \`a utiliser \def\MPFigurePytha#1#2#3#4#5#6{% @@ -9222,13 +10787,96 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \fi } +\def\MPFigurePythaSansMots#1#2#3#4#5#6{% + % #1 Premier sommet + % #2 Sommet de l'angle droit + % #3 troisi\`eme sommet + % #4 1ere longueur + % #5 2eme longueur + % #6 angle de rotation de la figure + \ifluatex + \mplibforcehmode + \begin{mplibcode} + u:=\useKV[ClesPythagore]{Echelle}; + pair A,B,C,O,D,E,F,L[],M[],N[];%B est le sommet de l'angle droit + O=u*(2.5,2.5); + path cc; + cc=(fullcircle scaled 4u) shifted O; + % On place les points A,B,C sur le cercle de mani\`ere \`a faciliter la rotation de la figure + A=point(0.9*length cc) of cc; + B=A rotatedabout(O,-120); + C=2[A,O]; + % On tourne pour \'eventuellement moins de lassitude :) + A:=A rotatedabout(O,#6); + B:=B rotatedabout(O,#6); + C:=C rotatedabout(O,#6); + % On d\'efinit l'angle droit + D-B=7*unitvector(C-B); + F-B=7*unitvector(A-B); + E-D=F-B; + trace polygone(A,B,C); + draw D--E--F; + L1=rotation(B,A,90); + L2-L1=B-A; + trace chemin(A,L1,L2,B); + M1=rotation(C,B,90); + M2-M1=C-B; + trace chemin(B,M1,M2,C); + N1=rotation(A,C,90); + N2-N1=A-C; + trace chemin(C,N1,N2,A); + numeric decalage; + decalage=3mm; + if (#4<#5) or (#4=#5) : + if ypart(B)>ypart(O) : + label(btex \num{#4} etex,1/2[C,B]+decalage*(unitvector(A-B))); + label(btex \num{#5} etex,1/2[A,B]+decalage*(unitvector(C-B))); + label(TEX("\begin{tabular}{c}Aire\\$\num{#5}\times\num{#5}$\\$\num{\fpeval{#5*#5}}$\\\end{tabular}"),iso(A,L2)); + label(TEX("\begin{tabular}{c}Aire\\$\num{#4}\times\num{#4}$\\$\num{\fpeval{#4*#4}}$\\\end{tabular}"),iso(B,M2)); + label(TEX("\begin{tabular}{c}Aire\\$\num{\fpeval{#4*#4}}+\num{\fpeval{#5*#5}}$\\$\num{\fpeval{#4*#4+#5*#5}}$\\\end{tabular}"),iso(C,N2)); + else: + label(btex \num{#4} etex,1/2[C,B]+decalage*(unitvector(A-B))); + label(btex \num{#5} etex,1/2[A,B]+decalage*(unitvector(C-B))); + label(TEX("\begin{tabular}{c}Aire\\$\num{#5}\times\num{#5}$\\$\num{\fpeval{#5*#5}}$\\\end{tabular}"),iso(A,L2)); + label(TEX("\begin{tabular}{c}Aire\\$\num{#4}\times\num{#4}$\\$\num{\fpeval{#4*#4}}$\\\end{tabular}"),iso(B,M2)); + label(TEX("\begin{tabular}{c}Aire\\$\num{\fpeval{#4*#4}}+\num{\fpeval{#5*#5}}$\\$\num{\fpeval{#4*#4+#5*#5}}$\\\end{tabular}"),iso(C,N2)); + drawarrow 2/10[iso(A,L2),iso(C,N2)]--8/10[iso(A,L2),iso(C,N2)]; + drawarrow 2/10[iso(B,M2),iso(C,N2)]--8/10[iso(B,M2),iso(C,N2)]; + fi + else: + if ypart(B)>ypart(O) : + label(btex \num{#4} etex,1/2[C,A]-decalage*(unitvector(C-A) rotated 90)); + label(btex \num{#5} etex,1/2[A,B]-decalage*(unitvector(C-B))); + label(TEX("\begin{tabular}{c}Aire\\$\num{#5}\times\num{#5}$\\$\num{\fpeval{#5*#5}}$\\\end{tabular}"),iso(A,L2)); + label(TEX("\begin{tabular}{c}Aire\\$\num{#4}\times\num{#4}$\\$\num{\fpeval{#4*#4}}$\\\end{tabular}"),iso(C,N2)); + label(TEX("\begin{tabular}{c}Aire\\$\num{\fpeval{#4*#4}}-\num{\fpeval{#5*#5}}$\\$\num{\fpeval{#4*#4-#5*#5}}$\\\end{tabular}"),iso(B,M2)); + drawarrow 2/10[iso(A,L2),iso(B,M2)]--8/10[iso(A,L2),iso(B,M2)]; + drawarrow 2/10[iso(C,N2),iso(B,M2)]--8/10[iso(C,N2),iso(B,M2)]; + else: + label(btex \num{#4} etex,1/2[A,C]+decalage*(unitvector(A-C) rotated 90)); + label(btex \num{#5} etex,1/2[A,B]-decalage*(unitvector(C-B))); + label(TEX("\begin{tabular}{c}Aire\\$\num{#5}\times\num{#5}$\\$\num{\fpeval{#5*#5}}$\\\end{tabular}"),iso(A,L2)); + label(TEX("\begin{tabular}{c}Aire\\$\num{#4}\times\num{#4}$\\$\num{\fpeval{#4*#4}}$\\\end{tabular}"),iso(C,N2)); + label(TEX("\begin{tabular}{c}Aire\\$\num{\fpeval{#4*#4}}-\num{\fpeval{#5*#5}}$\\$\num{\fpeval{#4*#4-#5*#5}}$\\\end{tabular}"),iso(B,M2)); + drawarrow 2/10[iso(A,L2),iso(B,M2)]--8/10[iso(A,L2),iso(B,M2)]; + drawarrow 2/10[iso(C,N2),iso(B,M2)]--8/10[iso(C,N2),iso(B,M2)]; + fi; + fi; + label(btex #3 etex,1.2[O,A]); + label(btex #2 etex,1.2[O,B]); + label(btex #1 etex,1.2[O,C]); + \end{mplibcode} + \fi +} + \newcommand\RedactionPythagore{}% \newcommand\RedactionReciPythagore{}% \newcommand\RedactionCalculsPythagore{}% \newcommand\RedactionCalculsReciPythagore{}% \newcommand\RedactionConclusionReciPythagore{}% -\newcommand\Pythagore[5][]{% +% \newcommand\Pythagore[5][]{% +\NewDocumentCommand\Pythagore{o m m m m}{% % #1 Param\`etres sous forme de cl\'es % #2 Nom "complet" du triangle : ABC par exemple % #3 Premi\`ere longueur @@ -9417,51 +11065,55 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \end{multicols} }{% % On d\'emarre la r\'esolution - \ifboolKV[ClesPythagore]{AllPerso}{% - \RedactionPythagore% - \RedactionCalculsPythagore% + \ifboolKV[ClesPythagore]{SansMots}{% + \MPFigurePythaSansMots{\NomA}{\NomB}{\NomC}{#3}{#4}{\useKV[ClesPythagore]{Angle}} }{% - \ifboolKV[ClesPythagore]{Perso}{\RedactionPythagore}{\ifboolKV[ClesPythagore]{Egalite}{Comme le triangle $#2$ est rectangle en $\NomB$, alors l'\'egalit\'e de Pythagore est v\'erifi\'ee :}{Dans le triangle $#2$ rectangle en $\NomB$, le th\'eor\`eme de Pythagore permet d'\'ecrire :% - }}% - \xintifboolexpr{#3<#4 || #3==#4}{%\ifnum#3<#4% - \xdef\ResultatPytha{\fpeval{round(sqrt(#3^2+#4^2),\useKV[ClesPythagore]{Precision})}}% - \begin{align*} - \NomA\NomC^2&=\NomA\NomB^2+\NomB\NomC^2\\ - \NomA\NomC^2&=\ifboolKV[ClesPythagore]{EnchaineA}{\opcopy{\useKV[ClesPythagore]{ValeurA}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opexport{A1}{\Aun}\num{\Aun}^2}+\ifboolKV[ClesPythagore]{EnchaineB}{\opcopy{\useKV[ClesPythagore]{ValeurB}}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}{\opexport{A2}{\Adeux}\num{\Adeux}^2}\\ - \NomA\NomC^2&=\ifboolKV[ClesPythagore]{EnchaineA}{\opexport{a1}{\Aun}\num{\Aun}}{\opmul*{A1}{A1}{a1}\opexport{a1}{\Aun}\num{\Aun}}+\ifboolKV[ClesPythagore]{EnchaineB}{\opexport{a2}{\Adeux}\num{\Adeux}}{\opmul*{A2}{A2}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}\\ - \NomA\NomC^2&=\opadd*{a1}{a2}{a3}\opexport{a3}{\Atrois}\num{\Atrois}%\\ - \ifboolKV[ClesPythagore]{AvantRacine}{}{% - \ifboolKV[ClesPythagore]{Entier}{}{\\\NomA\NomC&=\sqrt{\opexport{a3}{\Atrois}\num{\Atrois}}} - \ifboolKV[ClesPythagore]{Racine}{}{\\\ifboolKV[ClesPythagore]{Exact}{\NomA\NomC&=\opsqrt[maxdivstep=3]{a3}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}{\NomA\NomC&\approx\opsqrt[maxdivstep=5]{a3}{a4}\opround{a4}{pres}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}}%\\ - } - \end{align*} - }{%\else - \xdef\ResultatPytha{\fpeval{round(sqrt(#3^2-#4^2),\useKV[ClesPythagore]{Precision})}}% - \ifboolKV[ClesPythagore]{Soustraction}{% - \begin{align*} - \NomA\NomB^2&=\NomA\NomC^2-\NomB\NomC^2\\ - \NomA\NomB^2&=\ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opexport{A1}{\Aun}\num{\Aun}^2}-\ifboolKV[ClesPythagore]{EnchaineB}{\opcopy{\useKV[ClesPythagore]{ValeurB}}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}{\opexport{A2}{\Adeux}\num{\Adeux}^2}\\ - \NomA\NomB^2&=\ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opmul*{A1}{A1}{a1}\opexport{a1}{\Aun}\num{\Aun}}-\ifboolKV[ClesPythagore]{EnchaineB}{\opexport{a2}{\Adeux}\num{\Adeux}}{\opmul*{A2}{A2}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}\\ - \NomA\NomB^2&=\opsub*{a1}{a2}{a3}\opexport{a3}{\Atrois}\num{\Atrois}%\\ - \ifboolKV[ClesPythagore]{AvantRacine}{}{% - \ifboolKV[ClesPythagore]{Entier}{}{\\\NomA\NomB&=\sqrt{\opexport{a3}{\Atrois}\num{\Atrois}}} - \ifboolKV[ClesPythagore]{Racine}{}{\\\ifboolKV[ClesPythagore]{Exact}{\NomA\NomB&=\opsqrt[maxdivstep=3]{a3}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}{\NomA\NomB&\approx\opsqrt[maxdivstep=5]{a3}{a4}\opround{a4}{pres}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}}%\\ - } - \end{align*} - }{% + \ifboolKV[ClesPythagore]{AllPerso}{% + \RedactionPythagore% + \RedactionCalculsPythagore% + }{% + \ifboolKV[ClesPythagore]{Perso}{\RedactionPythagore}{\ifboolKV[ClesPythagore]{Egalite}{Comme le triangle $#2$ est rectangle en $\NomB$, alors l'\'egalit\'e de Pythagore est v\'erifi\'ee :}{Dans le triangle $#2$ rectangle en $\NomB$, le th\'eor\`eme de Pythagore permet d'\'ecrire :% + }}% + \xintifboolexpr{#3<#4 || #3==#4}{%\ifnum#3<#4% + \xdef\ResultatPytha{\fpeval{round(sqrt(#3^2+#4^2),\useKV[ClesPythagore]{Precision})}}% \begin{align*} \NomA\NomC^2&=\NomA\NomB^2+\NomB\NomC^2\\ - \ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opexport{A1}{\Aun}\num{\Aun}^2}&=\NomA\NomB^2+\ifboolKV[ClesPythagore]{EnchaineB}{\opcopy{\useKV[ClesPythagore]{ValeurB}}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}{\opexport{A2}{\Adeux}\num{\Adeux}^2}\\ - \ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opmul*{A1}{A1}{a1}\opexport{a1}{\Aun}\num{\Aun}}&=\NomA\NomB^2+\ifboolKV[ClesPythagore]{EnchaineB}{\opexport{a2}{\Adeux}\num{\Adeux}}{\opmul*{A2}{A2}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}\\ - \NomA\NomB^2&=\ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opmul*{A1}{A1}{a1}\opexport{a1}{\Aun}\num{\Aun}}-\ifboolKV[ClesPythagore]{EnchaineB}{\opexport{a2}{\Adeux}\num{\Adeux}}{\opmul*{A2}{A2}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}\\ - \NomA\NomB^2&=\opsub*{a1}{a2}{a3}\opexport{a3}{\Atrois}\num{\Atrois}%\\ + \NomA\NomC^2&=\ifboolKV[ClesPythagore]{EnchaineA}{\opcopy{\useKV[ClesPythagore]{ValeurA}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opexport{A1}{\Aun}\num{\Aun}^2}+\ifboolKV[ClesPythagore]{EnchaineB}{\opcopy{\useKV[ClesPythagore]{ValeurB}}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}{\opexport{A2}{\Adeux}\num{\Adeux}^2}\\ + \NomA\NomC^2&=\ifboolKV[ClesPythagore]{EnchaineA}{\opexport{a1}{\Aun}\num{\Aun}}{\opmul*{A1}{A1}{a1}\opexport{a1}{\Aun}\num{\Aun}}+\ifboolKV[ClesPythagore]{EnchaineB}{\opexport{a2}{\Adeux}\num{\Adeux}}{\opmul*{A2}{A2}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}\\ + \NomA\NomC^2&=\opadd*{a1}{a2}{a3}\opexport{a3}{\Atrois}\num{\Atrois}%\\ \ifboolKV[ClesPythagore]{AvantRacine}{}{% - \ifboolKV[ClesPythagore]{Entier}{}{\\\NomA\NomB&=\sqrt{\opexport{a3}{\Atrois}\num{\Atrois}}}% - \ifboolKV[ClesPythagore]{Racine}{}{\\\ifboolKV[ClesPythagore]{Exact}{\NomA\NomB&=\opsqrt[maxdivstep=3]{a3}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}{\NomA\NomB&\approx\opsqrt[maxdivstep=5]{a3}{a4}\opround{a4}{pres}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}}%\\ + \ifboolKV[ClesPythagore]{Entier}{}{\\\NomA\NomC&=\sqrt{\opexport{a3}{\Atrois}\num{\Atrois}}} + \ifboolKV[ClesPythagore]{Racine}{}{\\\ifboolKV[ClesPythagore]{Exact}{\NomA\NomC&=\opsqrt[maxdivstep=3]{a3}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}{\NomA\NomC&\approx\opsqrt[maxdivstep=5]{a3}{a4}\opround{a4}{pres}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}}%\\ } \end{align*} - }% - }%\fi% + }{%\else + \xdef\ResultatPytha{\fpeval{round(sqrt(#3^2-#4^2),\useKV[ClesPythagore]{Precision})}}% + \ifboolKV[ClesPythagore]{Soustraction}{% + \begin{align*} + \NomA\NomB^2&=\NomA\NomC^2-\NomB\NomC^2\\ + \NomA\NomB^2&=\ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opexport{A1}{\Aun}\num{\Aun}^2}-\ifboolKV[ClesPythagore]{EnchaineB}{\opcopy{\useKV[ClesPythagore]{ValeurB}}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}{\opexport{A2}{\Adeux}\num{\Adeux}^2}\\ + \NomA\NomB^2&=\ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opmul*{A1}{A1}{a1}\opexport{a1}{\Aun}\num{\Aun}}-\ifboolKV[ClesPythagore]{EnchaineB}{\opexport{a2}{\Adeux}\num{\Adeux}}{\opmul*{A2}{A2}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}\\ + \NomA\NomB^2&=\opsub*{a1}{a2}{a3}\opexport{a3}{\Atrois}\num{\Atrois}%\\ + \ifboolKV[ClesPythagore]{AvantRacine}{}{% + \ifboolKV[ClesPythagore]{Entier}{}{\\\NomA\NomB&=\sqrt{\opexport{a3}{\Atrois}\num{\Atrois}}} + \ifboolKV[ClesPythagore]{Racine}{}{\\\ifboolKV[ClesPythagore]{Exact}{\NomA\NomB&=\opsqrt[maxdivstep=3]{a3}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}{\NomA\NomB&\approx\opsqrt[maxdivstep=5]{a3}{a4}\opround{a4}{pres}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}}%\\ + } + \end{align*} + }{% + \begin{align*} + \NomA\NomC^2&=\NomA\NomB^2+\NomB\NomC^2\\ + \ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opexport{A1}{\Aun}\num{\Aun}^2}&=\NomA\NomB^2+\ifboolKV[ClesPythagore]{EnchaineB}{\opcopy{\useKV[ClesPythagore]{ValeurB}}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}{\opexport{A2}{\Adeux}\num{\Adeux}^2}\\ + \ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opmul*{A1}{A1}{a1}\opexport{a1}{\Aun}\num{\Aun}}&=\NomA\NomB^2+\ifboolKV[ClesPythagore]{EnchaineB}{\opexport{a2}{\Adeux}\num{\Adeux}}{\opmul*{A2}{A2}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}\\ + \NomA\NomB^2&=\ifboolKV[ClesPythagore]{EnchaineC}{\opcopy{\useKV[ClesPythagore]{ValeurC}}{a1}\opexport{a1}{\Aun}\num{\Aun}}{\opmul*{A1}{A1}{a1}\opexport{a1}{\Aun}\num{\Aun}}-\ifboolKV[ClesPythagore]{EnchaineB}{\opexport{a2}{\Adeux}\num{\Adeux}}{\opmul*{A2}{A2}{a2}\opexport{a2}{\Adeux}\num{\Adeux}}\\ + \NomA\NomB^2&=\opsub*{a1}{a2}{a3}\opexport{a3}{\Atrois}\num{\Atrois}%\\ + \ifboolKV[ClesPythagore]{AvantRacine}{}{% + \ifboolKV[ClesPythagore]{Entier}{}{\\\NomA\NomB&=\sqrt{\opexport{a3}{\Atrois}\num{\Atrois}}}% + \ifboolKV[ClesPythagore]{Racine}{}{\\\ifboolKV[ClesPythagore]{Exact}{\NomA\NomB&=\opsqrt[maxdivstep=3]{a3}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}{\NomA\NomB&\approx\opsqrt[maxdivstep=5]{a3}{a4}\opround{a4}{pres}{a4}\opunzero{a4}\opexport{a4}{\Aquatre}\SI{\Aquatre}{\PfCPythaUnit}}}%\\ + } + \end{align*} + }% + }%\fi% + }% }% }% }% @@ -11449,7 +13101,9 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \ppcm=\numexpr#1*#2/\pgcd\relax% }% -\setKVdefault[ClesThales]{Calcul=true,Droites=false,Propor=false,Segment=false,Figure=false,FigureSeule=false,Figurecroisee=false,FigurecroiseeSeule=false,Angle=0,Precision=2,Entier=false,Unite=cm,Reciproque=false,Produit=false,ChoixCalcul=0,Simplification,Redaction=false,Remediation=false,Echelle=1cm,Perso=false,CalculsPerso=false,IntroCalculs} +\setKVdefault[ClesThales]{Calcul=true,Droites=false,Propor=false,Segment=false,Figure=false,FigureSeule=false,Figurecroisee=false,FigurecroiseeSeule=false,Angle=0,Precision=2,Entier=false,Unite=cm,Reciproque=false,Produit=false,ChoixCalcul=0,Simplification,Redaction=false,Remediation=false,Echelle=1cm,Perso=false,CalculsPerso=false,IntroCalculs,CouleursNum=false,CouleursDen=false} +\defKV[ClesThales]{CouleurNum=\setKV[ClesThales]{CouleursNum}} +\defKV[ClesThales]{CouleurDen=\setKV[ClesThales]{CouleursDen}} \DeclareSIUnit{\PfCThalesUnit}{\useKV[ClesThales]{Unite}}% @@ -11466,6 +13120,20 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \mplibforcehmode \begin{mplibcode} u:=\useKV[ClesThales]{Echelle}; + boolean CouleursNum,CouleursDen; + CouleursNum=\useKV[ClesThales]{CouleursNum}; + CouleursDen=\useKV[ClesThales]{CouleursDen}; + color CouleurNum,CouleurDen; + if CouleursNum: + CouleurNum=\useKV[ClesThales]{CouleurNum} + else: + CouleurNum=black + fi; + if CouleursDen: + CouleurDen=\useKV[ClesThales]{CouleurDen} + else: + CouleurDen=black + fi; pair A,B,C,M,N,O;% %On place les points A,B,C sur le cercle de mani\`ere \`a faciliter la rotation de la figure A=u*(1,1); @@ -11490,6 +13158,14 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. triangle=cotes1--cotes2--cotes3--cycle; draw triangle; draw cotes4; + if CouleursDen: + draw triangle dashed evenly withpen pencircle scaled 1.5 withcolor CouleurDen; + fi; + if CouleursNum: + draw (cotes1 cutafter cotes4) dashed dashpattern(off 3 on 3) withpen pencircle scaled 1.5 withcolor CouleurNum; + draw (cotes4 cutbefore cotes1 cutafter cotes3) dashed dashpattern(off 3 on 3) withpen pencircle scaled 1.5 withcolor CouleurNum; + draw (cotes3 cutbefore cotes4) dashed dashpattern(off 3 on 3) withpen pencircle scaled 1.5 withcolor CouleurNum; + fi; %on labelise label(btex #1 etex,1.15[O,A]); label(btex #2 etex,1.15[O,B]); @@ -11513,7 +13189,20 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \end{mplibcode} % \mplibcodeinherit{disable} \else - \begin{mpost}[mpsettings={u:=\useKV[ClesThales]{Echelle};}] + \begin{mpost}[mpsettings={u:=\useKV[ClesThales]{Echelle};boolean CouleursNum,CouleursDen; + CouleursNum=\useKV[ClesThales]{CouleursNum}; + CouleursDen=\useKV[ClesThales]{CouleursDen}; + color CouleurNum,CouleurDen; + if CouleursNum: + CouleurNum=\useKV[ClesThales]{CouleurNum} + else: + CouleurNum=black + fi; + if CouleursDen: + CouleurDen=\useKV[ClesThales]{CouleurDen} + else: + CouleurDen=black + fi;}] pair A,B,C,M,N,O;% %On place les points A,B,C sur le cercle de mani\`ere \`a faciliter la rotation de la figure A=u*(1,1); @@ -11538,6 +13227,14 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. triangle=cotes1--cotes2--cotes3--cycle; draw triangle; draw cotes4; + if CouleursDen: + draw triangle dashed evenly withpen pencircle scaled 1.5 withcolor CouleurDen; + fi; + if CouleursNum: + draw (cotes1 cutafter cotes4) dashed dashpattern(off 3 on 3) withpen pencircle scaled 1.5 withcolor CouleurNum; + draw (cotes4 cutbefore cotes1 cutafter cotes3) dashed dashpattern(off 3 on 3) withpen pencircle scaled 1.5 withcolor CouleurNum; + draw (cotes3 cutbefore cotes4) dashed dashpattern(off 3 on 3) withpen pencircle scaled 1.5 withcolor CouleurNum; + fi; %on labelise label(btex #1 etex,1.15[O,A]); label(btex #2 etex,1.15[O,B]); @@ -11658,6 +13355,20 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \mplibcodeinherit{enable} \begin{mplibcode} u:=\useKV[ClesThales]{Echelle}; + boolean CouleursNum,CouleursDen; + CouleursNum=\useKV[ClesThales]{CouleursNum}; + CouleursDen=\useKV[ClesThales]{CouleursDen}; + color CouleurNum,CouleurDen; + if CouleursNum: + CouleurNum=\useKV[ClesThales]{CouleurNum} + else: + CouleurNum=black + fi; + if CouleursDen: + CouleurDen=\useKV[ClesThales]{CouleurDen} + else: + CouleurDen=black + fi; pair A,B,C,M,N,O;% O=(2.5u,2.5u); path cc; @@ -11683,6 +13394,20 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. for k=1 upto 6: draw cotes[k]; endfor; + if CouleursDen: + drawoptions(dashed evenly withpen pencircle scaled 1.5 withcolor CouleurDen); + draw (cotes[1] cutafter cotes[2]); + draw (cotes[2] cutbefore cotes[1] cutafter cotes[3]); + draw (cotes[3] cutbefore cotes[2]); + drawoptions(); + fi; + if CouleursNum: + drawoptions(dashed evenly withpen pencircle scaled 1.5 withcolor CouleurNum); + draw (cotes[5] cutafter cotes[4]); + draw (cotes[4] cutbefore cotes[5] cutafter cotes[6]); + draw (cotes[6] cutafter cotes[4]); + drawoptions(); + fi; pair I; % On d\'efinit le centre du cercle inscrit \`a AMC (I-C) rotated ((angle(A-C)-angle(M-C))/2) shifted C=whatever[A,C]; @@ -11710,7 +13435,20 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. \end{mplibcode} \mplibcodeinherit{disable} \else - \begin{mpost}[mpsettings={u:=\useKV[ClesThales]{Echelle};}] + \begin{mpost}[mpsettings={u:=\useKV[ClesThales]{Echelle};boolean CouleursNum,CouleursDen; + CouleursNum=\useKV[ClesThales]{CouleursNum}; + CouleursDen=\useKV[ClesThales]{CouleursDen}; + color CouleurNum,CouleurDen; + if CouleursNum: + CouleurNum=\useKV[ClesThales]{CouleurNum} + else: + CouleurNum=black + fi; + if CouleursDen: + CouleurDen=\useKV[ClesThales]{CouleurDen} + else: + CouleurDen=black + fi;}] pair A,B,C,M,N,O;% O=(2.5u,2.5u); path cc; @@ -11736,6 +13474,20 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. for k=1 upto 6: draw cotes[k]; endfor; + if CouleursDen: + drawoptions(dashed evenly withpen pencircle scaled 1.5 withcolor CouleurDen); + draw (cotes[1] cutafter cotes[2]); + draw (cotes[2] cutbefore cotes[1] cutafter cotes[3]); + draw (cotes[3] cutbefore cotes[2]); + drawoptions(); + fi; + if CouleursNum: + drawoptions(dashed evenly withpen pencircle scaled 1.5 withcolor CouleurNum); + draw (cotes[5] cutafter cotes[4]); + draw (cotes[4] cutbefore cotes[5] cutafter cotes[6]); + draw (cotes[6] cutafter cotes[4]); + drawoptions(); + fi; pair I; % On d\'efinit le centre du cercle inscrit \`a AMC (I-C) rotated ((angle(A-C)-angle(M-C))/2) shifted C=whatever[A,C]; @@ -11891,7 +13643,7 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. est un tableau de proportionnalit\'e\ifboolKV[ClesThales]{Segment}{.}{ d'apr\`es le th\'eor\`eme de Thal\`es.}% }{% \ifboolKV[ClesThales]{Segment}{on a :}{le th\'eor\`eme de Thal\`es permet d'\'ecrire :}% - \[\frac{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{#2#5}}{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{#2#3}}=\frac{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{#2#6}}{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{#2#4}}=\frac{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{#5#6}}{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{#3#4}}\]% + \[\frac{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{\ifboolKV[ClesThales]{CouleursNum}{\mathcolor{\useKV[ClesThales]{CouleurNum}}{#2#5}}{#2#5}}}{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{\ifboolKV[ClesThales]{CouleursDen}{\mathcolor{\useKV[ClesThales]{CouleurDen}}{#2#3}}{#2#3}}}=\frac{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{\ifboolKV[ClesThales]{CouleursNum}{\mathcolor{\useKV[ClesThales]{CouleurNum}}{#2#6}}{#2#6}}}{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{\ifboolKV[ClesThales]{CouleursDen}{\mathcolor{\useKV[ClesThales]{CouleurDen}}{#2#4}}{#2#4}}}=\frac{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{\ifboolKV[ClesThales]{CouleursNum}{\mathcolor{\useKV[ClesThales]{CouleurNum}}{#5#6}}{#5#6}}}{\ifboolKV[ClesThales]{Remediation}{\pointilles[1cm]}{\ifboolKV[ClesThales]{CouleursDen}{\mathcolor{\useKV[ClesThales]{CouleurDen}}{#3#4}}{#3#4}}}\]% }% }% }% @@ -13337,7 +15089,7 @@ couleur indiquée, le nombre de cases donné par le résultat du calcul. %%% % Statistiques %%% -\newcommand\NbDonnees{} +\newcommand\NbDonnees{}% \newcommand\SommeDonnees{}% \newcommand\EffectifTotal{}% \newcommand\Moyenne{}% @@ -13360,16 +15112,16 @@ Rayon=3cm,AffichageAngle=false,AffichageDonnee=false,ListeCouleurs={white},Hachu Representation=false,% %Pour les barres horizontales Barre=false,Longueur=10cm,Hauteur=5mm,Bicolore=false,EcartBarre=0%Grille est dispo -} +}% %compl\'ements \defKV[ClesStat]{AngleRotationAbscisse=\setKV[ClesStat]{AbscisseRotation}}% \defKV[ClesStat]{AffichageDonnees=\setKV[ClesStat]{AffichageAngle=false}\setKV[ClesStat]{AffichageDonnee}}% \defKV[ClesStat]{CasesVides=\setKV[ClesStat]{CaseVide}}% \defKV[ClesStat]{LegendesVides=\setKV[ClesStat]{LegendeVide}}% % La construction du tableau -\def\addtotok#1#2{#1\expandafter{\the#1#2}} -\newtoks\tabtoksa\newtoks\tabtoksb\newtoks\tabtoksc -\def\updatetoks#1/#2\nil{\addtotok\tabtoksa{\ifboolKV[ClesStat]{Qualitatif}{}{&\num{#1}}}\addtotok\tabtoksb{&\num{#2}}} +\def\addtotok#1#2{#1\expandafter{\the#1#2}}% +\newtoks\tabtoksa\newtoks\tabtoksb\newtoks\tabtoksc% +\def\updatetoks#1/#2\nil{\addtotok\tabtoksa{\ifboolKV[ClesStat]{Qualitatif}{}{&\num{#1}}}\addtotok\tabtoksb{&\num{#2}}}% % \newcounter{PfCCompteLignes}% % @@ -15109,8 +16861,8 @@ Barre=false,Longueur=10cm,Hauteur=5mm,Bicolore=false,EcartBarre=0%Grille est dis trace pointarc(cc,N[1]) for l=2 upto n: --pointarc(cc,N[l]) endfor --cycle; % etiquettage des pas - dotlabel.urt(btex \tiny #4 etex,pointarc(cc,0)); - dotlabel.urt(btex \tiny #3 etex,(1/pas)[O,pointarc(cc,0)]); + dotlabel.urt(TEX("\tiny"&decimal(#4)),pointarc(cc,0)); + dotlabel.urt(TEX("\tiny"&decimal(#3)),(1/pas)[O,pointarc(cc,0)]); % trac\'e des r\'esultats \'el\`eves pair El[]; el=0; @@ -15225,8 +16977,8 @@ Barre=false,Longueur=10cm,Hauteur=5mm,Bicolore=false,EcartBarre=0%Grille est dis \useKVdefault[ClesBarre]% \setKV[ClesBarre]{#1}% \xdef\NomComp{\useKV[ClesBarre]{Nom}}% - \xdef\TexteOrigine{\useKV[ClesBarre]{Origine}}% - \xdef\TexteReference{\useKV[ClesBarre]{Reference}}% + \def\TexteOrigine{\useKV[ClesBarre]{TexteOrigine}}% + \def\TexteReference{\useKV[ClesBarre]{TexteReference}}% \xdef\CouleurFond{\useKV[ClesBarre]{CouleurFond}}% \xdef\CouleurGrad{\useKV[ClesBarre]{CouleurGraduation}}% \xdef\CouleurBarre{\useKV[ClesBarre]{CouleurBarre}}% @@ -24317,7 +26069,7 @@ label.lft(LATEX("\noexpand\footnotesize\noexpand\SI{\noexpand\fpeval{"&decimal(V \else% \NewDocumentEnvironment{Scratch}{o +b}{% \setKV[Scratch]{#1}% - \begin{mpost}[mpsettings={boolean Naturel;Naturel=\useKV[Scratch]{Naturel};if Naturel: input PfCPseudo; print:=true; else: input PfCScratch; print:=\useKV[Scratch]{Impression}; fi;NumeroteLignes:=\useKV[Scratch]{Numerotation};Echelle:=\useKV[Scratch]{Echelle};}]% + \begin{mpost}[mpsettings={boolean Naturel;Naturel=\useKV[Scratch]{Naturel};if Naturel: input PfCPseudo; print:=true; else: input PfCScratchpdf; print:=\useKV[Scratch]{Impression}; fi;NumeroteLignes:=\useKV[Scratch]{Numerotation};Echelle:=\useKV[Scratch]{Echelle};}]% #2% picture recap;% recap:=currentpicture scaled Echelle;% |