math-exercises 3.0.144 → 3.0.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/lib/exercises/exercise.d.ts +1 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/addAndSub.d.ts.map +1 -1
  4. package/lib/exercises/math/calcul/addAndSub.js +20 -1
  5. package/lib/exercises/math/calcul/arithmetics/euclideanDivision.js +1 -1
  6. package/lib/exercises/math/calcul/index.d.ts +1 -0
  7. package/lib/exercises/math/calcul/index.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/index.js +1 -0
  9. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts +2 -0
  10. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts.map +1 -1
  11. package/lib/exercises/math/calcul/mentalCaluls/index.js +2 -0
  12. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +22 -0
  14. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.d.ts +9 -0
  15. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.d.ts.map +1 -0
  16. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfInteger.js +152 -0
  17. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.d.ts +15 -0
  18. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.d.ts.map +1 -0
  19. package/lib/exercises/math/calcul/mentalCaluls/mentalFractionageOfQuantity.js +412 -0
  20. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts.map +1 -1
  21. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.js +6 -8
  22. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
  23. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +37 -7
  24. package/lib/exercises/math/calcul/ratio/index.d.ts +2 -0
  25. package/lib/exercises/math/calcul/ratio/index.d.ts.map +1 -0
  26. package/lib/exercises/math/calcul/ratio/index.js +2 -0
  27. package/lib/exercises/math/calcul/ratio/partUsingRatio.d.ts +14 -0
  28. package/lib/exercises/math/calcul/ratio/partUsingRatio.d.ts.map +1 -0
  29. package/lib/exercises/math/calcul/ratio/partUsingRatio.js +388 -0
  30. package/lib/exercises/math/calcul/ratio/ratioFromParts.d.ts +10 -0
  31. package/lib/exercises/math/calcul/ratio/ratioFromParts.d.ts.map +1 -0
  32. package/lib/exercises/math/calcul/ratio/ratioFromParts.js +198 -0
  33. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.d.ts.map +1 -1
  34. package/lib/exercises/math/calculLitteral/equation/equationFromSentenceExercise.js +50 -0
  35. package/lib/exercises/math/calculLitteral/simplifying/compareMinusA.js +1 -1
  36. package/lib/exercises/math/index.d.ts +1 -0
  37. package/lib/exercises/math/index.d.ts.map +1 -1
  38. package/lib/exercises/math/index.js +1 -0
  39. package/lib/exercises/math/probaStat/basicProbas/index.d.ts +1 -0
  40. package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
  41. package/lib/exercises/math/probaStat/basicProbas/index.js +1 -0
  42. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.d.ts +10 -0
  43. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.d.ts.map +1 -0
  44. package/lib/exercises/math/probaStat/basicProbas/rangeBasicProbas.js +113 -0
  45. package/lib/exercises/math/probaStat/index.d.ts +1 -0
  46. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  47. package/lib/exercises/math/probaStat/index.js +1 -0
  48. package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts +8 -0
  49. package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts.map +1 -0
  50. package/lib/exercises/math/probaStat/stats1var/etendueTable.js +89 -0
  51. package/lib/exercises/math/probaStat/stats1var/index.d.ts +1 -0
  52. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  53. package/lib/exercises/math/probaStat/stats1var/index.js +1 -0
  54. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.d.ts +8 -0
  55. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.d.ts.map +1 -0
  56. package/lib/exercises/math/probaStat/twoStepExperiments/countIssuesTwoStepExperiment.js +244 -0
  57. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts +3 -0
  58. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts.map +1 -0
  59. package/lib/exercises/math/probaStat/twoStepExperiments/index.js +2 -0
  60. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.d.ts +8 -0
  61. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.d.ts.map +1 -0
  62. package/lib/exercises/math/probaStat/twoStepExperiments/twoStepExperimentProbas.js +452 -0
  63. package/lib/exercises/math/python/pythonWhileStatementOperationCompletion.d.ts.map +1 -1
  64. package/lib/exercises/math/python/pythonWhileStatementOperationCompletion.js +3 -0
  65. package/lib/exercises/math/scratch/index.d.ts +2 -0
  66. package/lib/exercises/math/scratch/index.d.ts.map +1 -0
  67. package/lib/exercises/math/scratch/index.js +1 -0
  68. package/lib/exercises/math/scratch/scratchLoopStepsCount.d.ts +8 -0
  69. package/lib/exercises/math/scratch/scratchLoopStepsCount.d.ts.map +1 -0
  70. package/lib/exercises/math/scratch/scratchLoopStepsCount.js +85 -0
  71. package/lib/exercises/math/scratch/testScratch.d.ts +8 -0
  72. package/lib/exercises/math/scratch/testScratch.d.ts.map +1 -0
  73. package/lib/exercises/math/scratch/testScratch.js +79 -0
  74. package/lib/exercises/math/trigonometry/index.d.ts +3 -0
  75. package/lib/exercises/math/trigonometry/index.d.ts.map +1 -1
  76. package/lib/exercises/math/trigonometry/index.js +3 -0
  77. package/lib/exercises/math/trigonometry/trigonometrySideName.d.ts +13 -0
  78. package/lib/exercises/math/trigonometry/trigonometrySideName.d.ts.map +1 -0
  79. package/lib/exercises/math/trigonometry/trigonometrySideName.js +189 -0
  80. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.d.ts +13 -0
  81. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.d.ts.map +1 -0
  82. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaCalcul.js +290 -0
  83. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.d.ts +18 -0
  84. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.d.ts.map +1 -0
  85. package/lib/exercises/math/trigonometry/trigonometrySohcahtoaUse.js +386 -0
  86. package/lib/index.d.ts +58 -0
  87. package/lib/index.d.ts.map +1 -1
  88. package/lib/latexTester.d.ts.map +1 -1
  89. package/lib/latexTester.js +5 -0
  90. package/lib/math/geometry/triangles/triangle.d.ts +1 -0
  91. package/lib/math/geometry/triangles/triangle.d.ts.map +1 -1
  92. package/lib/math/geometry/triangles/triangle.js +1 -0
  93. package/lib/math/numbers/fractions/isDecimalFraction.d.ts +3 -0
  94. package/lib/math/numbers/fractions/isDecimalFraction.d.ts.map +1 -0
  95. package/lib/math/numbers/fractions/isDecimalFraction.js +14 -0
  96. package/lib/math/polynomials/polynomial.js +1 -1
  97. package/lib/types/keyIds.d.ts +1 -1
  98. package/lib/types/keyIds.d.ts.map +1 -1
  99. package/package.json +1 -1
