1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
%%%%
% Prog de calculs "simples"
%%%%
\setKVdefault[ClesProg]{%
Ecart=2em,%
Direct,%
SansCalcul=false,%
Application=false,
Details=false,
Enonce=false,
Nom={},
CouleurCadre=black,%
CouleurFond=gray!10,%
Largeur={.95\linewidth},%
Epaisseur=.75pt,%
Pointilles=0,
ThemePerso=false,
}
\newcounter{NBprog}%
\setcounter{NBprog}{0}%
\newlength{\PointillesClesProg}%
\newcommand\ProgCalcul[2][]{%
% #1 : cl\'es
% #2 : \'etapes
\useKVdefault[ClesProg]%
\setKV[ClesProg]{#1}%
\ifboolKV[ClesProg]{ThemePerso}{}{%
\tcbset{ProgCalcul/.style={%
boxsep=1mm,
bottom=.75mm,
middle=2mm,
boxrule={\useKV[ClesProg]{Epaisseur}},
text width={\useKV[ClesProg]{Largeur}},
colframe={\useKV[ClesProg]{CouleurCadre}},
colback={\useKV[ClesProg]{CouleurFond}},
halign upper=center
}%
}%
}%
\ifboolKV[ClesProg]{Application}{%
% % by Thomas Dehon and cp
\setsepchar[*]{§*,}
% \setsepchar[*]{,* }%
\ignoreemptyitems%
\readlist*\ListeTotale{#2}%
\xdef\PfCPCfoo{\ListeTotale[1]}%
\xdef\PfCPCfaa{\ListeTotale[2]}%
%%
\setsepchar{,}% \ignoreemptyitems%
\readlist*\ListeEtapes{\PfCPCfoo}%
\setsepchar[*]{,* }\ignoreemptyitems%
\readlist*\ListeProg{\PfCPCfaa}%
\begin{tcolorbox}[%
ProgCalcul,%
]
\ifthenelse{\equal{\useKV[ClesProg]{Nom}}{}}%
{}%
{%
{\color{\useKV[ClesProg]{CouleurCadre}}{\bfseries\useKV[ClesProg]{Nom}}}%
\tcblower
}%
\ifboolKV[ClesProg]{SansCalcul}{%
\begin{enumerate}
\item Choisir un nombre~\pointilles~$\ListeProg[1]$%
\foreachitem\etape\in\ListeEtapes{%
\item \etape~\pointilles~$\ListeProg[3,\etapecnt]$
}%
\end{enumerate}
}{\begin{enumerate}
\item Choisir un nombre~\pointilles~\xdef\NbDepart{\ListeProg[1]}\num{\NbDepart}
\foreachitem\etape\in\ListeEtapes{%
\item \etape~\pointilles~\edef\Test{\ListeProg[2,\etapecnt]}%
\expandarg%
\StrSubstitute{\Test}{^}{\empty\dots{}^}[\tempa]%
\StrSubstitute{\tempa}{**}{^}[\tempab]%
\StrSubstitute{\tempab}{*}{\times}[\tempac]%
\StrSubstitute{\tempac}{/}{\div}[\tempad]%
$\ifboolKV[ClesProg]{Details}{\xintifboolexpr{\NbDepart<0}{(\num{\NbDepart})}{\num{\NbDepart}}\tempad=}{}\xdef\NbDepart{\fpeval{(\NbDepart)\ListeProg[2,\etapecnt]}}\num{\NbDepart}$%
}%
\end{enumerate}
}
\end{tcolorbox}
}{%
\ifboolKV[ClesProg]{Enonce}{%
% by Thomas Dehon
\setsepchar[*]{,* }%
\ignoreemptyitems%
\readlist*\ListeEtapes{#2}%
\begin{tcolorbox}[%
ProgCalcul,%
]
\ifthenelse{\equal{\useKV[ClesProg]{Nom}}{}}%
{}%
{%
{\color{\useKV[ClesProg]{CouleurCadre}}{\bfseries\useKV[ClesProg]{Nom}}}%
\tcblower
}%
\begin{enumerate}
\foreachitem\etape\in\ListeEtapes{%
\item \etape
\ifthenelse{\equal{\useKV[ClesProg]{Pointilles}}{0}}%
{}%
{%
\setlength{\PointillesClesProg}{\useKV[ClesProg]{Pointilles}}
\hfill \pointilles[\PointillesClesProg]%
}%
}
\end{enumerate}
\end{tcolorbox}
}{%
\setsepchar[*]{,* }\ignoreemptyitems%
\readlist*\ListeProg{#2}%
\stepcounter{NBprog}%
\xdef\NbDepart{\ListeProg[1]}%
\ifboolKV[ClesProg]{SansCalcul}{%
$\NbDepart$\foreachitem\compteur\in\ListeProg[2]{%
\hspace{0.2em}\tikzmark{A-\theNBprog-\compteurcnt}\hspace{\useKV[ClesProg]{Ecart}}\tikzmark{B-\theNBprog-\compteurcnt}\hspace{0.2em}$\ListeProg[3,\compteurcnt]$%
}%
\begin{tikzpicture}[remember picture, overlay]
\foreachitem\compteur\in\ListeProg[2]{%
\edef\Test{\ListeProg[2,\compteurcnt]}
\expandarg%
\StrSubstitute{\Test}{^}{\empty\dots{}^}[\tempa]%
\StrSubstitute{\tempa}{**}{^}[\tempab]%
\StrSubstitute{\tempab}{*}{\times}[\tempac]%
\StrSubstitute{\tempac}{/}{\div}[\tempad]%
\draw[-stealth,transform canvas={yshift=0.25em}] (pic cs:A-\theNBprog-\compteurcnt) --
node[above]{\scriptsize$\tempad$}(pic cs:B-\theNBprog-\compteurcnt);
}
\end{tikzpicture}
}{%
\num{\NbDepart}\foreachitem\compteur\in\ListeProg[2]{%
\hspace{0.2em}\tikzmark{A-\theNBprog-\compteurcnt}\hspace{\useKV[ClesProg]{Ecart}}\tikzmark{B-\theNBprog-\compteurcnt}\xdef\NbDepart{\fpeval{(\NbDepart)\ListeProg[2,\compteurcnt]}}\hspace{0.2em}\num{\NbDepart}%
}%
\ifboolKV[ClesProg]{Direct}{%
\begin{tikzpicture}[remember picture, overlay]
\foreachitem\compteur\in\ListeProg[2]{%
\edef\Test{\ListeProg[2,\compteurcnt]}
\expandarg%
\StrSubstitute{\Test}{^}{\empty\dots{}^}[\tempa]%
\StrSubstitute{\tempa}{**}{^}[\tempab]%
\StrSubstitute{\tempab}{*}{\times}[\tempac]%
\StrSubstitute{\tempac}{/}{\div}[\tempad]%
\draw[-stealth,transform canvas={yshift=0.25em}] (pic cs:A-\theNBprog-\compteurcnt) --
node[above]{\scriptsize$\tempad$}(pic
cs:B-\theNBprog-\compteurcnt);
}
\end{tikzpicture}
}{%
\begin{tikzpicture}[remember picture, overlay]
\foreachitem\compteur\in\ListeProg[2]{%
\edef\Test{\ListeProg[2,\compteurcnt]}
\expandarg%
\StrSubstitute{\Test}{^2}{\empty\sqrt{\dots{}}}[\tempa]%
\StrSubstitute{\tempa}{**}{^}[\tempab]%
\StrSubstitute{\tempab}{*}{\div}[\tempac]%
\StrSubstitute{\tempac}{/}{\times}[\tempad]%
\StrSubstitute{\tempad}{-}{+}[\tempae]%
\StrSubstitute{\tempae}{++}{-}[\tempaf]%
\draw[-stealth,transform canvas={yshift=0.25em}] (pic cs:B-\theNBprog-\compteurcnt) -- node[above]{\scriptsize$\tempaf$}(pic cs:A-\theNBprog-\compteurcnt);
}
\end{tikzpicture}
}%
}%
}%
}%
}%
|