@@ -0,0 +1,452 @@
1
+ import { randint } from "../../../../math/utils/random/randint.js";
2
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercise.js";
3
+ import { getDistinctQuestions } from "../../../utils/getDistinctQuestions.js";
4
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
5
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
6
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
7
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { randomMany } from "../../../../utils/alea/random.js";
9
+ import { joinanded } from "../../../../utils/strings/joinanded.js";
10
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
11
+ import { getCartesiansProducts } from "../../../../utils/arrays/cartesianProducts.js";
12
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
13
+ import { round } from "../../../../math/utils/round.js";
14
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
15
+ function highlighted(str) {
16
+ return `{ \\color{green} ${str} }`;
17
+ }
18
+ const situations = [
19
+ //1<->100
20
+ // (() => {
21
+ // const isRealizingEvent = (v0: number, v1: number) => {
22
+ // return v0 * 100 === v1;
23
+ // };
24
+ // return {
25
+ // instruction: (values: number[][]) => {
26
+ // return `Dans un porte-monnaie, il y a $${
27
+ // values[0].length
28
+ // }$ pièces différentes et $${values[1].length}$ billets différents.
29
+ // Les valeurs des pièces sont ${joinanded(
30
+ // values[0].map((v) => `$${v.frenchify()}\\ \\textrm{€}$`),
31
+ // ", ",
32
+ // " et ",
33
+ // )}.
34
+ // Les valeurs des billets sont ${joinanded(
35
+ // values[1].map((v) => `$${v.frenchify()}\\ \\textrm{€}$`),
36
+ // ", ",
37
+ // " et ",
38
+ // )}.
39
+ // Lisa prend au hasard une pièce et un billet dans ce porte-monnaie.
40
+ // Quelle est la probabilité de l'évènement "La pièce a la même valeur en centimes que le billet en euros" ?
41
+ // `;
42
+ // },
43
+ // correction: (values: number[][]) => {
44
+ // const cartesianProduct = getCartesiansProducts(values);
45
+ // const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) =>
46
+ // isRealizingEvent(v0, v1),
47
+ // );
48
+ // const nbIssuesSatisfyingE = issuesSatisfyingE.length;
49
+ // const nbIssuesTotal = values[0].length * values[1].length;
50
+ // const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal);
51
+ // return `On peut construire le tableau ci-dessous :
52
+ // ${mdTable([
53
+ // ["Lisa", ...values[0].map(() => ``)],
54
+ // [``, ...values[0].map((v0) => `$${v0.frenchify()}\\ \\textrm{€}$`)],
55
+ // ...values[1].map((v1) => [
56
+ // `$${v1.frenchify()}\\ \\textrm{€}$`,
57
+ // ...values[0].map((v0) => {
58
+ // const strStd = `(${v1.frenchify()};${v0.frenchify()})`;
59
+ // if (isRealizingEvent(v0, v1)) {
60
+ // return `$${highlighted(strStd)}$`;
61
+ // } else {
62
+ // return `$${strStd}$`;
63
+ // }
64
+ // }),
65
+ // ]),
66
+ // ])}
67
+ // Il y a $${nbIssuesSatisfyingE}$ issue${
68
+ // nbIssuesSatisfyingE !== 1 ? "s" : ""
69
+ // } qui réalise${
70
+ // nbIssuesSatisfyingE !== 1 ? "nt" : ""
71
+ // } l'évènement "La pièce a la même valeur en centimes que le billet en euros".
72
+ // Il y a $${nbIssuesTotal}$ issues au total.
73
+ // La probabilité recherchée est donc $${nodeP.toTex()}$`;
74
+ // },
75
+ // randValues: () => {
76
+ // const [l1, l2] = randomMany([2, 3, 4], 2);
77
+ // return [
78
+ // randomMany([0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2], l1).toSorted(
79
+ // (n1, n2) => n1 - n2,
80
+ // ),
81
+ // randomMany([5, 10, 20, 50, 100, 200], l2).toSorted(
82
+ // (n1, n2) => n1 - n2,
83
+ // ),
84
+ // ];
85
+ // },
86
+ // answerNode: (values: number[][]) => {
87
+ // const cartesianProduct = getCartesiansProducts(values);
88
+ // const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) =>
89
+ // isRealizingEvent(v0, v1),
90
+ // );
91
+ // const nbIssuesSatisfyingE = issuesSatisfyingE.length;
92
+ // const nbIssuesTotal = values[0].length * values[1].length;
93
+ // const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal);
94
+ // return nodeP;
95
+ // },
96
+ // };
97
+ // })(),
98
+ //even digits
99
+ (() => {
100
+ const isRealizingEvent = (v0, v1) => {
101
+ const vSum = v0 + v1;
102
+ const strSum = vSum.toString().replace(".", "");
103
+ return strSum.split("").every((s) => Number(s) % 2 === 0);
104
+ };
105
+ return {
106
+ instruction: (values) => {
107
+ return `Dans un porte-monnaie, il y a $${values[0].length}$ pièces différentes et $${values[1].length}$ billets différents.
108
+ Les valeurs des pièces sont ${joinanded(values[0].map((v) => `$${v.frenchify()}\\ \\textrm{€}$`), ", ", " et ")}.
109
+ Les valeurs des billets sont ${joinanded(values[1].map((v) => `$${v.frenchify()}\\ \\textrm{€}$`), ", ", " et ")}.
110
+ Salomé prend au hasard une pièce et un billet dans ce porte-monnaie.
111
+
112
+ Quelle est la probabilité de l'évènement "La valeur de la somme en euros contient uniquement des chiffres pairs" ?
113
+ `;
114
+ },
115
+ correction: (values) => {
116
+ const cartesianProduct = getCartesiansProducts(values);
117
+ const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) => isRealizingEvent(v0, v1));
118
+ const nbIssuesSatisfyingE = issuesSatisfyingE.length;
119
+ const nbIssuesTotal = values[0].length * values[1].length;
120
+ const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal);
121
+ return `On peut construire le tableau ci-dessous :
122
+ ${mdTable([
123
+ ["Somme en euros", ...values[0].map(() => ``)],
124
+ [``, ...values[0].map((v0) => `$${v0.frenchify()}\\ \\textrm{€}$`)],
125
+ ...values[1].map((v1) => [
126
+ `$${v1.frenchify()}\\ \\textrm{€}$`,
127
+ ...values[0].map((v0) => {
128
+ const strStd = `${(v0 + v1).frenchify()}`;
129
+ if (isRealizingEvent(v0, v1)) {
130
+ return `$${highlighted(strStd)}$`;
131
+ }
132
+ else {
133
+ return `$${strStd}$`;
134
+ }
135
+ }),
136
+ ]),
137
+ ])}
138
+
139
+ Il y a $${nbIssuesSatisfyingE}$ issue${nbIssuesSatisfyingE !== 1 ? "s" : ""} qui réalise${nbIssuesSatisfyingE !== 1 ? "nt" : ""} l'évènement "La valeur de la somme en euros contient uniquement des chiffres pairs".
140
+ Il y a $${nbIssuesTotal}$ issues au total.
141
+ La probabilité recherchée est donc :
142
+
143
+ $$
144
+ ${nodeP.toSimplificationTex()}
145
+ $$`;
146
+ },
147
+ randValues: () => {
148
+ const [l1, l2] = randomMany([2, 3, 4], 2);
149
+ return [
150
+ randomMany([0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2], l1).toSorted((n1, n2) => n1 - n2),
151
+ randomMany([5, 10, 20, 50, 100, 200], l2).toSorted((n1, n2) => n1 - n2),
152
+ ];
153
+ },
154
+ answerNode: (values) => {
155
+ const cartesianProduct = getCartesiansProducts(values);
156
+ const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) => isRealizingEvent(v0, v1));
157
+ const nbIssuesSatisfyingE = issuesSatisfyingE.length;
158
+ const nbIssuesTotal = values[0].length * values[1].length;
159
+ const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal).simplify();
160
+ return nodeP;
161
+ },
162
+ };
163
+ })(),
164
+ //2 fois le même chiffre(!==0)
165
+ (() => {
166
+ const isRealizingEvent = (v0, v1) => {
167
+ const vSum = v0 + v1;
168
+ const strSum = vSum.frenchify();
169
+ const arrOccurences = [...Array(9).keys()]
170
+ .map((i) => i + 1)
171
+ .map((i) => strSum.split("").filter((c) => c === `${i}`).length);
172
+ return arrOccurences.includes(2);
173
+ };
174
+ return {
175
+ instruction: (values) => {
176
+ return `Dans un porte-monnaie, il y a $${values[0].length}$ pièces différentes et $${values[1].length}$ billets différents.
177
+ Les valeurs des pièces sont ${joinanded(values[0].map((v) => `$${v.frenchify()}\\ \\textrm{€}$`), ", ", " et ")}.
178
+ Les valeurs des billets sont ${joinanded(values[1].map((v) => `$${v.frenchify()}\\ \\textrm{€}$`), ", ", " et ")}.
179
+ Léo prend au hasard une pièce et un billet dans ce porte-monnaie.
180
+
181
+ Quelle est la probabilité de l'évènement "La valeur de la somme en euros contient deux fois le même chiffre (différent de $0$)" ?
182
+ `;
183
+ },
184
+ correction: (values) => {
185
+ const cartesianProduct = getCartesiansProducts(values);
186
+ const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) => isRealizingEvent(v0, v1));
187
+ const nbIssuesSatisfyingE = issuesSatisfyingE.length;
188
+ const nbIssuesTotal = values[0].length * values[1].length;
189
+ const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal);
190
+ return `On peut construire le tableau ci-dessous :
191
+ ${mdTable([
192
+ ["Somme", ...values[0].map(() => ``)],
193
+ [``, ...values[0].map((v0) => `$${v0.frenchify()}\\ \\textrm{€}$`)],
194
+ ...values[1].map((v1) => [
195
+ `$${v1.frenchify()}\\ \\textrm{€}$`,
196
+ ...values[0].map((v0) => {
197
+ const strStd = `${(v0 + v1).frenchify()}`;
198
+ if (isRealizingEvent(v0, v1)) {
199
+ return `$${highlighted(strStd)}$`;
200
+ }
201
+ else {
202
+ return `$${strStd}$`;
203
+ }
204
+ }),
205
+ ]),
206
+ ])}
207
+
208
+ Il y a $${nbIssuesSatisfyingE}$ issue${nbIssuesSatisfyingE !== 1 ? "s" : ""} qui réalise${nbIssuesSatisfyingE !== 1 ? "nt" : ""} l'évènement "La valeur de la somme en euros contient deux fois le même chiffre (différent de $0$)".
209
+ Il y a $${nbIssuesTotal}$ issues au total.
210
+ La probabilité recherchée est donc :
211
+
212
+ $$
213
+ ${nodeP.toSimplificationTex()}
214
+ $$`;
215
+ },
216
+ randValues: () => {
217
+ const [l1, l2] = randomMany([2, 3, 4], 2);
218
+ return [
219
+ randomMany([0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2], l1).toSorted((n1, n2) => n1 - n2),
220
+ randomMany([5, 10, 20, 50, 100, 200], l2).toSorted((n1, n2) => n1 - n2),
221
+ ];
222
+ },
223
+ answerNode: (values) => {
224
+ const cartesianProduct = getCartesiansProducts(values);
225
+ const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) => isRealizingEvent(v0, v1));
226
+ const nbIssuesSatisfyingE = issuesSatisfyingE.length;
227
+ const nbIssuesTotal = values[0].length * values[1].length;
228
+ const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal).simplify();
229
+ return nodeP;
230
+ },
231
+ };
232
+ })(),
233
+ //xGame: geq 10
234
+ (() => {
235
+ const isRealizingEvent = (v0, v1) => {
236
+ return v0 * v1 >= 10;
237
+ };
238
+ return {
239
+ instruction: (values) => {
240
+ return `Dans un jeu, on tire au hasard une somme de base et un multiplicateur.
241
+ Les sommes de base sont ${joinanded(values[0].map((v) => `$${v.frenchify()}\\ \\textrm{€}$`), ", ", " et ")}.
242
+ Les multiplicateurs sont ${joinanded(values[1].map((v) => `$\\times ${v.frenchify()}$`), ", ", " et ")}.
243
+ Jean tente sa chance.
244
+ Quelle est la probabilité de l'évènement "La somme gagnée est supérieure ou égale à $10 \\ \\textrm{€}$" ?
245
+ `;
246
+ },
247
+ correction: (values) => {
248
+ const cartesianProduct = getCartesiansProducts(values);
249
+ const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) => isRealizingEvent(v0, v1));
250
+ const nbIssuesSatisfyingE = issuesSatisfyingE.length;
251
+ const nbIssuesTotal = values[0].length * values[1].length;
252
+ const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal);
253
+ return `On peut construire le tableau ci-dessous :
254
+ ${mdTable([
255
+ ["Somme en euros", ...values[0].map(() => ``)],
256
+ [``, ...values[0].map((v0) => `$${v0.frenchify()}\\ \\textrm{€}$`)],
257
+ ...values[1].map((v1) => [
258
+ `$\\times ${v1.frenchify()}$`,
259
+ ...values[0].map((v0) => {
260
+ const strStd = `${round(v0 * v1, 4).frenchify()}`;
261
+ if (isRealizingEvent(v0, v1)) {
262
+ return `$${highlighted(strStd)}$`;
263
+ }
264
+ else {
265
+ return `$${strStd}$`;
266
+ }
267
+ }),
268
+ ]),
269
+ ])}
270
+
271
+ Il y a $${nbIssuesSatisfyingE}$ issue${nbIssuesSatisfyingE !== 1 ? "s" : ""} qui réalise${nbIssuesSatisfyingE !== 1 ? "nt" : ""} l'évènement "La somme gagnée est supérieure ou égale à $10 \\ \\textrm{€}$".
272
+ Il y a $${nbIssuesTotal}$ issues au total.
273
+ La probabilité recherchée est donc :
274
+
275
+ $$
276
+ ${nodeP.toSimplificationTex()}
277
+ $$`;
278
+ },
279
+ randValues: () => {
280
+ const [l1, l2] = randomMany([2, 3, 4], 2);
281
+ return [
282
+ randomMany([0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2], l1).toSorted((n1, n2) => n1 - n2),
283
+ randomMany([1, 2, 5, 10, 20, 50, 100], l2).toSorted((n1, n2) => n1 - n2),
284
+ ];
285
+ },
286
+ answerNode: (values) => {
287
+ const cartesianProduct = getCartesiansProducts(values);
288
+ const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) => isRealizingEvent(v0, v1));
289
+ const nbIssuesSatisfyingE = issuesSatisfyingE.length;
290
+ const nbIssuesTotal = values[0].length * values[1].length;
291
+ const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal).simplify();
292
+ return nodeP;
293
+ },
294
+ };
295
+ })(),
296
+ //xGame: contains 1
297
+ (() => {
298
+ const isRealizingEvent = (v0, v1) => {
299
+ const vProduct = v0 * v1;
300
+ return vProduct.frenchify().includes("1");
301
+ };
302
+ return {
303
+ instruction: (values) => {
304
+ return `Dans un jeu, on tire au hasard une somme de base et un multiplicateur.
305
+ Les sommes de base sont ${joinanded(values[0].map((v) => `$${v.frenchify()}\\ \\textrm{€}$`), ", ", " et ")}.
306
+ Les multiplicateurs sont ${joinanded(values[1].map((v) => `$\\times ${v.frenchify()}$`), ", ", " et ")}.
307
+ Karima tente sa chance.
308
+ Quelle est la probabilité de l'évènement "La somme gagnée contient le chiffre $1$" ?
309
+ `;
310
+ },
311
+ correction: (values) => {
312
+ const cartesianProduct = getCartesiansProducts(values);
313
+ const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) => isRealizingEvent(v0, v1));
314
+ const nbIssuesSatisfyingE = issuesSatisfyingE.length;
315
+ const nbIssuesTotal = values[0].length * values[1].length;
316
+ const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal);
317
+ return `On peut construire le tableau ci-dessous :
318
+ ${mdTable([
319
+ ["Somme gagnée", ...values[0].map(() => ``)],
320
+ [``, ...values[0].map((v0) => `$${v0.frenchify()}\\ \\textrm{€}$`)],
321
+ ...values[1].map((v1) => [
322
+ `$\\times ${v1.frenchify()}$`,
323
+ ...values[0].map((v0) => {
324
+ const strStd = `${round(v0 * v1, 4).frenchify()}`;
325
+ if (isRealizingEvent(v0, v1)) {
326
+ return `$${highlighted(strStd)}$`;
327
+ }
328
+ else {
329
+ return `$${strStd}$`;
330
+ }
331
+ }),
332
+ ]),
333
+ ])}
334
+
335
+ Il y a $${nbIssuesSatisfyingE}$ issue${nbIssuesSatisfyingE !== 1 ? "s" : ""} qui réalise${nbIssuesSatisfyingE !== 1 ? "nt" : ""} l'évènement "La somme gagnée contient le chiffre $1$".
336
+ Il y a $${nbIssuesTotal}$ issues au total.
337
+ La probabilité recherchée est donc :
338
+
339
+ $$
340
+ ${nodeP.toSimplificationTex()}
341
+ $$`;
342
+ },
343
+ randValues: () => {
344
+ const [l1, l2] = randomMany([2, 3, 4], 2);
345
+ return [
346
+ randomMany([0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2], l1).toSorted((n1, n2) => n1 - n2),
347
+ randomMany([1, 2, 5, 10, 20, 50, 100], l2).toSorted((n1, n2) => n1 - n2),
348
+ ];
349
+ },
350
+ answerNode: (values) => {
351
+ const cartesianProduct = getCartesiansProducts(values);
352
+ const issuesSatisfyingE = cartesianProduct.filter(([v0, v1]) => isRealizingEvent(v0, v1));
353
+ const nbIssuesSatisfyingE = issuesSatisfyingE.length;
354
+ const nbIssuesTotal = values[0].length * values[1].length;
355
+ const nodeP = frac(nbIssuesSatisfyingE, nbIssuesTotal).simplify();
356
+ return nodeP;
357
+ },
358
+ };
359
+ })(),
360
+ ];
361
+ const getInstruction = (identifiers) => {
362
+ const { situationIndex, values } = identifiers;
363
+ const situation = situations[situationIndex];
364
+ return situation.instruction(values);
365
+ };
366
+ const getAnswerNode = (identifiers) => {
367
+ const { situationIndex, values } = identifiers;
368
+ const situation = situations[situationIndex];
369
+ return situation.answerNode(values);
370
+ };
371
+ const getAnswer = (identifiers) => {
372
+ return getAnswerNode(identifiers).toTex();
373
+ };
374
+ const getHint = () => {
375
+ return `Tu peux dresser un tableau avec les différentes issues et compter combien réalisent l'évènement demandé.`;
376
+ };
377
+ const getCorrection = (identifiers) => {
378
+ const { situationIndex, values } = identifiers;
379
+ const situation = situations[situationIndex];
380
+ return situation.correction(values);
381
+ };
382
+ const getPropositions = (n, { answer, ...identifiers }) => {
383
+ const { values } = identifiers;
384
+ const answerNode = getAnswerNode(identifiers);
385
+ const nbTotal = values[0].length * values[1].length;
386
+ const nbIssuesSatisfyingE = multiply(answerNode, nbTotal)
387
+ .simplify()
388
+ .evaluate();
389
+ const propositions = [];
390
+ const isSimplify = coinFlip();
391
+ addValidProp(propositions, (isSimplify ? answerNode.simplify() : answerNode).toTex());
392
+ //nbIssuesSatisfyingE
393
+ if (nbIssuesSatisfyingE !== 0) {
394
+ tryToAddWrongProp(propositions, nbIssuesSatisfyingE.frenchify());
395
+ }
396
+ //frac{1}{nbIssuesSatisfyingE}
397
+ if (nbIssuesSatisfyingE !== 0) {
398
+ tryToAddWrongProp(propositions, frac(1, nbIssuesSatisfyingE).simplify().toTex());
399
+ }
400
+ //random around
401
+ [-2, -1, +1, +2, +3, +4].forEach((offset) => {
402
+ const nbIssuesSatisfyingEWrong = nbIssuesSatisfyingE + offset;
403
+ if (nbIssuesSatisfyingEWrong >= 0) {
404
+ tryToAddWrongProp(propositions, frac(nbIssuesSatisfyingEWrong, nbTotal).toTex());
405
+ }
406
+ });
407
+ return shuffleProps(propositions, n);
408
+ };
409
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
410
+ try {
411
+ const nodeAns = parseAlgebraic(ans);
412
+ const nodeAnswer = getAnswerNode(identifiers);
413
+ return (substract(nodeAns.simplify(), nodeAnswer.simplify())
414
+ .simplify()
415
+ .evaluate() === 0);
416
+ }
417
+ catch (err) {
418
+ return handleVEAError(err);
419
+ }
420
+ };
421
+ const getTwoStepExperimentProbasQuestion = () => {
422
+ const situationIndex = randint(0, situations.length);
423
+ const situation = situations[situationIndex];
424
+ const values = situation.randValues();
425
+ const identifiers = { situationIndex, values };
426
+ return getQuestionFromIdentifiers(identifiers);
427
+ };
428
+ const getQuestionFromIdentifiers = (identifiers) => {
429
+ const question = {
430
+ instruction: getInstruction(identifiers),
431
+ answer: getAnswer(identifiers),
432
+ keys: [],
433
+ answerFormat: "tex",
434
+ identifiers,
435
+ hint: getHint(identifiers),
436
+ correction: getCorrection(identifiers),
437
+ };
438
+ return question;
439
+ };
440
+ export const twoStepExperimentProbas = {
441
+ id: "twoStepExperimentProbas",
442
+ label: "Calculer la probabilité d'un évènement dans une expérience à deux épreuves avec équiprobabilité",
443
+ isSingleStep: true,
444
+ generator: (nb) => getDistinctQuestions(getTwoStepExperimentProbasQuestion, nb),
445
+ qcmTimer: 60,
446
+ freeTimer: 60,
447
+ getPropositions,
448
+ isAnswerValid,
449
+ subject: "Mathématiques",
450
+ hasHintAndCorrection: true,
451
+ getQuestionFromIdentifiers,
452
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"pythonWhileStatementOperationCompletion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonWhileStatementOperationCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IAEjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAuGF,eAAO,MAAM,uCAAuC,EAAE,QAAQ,CAAC,WAAW,CAqBzE,CAAC"}
1
+ {"version":3,"file":"pythonWhileStatementOperationCompletion.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonWhileStatementOperationCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IAEjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA0GF,eAAO,MAAM,uCAAuC,EAAE,QAAQ,CAAC,WAAW,CAqBzE,CAAC"}
@@ -97,6 +97,9 @@ const getQuestionFromIdentifiers = (identifiers) => {
97
97
  identifiers,
98
98
  hint: getHint(identifiers),
99
99
  correction: getCorrection(identifiers),
100
+ keyboardOptions: {
101
+ timesShouldProduceStar: true,
102
+ },
100
103
  };
101
104
  };
102
105
  export const pythonWhileStatementOperationCompletion = {
@@ -0,0 +1,2 @@
1
+ export * from "./scratchLoopStepsCount.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/scratch/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./scratchLoopStepsCount.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ repeatCount: number;
4
+ stepsCount: number;
5
+ };
6
+ export declare const scratchLoopStepsCount: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=scratchLoopStepsCount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scratchLoopStepsCount.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/scratch/scratchLoopStepsCount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA2EF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../exercises/vea/numberVEA.js";
4
+ import { randint } from "../../../math/utils/random/randint.js";
5
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
6
+ const getPropositions = (n, { answer }) => {
7
+ const propositions = [];
8
+ addValidProp(propositions, answer);
9
+ propWhile(propositions, n, () => {
10
+ tryToAddWrongProp(propositions, randint(1, 10).frenchify());
11
+ });
12
+ return shuffleProps(propositions, n);
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ return (identifiers.repeatCount * identifiers.stepsCount).frenchify();
16
+ };
17
+ const getInstruction = (identifiers) => {
18
+ return `On considère le programme Scratch ci-dessous :
19
+
20
+ <svg id="scratch">quand @greenFlag est cliqué
21
+ répéter (${identifiers.repeatCount}) fois
22
+ avancer de (${identifiers.stepsCount}) pas
23
+ fin</svg>
24
+
25
+ Au total, de combien de pas a-t-on avancé ?`;
26
+ };
27
+ const getHint = (identifiers) => {
28
+ const { repeatCount, stepsCount } = identifiers;
29
+ return `À chaque fois qu'on passe dans la boucle, on avance de $${stepsCount}$ pas. On répète cette boucle $${repeatCount}$ fois. Au total, de combien de pas avance-t-on ?`;
30
+ };
31
+ const getCorrection = (identifiers) => {
32
+ const { repeatCount, stepsCount } = identifiers;
33
+ return `À chaque fois qu'on passe dans la boucle, on avance de $${stepsCount}$ pas.
34
+
35
+ On répète la boucle $${repeatCount}$ fois.
36
+
37
+ Au total, on avance donc de $${repeatCount} \\times ${stepsCount} = ${repeatCount * stepsCount}$ pas.`;
38
+ };
39
+ const getKeys = () => {
40
+ return [];
41
+ };
42
+ const isAnswerValid = (ans, { answer }) => {
43
+ try {
44
+ return numberVEA(ans, answer);
45
+ }
46
+ catch (err) {
47
+ return handleVEAError(err);
48
+ }
49
+ };
50
+ const getTestScratchQuestion = () => {
51
+ const identifiers = {
52
+ repeatCount: randint(2, 11),
53
+ stepsCount: randint(2, 11),
54
+ };
55
+ return getQuestionFromIdentifiers(identifiers);
56
+ };
57
+ const getQuestionFromIdentifiers = (identifiers) => {
58
+ return {
59
+ answer: getAnswer(identifiers),
60
+ instruction: getInstruction(identifiers),
61
+ keys: getKeys(identifiers),
62
+ answerFormat: "tex",
63
+ identifiers,
64
+ hint: getHint(identifiers),
65
+ correction: getCorrection(identifiers),
66
+ };
67
+ };
68
+ export const scratchLoopStepsCount = {
69
+ id: "scratchLoopStepsCount",
70
+ connector: "=",
71
+ label: "Compter le nombre de pas dans une boucle en Scratch",
72
+ isSingleStep: true,
73
+ generator: (nb, opts) => getDistinctQuestions(() => getTestScratchQuestion(opts), nb),
74
+ qcmTimer: 60,
75
+ freeTimer: 60,
76
+ getPropositions,
77
+ isAnswerValid,
78
+ subject: "Mathématiques",
79
+ getInstruction,
80
+ getHint,
81
+ getCorrection,
82
+ getAnswer,
83
+ getQuestionFromIdentifiers,
84
+ hasHintAndCorrection: true,
85
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ repeatCount: number;
4
+ stepsCount: number;
5
+ };
6
+ export declare const testScratch: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=testScratch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testScratch.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/scratch/testScratch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAkEF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAkB7C,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../exercises/vea/numberVEA.js";
4
+ import { randint } from "../../../math/utils/random/randint.js";
5
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
6
+ const getPropositions = (n, { answer }) => {
7
+ const propositions = [];
8
+ addValidProp(propositions, answer);
9
+ propWhile(propositions, n, () => {
10
+ tryToAddWrongProp(propositions, randint(1, 10).frenchify());
11
+ });
12
+ return shuffleProps(propositions, n);
13
+ };
14
+ const getAnswer = (identifiers) => {
15
+ return (identifiers.repeatCount * identifiers.stepsCount).frenchify();
16
+ };
17
+ const getInstruction = (identifiers) => {
18
+ return `On donne le programme Scratch ci-dessous :
19
+
20
+ <svg id="scratch">quand @greenFlag est cliqué
21
+ répéter (${identifiers.repeatCount}) fois
22
+ avancer de (${identifiers.stepsCount}) pas
23
+ fin</svg>
24
+
25
+ Au total, de combien de pas a-t-on avancé ?`;
26
+ };
27
+ const getHint = () => {
28
+ return `indice`;
29
+ };
30
+ const getCorrection = () => {
31
+ return `correction`;
32
+ };
33
+ const getKeys = () => {
34
+ return [];
35
+ };
36
+ const isAnswerValid = (ans, { answer }) => {
37
+ try {
38
+ return numberVEA(ans, answer);
39
+ }
40
+ catch (err) {
41
+ return handleVEAError(err);
42
+ }
43
+ };
44
+ const getTestScratchQuestion = () => {
45
+ const identifiers = {
46
+ repeatCount: randint(2, 11),
47
+ stepsCount: randint(2, 11),
48
+ };
49
+ return getQuestionFromIdentifiers(identifiers);
50
+ };
51
+ const getQuestionFromIdentifiers = (identifiers) => {
52
+ return {
53
+ answer: getAnswer(identifiers),
54
+ instruction: getInstruction(identifiers),
55
+ keys: getKeys(identifiers),
56
+ answerFormat: "tex",
57
+ identifiers,
58
+ hint: getHint(identifiers),
59
+ correction: getCorrection(identifiers),
60
+ };
61
+ };
62
+ export const testScratch = {
63
+ id: "testScratch",
64
+ connector: "=",
65
+ label: "Test Scratch",
66
+ isSingleStep: true,
67
+ generator: (nb, opts) => getDistinctQuestions(() => getTestScratchQuestion(opts), nb),
68
+ qcmTimer: 60,
69
+ freeTimer: 60,
70
+ getPropositions,
71
+ isAnswerValid,
72
+ subject: "Mathématiques",
73
+ getInstruction,
74
+ getHint,
75
+ getCorrection,
76
+ getAnswer,
77
+ getQuestionFromIdentifiers,
78
+ hasHintAndCorrection: true,
79
+ };