math-exercises 3.0.184 → 3.0.185

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 (26) hide show
  1. package/lib/exercises/math/functions/exponential/algebraic/approxExpAPlusB.d.ts.map +1 -1
  2. package/lib/exercises/math/functions/exponential/algebraic/approxExpAPlusB.js +91 -38
  3. package/lib/exercises/math/probaStat/trees/index.d.ts +1 -1
  4. package/lib/exercises/math/probaStat/trees/index.d.ts.map +1 -1
  5. package/lib/exercises/math/probaStat/trees/index.js +1 -3
  6. package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts +9 -3
  7. package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts.map +1 -1
  8. package/lib/exercises/math/probaStat/trees/probabilityTree.js +419 -45
  9. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -1
  10. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +3 -3
  11. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -1
  12. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +2 -2
  13. package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +2 -0
  14. package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -1
  15. package/lib/exercises/math/sequences/arithmetic/situations/index.js +2 -2
  16. package/lib/index.d.ts +13 -0
  17. package/lib/index.d.ts.map +1 -1
  18. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +2 -0
  19. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  20. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +150 -128
  21. package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +1 -1
  22. package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -1
  23. package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +4 -1
  24. package/lib/tests/questionTest.d.ts.map +1 -1
  25. package/lib/tests/questionTest.js +1 -0
  26. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
1
  import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
2
- import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
3
2
  import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
4
3
  import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
4
  import { randint } from "../../../../math/utils/random/randint.js";
6
5
  import { round } from "../../../../math/utils/round.js";
7
6
  import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
8
7
  import { add } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
9
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
10
  import { substract } from "../../../../tree/nodes/operators/substractNode.js";
11
11
  import { random } from "../../../../utils/alea/random.js";
@@ -18,12 +18,26 @@ const optionValues = [
18
18
  "Probabilité totale $P(C)$",
19
19
  "Probabilité conditionnelle $P_B(A)$",
20
20
  "Probabilité 'simple' $P(A)$",
21
+ "Probabilité d'inversion de causalité $P_B(A)$",
21
22
  ];
22
23
  const defaultOptionValues = [
23
24
  "Probabilité d'intersection $P(A\\cap C)$",
24
25
  "Probabilité totale $P(C)$",
25
26
  "Probabilité conditionnelle $P_B(A)$",
27
+ "Probabilité 'simple' $P(A)$",
26
28
  ];
29
+ const getProbaType = (identifiers) => {
30
+ const { probaName } = identifiers;
31
+ return probaName.includes("\\cap")
32
+ ? "inter"
33
+ : ["P(C)", "P(D)"].includes(probaName)
34
+ ? "totale"
35
+ : ["P(A)", "P(B)"].includes(probaName)
36
+ ? "simple"
37
+ : ["P_A(C)", "P_A(D)", "P_B(C)", "P_B(D)"].includes(probaName)
38
+ ? "conditionnelle"
39
+ : "inversion";
40
+ };
27
41
  const buildAll = (identifiers) => {
28
42
  return {
29
43
  pA: NodeConstructor.fromIdentifiers(identifiers.A),
@@ -62,16 +76,82 @@ const getAnswerNode = (identifiers) => {
62
76
  case "P(D)":
63
77
  default:
64
78
  return add(multiply(probas.pA, probas.pAD), multiply(probas.pB, probas.pBD)).simplify();
79
+ case "P_C(A)": {
80
+ //anc / c
81
+ const pc = add(multiply(probas.pA, probas.pAC), multiply(probas.pB, probas.pBC)).simplify();
82
+ return frac(multiply(probas.pA, probas.pAC), pc).simplify();
83
+ }
84
+ case "P_C(B)": {
85
+ //cnb / c
86
+ const pc = add(multiply(probas.pA, probas.pAC), multiply(probas.pB, probas.pBC)).simplify();
87
+ return frac(multiply(probas.pB, probas.pBC), pc).simplify();
88
+ }
89
+ case "P_D(A)": {
90
+ //and / d
91
+ const pd = add(multiply(probas.pA, probas.pAD), multiply(probas.pB, probas.pBD)).simplify();
92
+ return frac(multiply(probas.pA, probas.pAD), pd).simplify();
93
+ }
94
+ case "P_D(B)": {
95
+ //cnb / c
96
+ const pd = add(multiply(probas.pA, probas.pAD), multiply(probas.pB, probas.pBD)).simplify();
97
+ return frac(multiply(probas.pB, probas.pBD), pd).simplify();
98
+ }
65
99
  }
66
100
  };
67
101
  const getAnswer = (identifiers) => {
68
102
  return getAnswerNode(identifiers).toTex();
69
103
  };
104
+ const getTrueProbaName = (identifiers) => {
105
+ const { probaName, useContraryNames } = identifiers;
106
+ if (!useContraryNames)
107
+ return probaName;
108
+ return probaName
109
+ .replaceAll("_B", "_{\\overline{A}}")
110
+ .replaceAll("B", "\\overline{A}")
111
+ .replaceAll("_D", "_{\\overline{B}}")
112
+ .replaceAll("C", "B")
113
+ .replaceAll("D", "\\overline{B}");
114
+ };
70
115
  const getInstruction = (identifiers, options) => {
71
- let instr = `On considère l'arbre de probabilités ci-dessous. Calculer :
116
+ const probas = buildAll(identifiers);
117
+ const type = getProbaType(identifiers);
118
+ const { useContraryNames } = identifiers;
119
+ const trueProbaName = getTrueProbaName(identifiers);
120
+ const tree = [
121
+ [
122
+ [
123
+ [`£${probas.pA.toTex()}£`, "£A£"],
124
+ [
125
+ `£${probas.pB.toTex()}£`,
126
+ useContraryNames ? "£\\overline{A}£" : "£B£",
127
+ ],
128
+ ],
129
+ ],
130
+ [
131
+ [
132
+ [`£${probas.pAC.toTex()}£`, useContraryNames ? "£B£" : "£C£"],
133
+ [
134
+ `£${probas.pAD.toTex()}£`,
135
+ useContraryNames ? "£\\overline{B}£" : "£D£",
136
+ ],
137
+ ],
138
+ [
139
+ [`£${probas.pBC.toTex()}£`, useContraryNames ? "£B£" : "£C£"],
140
+ [
141
+ `£${probas.pBD.toTex()}£`,
142
+ useContraryNames ? "£\\overline{B}£" : "£D£",
143
+ ],
144
+ ],
145
+ ],
146
+ ];
147
+ let instr = `On considère l'arbre de probabilités ci-dessous :
148
+
149
+ <svg id="treeDiagram">${JSON.stringify(tree)}</svg>
150
+
151
+ ${type === "conditionnelle" || type === "simple" ? "Déterminer :" : "Calculer :"}
72
152
 
73
153
  $$
74
- ${identifiers.probaName}
154
+ ${trueProbaName}
75
155
  $$`;
76
156
  if (options?.allowApproximate) {
77
157
  instr += `
@@ -91,7 +171,7 @@ const getProbaAndOpposite = (decimal = false) => {
91
171
  }
92
172
  };
93
173
  const getStartStatement = (identifiers) => {
94
- return identifiers.probaName;
174
+ return getTrueProbaName(identifiers);
95
175
  };
96
176
  const getProbabilityTree = (opts) => {
97
177
  const isDecimal = opts?.probaType === "Décimales";
@@ -122,6 +202,9 @@ const getProbabilityTree = (opts) => {
122
202
  case 3: //simple
123
203
  probaName = random(["P(A)", "P(B)"]);
124
204
  break;
205
+ case 4: //inversion
206
+ probaName = random(["P_C(A)", "P_D(A)", "P_C(B)", "P_D(B)"]);
207
+ break;
125
208
  }
126
209
  const identifiers = {
127
210
  A: pA.toIdentifiers(),
@@ -131,58 +214,254 @@ const getProbabilityTree = (opts) => {
131
214
  BC: pCSachantB.toIdentifiers(),
132
215
  BD: pDSachantB.toIdentifiers(),
133
216
  probaName,
217
+ useContraryNames: opts?.eventsNames === "Événements et leur contraire",
134
218
  };
135
219
  return getQuestionFromIdentifiers(identifiers, opts);
136
220
  };
221
+ const getHint = (identifiers) => {
222
+ const { probaName, useContraryNames } = identifiers;
223
+ const type = getProbaType(identifiers);
224
+ const trueProbaName = getTrueProbaName(identifiers);
225
+ switch (type) {
226
+ case "conditionnelle": {
227
+ const splitted = probaName
228
+ .replaceAll("(", "")
229
+ .replaceAll(")", "")
230
+ .split("_")[1];
231
+ const under = splitted[0];
232
+ const trueUnder = useContraryNames && under === "B" ? "\\overline{A}" : under;
233
+ const over = splitted[1];
234
+ const trueOver = useContraryNames
235
+ ? over === "C"
236
+ ? "B"
237
+ : "\\overline{B}"
238
+ : over;
239
+ return `La probabilité $${trueProbaName}$ est la probabilité de $${trueOver}$ sachant $${trueUnder}$.
240
+
241
+ Dans l'arbre, elle se lit sur la branche partant de $${trueUnder}$ et allant jusqu'à $${trueOver}$.`;
242
+ }
243
+ case "inter": {
244
+ const [first, second] = probaName
245
+ .replaceAll("P(", "")
246
+ .replaceAll(")", "")
247
+ .split("\\cap ");
248
+ const trueFirst = useContraryNames && first === "B" ? "\\overline{A}" : first;
249
+ const trueSecond = useContraryNames
250
+ ? second === "C"
251
+ ? "B"
252
+ : "\\overline{B}"
253
+ : second;
254
+ return `La probabilité $${trueProbaName}$ est la probabilité d'une intersection.
255
+
256
+ Pour la calculer, il faut multiplier les probabilités présentes sur les branches suivant le chemin $${trueFirst}$ puis $${trueSecond}$.
257
+ `;
258
+ }
259
+ case "totale": {
260
+ const evenement = probaName[2];
261
+ const trueEvenement = useContraryNames
262
+ ? evenement === "C"
263
+ ? "B"
264
+ : "\\overline{B}"
265
+ : evenement;
266
+ return `Il y a plusieurs chemins qui mènent à l'événement $${trueEvenement}$. Sa probabilité est la somme des probabilités de chacun de ces chemins. Pour obtenir la probabilité d'un chemin, il faut multiplier les probabilités présentes sur les branches de ce chemin.`;
267
+ }
268
+ case "simple": {
269
+ const trueEvent = useContraryNames && probaName[2] === "B"
270
+ ? "\\overline{A}"
271
+ : probaName[2];
272
+ return `La probabilité $${trueProbaName}$ se lit sur la branche menant à l'événement $${trueEvent}$.`;
273
+ }
274
+ case "inversion": {
275
+ const splitted = probaName
276
+ .replaceAll("(", "")
277
+ .replaceAll(")", "")
278
+ .split("_")[1];
279
+ const under = splitted[0];
280
+ const trueUnder = useContraryNames
281
+ ? under === "C"
282
+ ? "B"
283
+ : "\\overline{B}"
284
+ : under;
285
+ const over = splitted[1];
286
+ const trueOver = useContraryNames && over === "B" ? "\\overline{A}" : over;
287
+ return `La probabilité $${trueProbaName}$ est la probabilité de $${trueOver}$ sachant $${trueUnder}$.
288
+
289
+ Pour la déterminer, tu peux revenir à la définition d'une probabilité conditionnelle : pour deux évenements $M$ et $N$, on a :
290
+
291
+ $$
292
+ P_M(N) = \\frac{P(M \\cap N)}{P(M)}
293
+ $$
294
+ `;
295
+ }
296
+ }
297
+ };
298
+ const getCorrection = (identifiers) => {
299
+ const { probaName } = identifiers;
300
+ const probas = buildAll(identifiers);
301
+ const type = getProbaType(identifiers);
302
+ const trueProbaName = getTrueProbaName(identifiers);
303
+ const { useContraryNames } = identifiers;
304
+ switch (type) {
305
+ case "conditionnelle": {
306
+ const splitted = probaName
307
+ .replaceAll("(", "")
308
+ .replaceAll(")", "")
309
+ .split("_")[1];
310
+ const under = splitted[0];
311
+ const trueUnder = useContraryNames && under === "B" ? "\\overline{A}" : under;
312
+ const over = splitted[1];
313
+ const trueOver = useContraryNames
314
+ ? over === "C"
315
+ ? "B"
316
+ : "\\overline{B}"
317
+ : over;
318
+ return `La probabilité $${trueProbaName}$ est la probabilité de $${trueOver}$ sachant $${trueUnder}$.
319
+
320
+ Dans l'arbre, elle se lit sur la branche partant de $${trueUnder}$ et allant jusqu'à $${trueOver}$.
321
+
322
+ On a donc :
323
+
324
+ $$
325
+ ${trueProbaName} = ${getAnswer(identifiers)}
326
+ $$`;
327
+ }
328
+ case "inter": {
329
+ const [first, second] = probaName
330
+ .replaceAll("P(", "")
331
+ .replaceAll(")", "")
332
+ .split("\\cap ");
333
+ const firstProba = first === "A" ? probas.pA : probas.pB;
334
+ const secondProba = second === "C"
335
+ ? first === "A"
336
+ ? probas.pAC
337
+ : probas.pBC
338
+ : first === "A"
339
+ ? probas.pAD
340
+ : probas.pBD;
341
+ const trueFirst = useContraryNames && first === "B" ? "\\overline{A}" : first;
342
+ const secondFirst = useContraryNames
343
+ ? second === "C"
344
+ ? "B"
345
+ : "\\overline{B}"
346
+ : second;
347
+ return `La probabilité $${trueProbaName}$ est la probabilité d'une intersection.
348
+
349
+ Pour la calculer, il faut multiplier les probabilités présentes sur les branches suivant le chemin $${trueFirst}$ puis $${secondFirst}$.
350
+
351
+ On a donc :
352
+
353
+ $$
354
+ ${trueProbaName} = ${multiply(firstProba, secondProba).toSimplificationTex()}
355
+ $$
356
+ `;
357
+ }
358
+ case "totale": {
359
+ const evenement = probaName[2];
360
+ const trueEvenement = useContraryNames
361
+ ? evenement === "C"
362
+ ? "B"
363
+ : "\\overline{B}"
364
+ : evenement;
365
+ const first = evenement === "C" ? probas.pAC : probas.pAD;
366
+ const second = evenement === "C" ? probas.pBC : probas.pBD;
367
+ const firstWay = multiply(probas.pA, first);
368
+ const secondWay = multiply(probas.pB, second);
369
+ return `Il y a plusieurs chemins qui mènent à l'événement $${trueEvenement}$ : le chemin de l'intersection $A\\cap ${trueEvenement}$ et celui de l'intersection $${useContraryNames ? "\\overline{A}" : "B"}\\cap ${trueEvenement}$. La probabilité $${trueProbaName}$ est la somme des probabilités de ces chemins.
370
+
371
+ On a :
372
+
373
+ $$
374
+ P(A\\cap ${trueEvenement}) = ${firstWay.toSimplificationTex()}
375
+ $$
376
+
377
+ et
378
+
379
+ $$
380
+ P(${useContraryNames ? "\\overline{A}" : "B"}\\cap ${trueEvenement}) = ${secondWay.toSimplificationTex()}
381
+ $$
382
+
383
+ Donc :
384
+
385
+ $$
386
+ ${trueProbaName} = ${add(firstWay.simplify(), secondWay.simplify()).toSimplificationTex()}
387
+ $$
388
+ `;
389
+ }
390
+ case "simple": {
391
+ const trueEvent = useContraryNames && probaName[2] === "B"
392
+ ? "\\overline{A}"
393
+ : probaName[2];
394
+ return `La probabilité $${trueProbaName}$ se lit sur la branche menant à l'événement $${trueEvent}$.
395
+
396
+ On a donc :
397
+
398
+ $$
399
+ ${trueProbaName} = ${getAnswer(identifiers)}
400
+ $$`;
401
+ }
402
+ case "inversion": {
403
+ const splitted = probaName
404
+ .replaceAll("(", "")
405
+ .replaceAll(")", "")
406
+ .split("_")[1];
407
+ const under = splitted[0];
408
+ const trueUnder = useContraryNames
409
+ ? under === "C"
410
+ ? "B"
411
+ : "\\overline{B}"
412
+ : under;
413
+ const over = splitted[1];
414
+ const trueOver = useContraryNames && over === "B" ? "\\overline{A}" : over;
415
+ const total = add(multiply(probas.pA, under === "C" ? probas.pAC : probas.pAD), multiply(probas.pB, under === "C" ? probas.pBC : probas.pBD));
416
+ const inter = multiply(over === "A" ? probas.pA : probas.pB, under === "C"
417
+ ? over === "A"
418
+ ? probas.pAC
419
+ : probas.pBC
420
+ : over === "A"
421
+ ? probas.pAD
422
+ : probas.pBD);
423
+ return `La probabilité $${trueProbaName}$ est la probabilité de $${trueOver}$ sachant $${trueUnder}$.
424
+
425
+ Pour la déterminer, on revient à la définition d'une probabilité conditionnelle :
426
+
427
+ $$
428
+ ${trueProbaName} = \\frac{P(${trueOver} \\cap ${trueUnder})}{P(${trueUnder})}
429
+ $$
430
+
431
+ On calcule donc d'abord $P(${trueOver} \\cap ${trueUnder})$ :
432
+
433
+ $$
434
+ P(${trueOver} \\cap ${trueUnder}) = ${inter.toSimplificationTex()}
435
+ $$
436
+
437
+ Puis on calcule la probabilité totale $P(${trueUnder})$ :
438
+
439
+ $$
440
+ P(${trueUnder})=${total.toSimplificationTex()}
441
+ $$
442
+
443
+ On a donc :
444
+
445
+ $$
446
+ ${trueProbaName} = ${frac(inter.simplify(), total.simplify()).toSimplificationTex()}
447
+ $$
448
+ `;
449
+ }
450
+ }
451
+ };
137
452
  const getQuestionFromIdentifiers = (identifiers, opts) => {
138
453
  const question = {
139
454
  instruction: getInstruction(identifiers, opts),
140
455
  startStatement: getStartStatement(identifiers, opts),
141
- answer: getAnswer(identifiers),
456
+ answer: getAnswer(identifiers, opts),
142
457
  keys: [],
143
- ggbOptions: getGGBOptions(identifiers, opts),
144
458
  answerFormat: "tex",
145
459
  identifiers,
460
+ hint: getHint(identifiers, opts),
461
+ correction: getCorrection(identifiers, opts),
146
462
  };
147
463
  return question;
148
464
  };
149
- const getGGBOptions = (identifiers) => {
150
- const probas = buildAll(identifiers);
151
- const commands = [
152
- "A = Point({2,2})",
153
- "B = Point({2,-2})",
154
- "AC = Point({5,3})",
155
- "AD = Point({5,1})",
156
- "BC = Point({5,-1})",
157
- "BD = Point({5,-3})",
158
- "Segment(Point({0,0}),A)",
159
- "Segment(A,AC)",
160
- "Segment(A,AD)",
161
- "Segment(Point({0,0}),B)",
162
- "Segment(B,BC)",
163
- "Segment(B,BD)",
164
- `Text("\\scriptsize ${probas.pA.toTex()}", (0.1, 2.2), true, true)`,
165
- `Text("\\scriptsize ${probas.pAC.toTex()}", (2.8, 4), true, true)`,
166
- `Text("\\scriptsize ${probas.pAD.toTex()}", (2.8, 1.6), true, true)`,
167
- `Text("\\scriptsize ${probas.pB.toTex()}", (0.1, -0.8), true, true)`,
168
- `Text("\\scriptsize ${probas.pBC.toTex()}", (2.8, -0.6), true, true)`,
169
- `Text("\\scriptsize ${probas.pBD.toTex()}", (2.8, -2.5), true, true)`,
170
- 'Text("A", (1.85 , 2.5))',
171
- 'Text("B", (1.85 , -2.8))',
172
- 'Text("C", (5.5 , 2.85))',
173
- 'Text("D", (5.5 , 0.85))',
174
- 'Text("C", (5.5 , -1.1))',
175
- 'Text("D", (5.5 , -3.1))',
176
- ];
177
- const ggb = new GeogebraConstructor({
178
- commands,
179
- hideAxes: true,
180
- hideGrid: true,
181
- });
182
- return ggb.getOptions({
183
- coords: [-2, 8, -5, 5],
184
- });
185
- };
186
465
  const getPropositions = (n, { answer, ...identifiers }) => {
187
466
  const propositions = [];
188
467
  addValidProp(propositions, answer);
@@ -233,19 +512,114 @@ const options = [
233
512
  defaultValue: "Fractions",
234
513
  values: ["Fractions", "Décimales"],
235
514
  },
515
+ {
516
+ id: "eventsNames",
517
+ label: "Noms des événements",
518
+ target: GeneratorOptionTarget.generation,
519
+ type: GeneratorOptionType.select,
520
+ defaultValue: "Événements et leur contraire",
521
+ values: [
522
+ "Événements et leur contraire",
523
+ "Noms d'événements tous différents",
524
+ ],
525
+ },
236
526
  ];
527
+ const partialOptions = options.filter((p) => p.id !== "eventTypes");
237
528
  export const probabilityTree = {
238
529
  id: "probabilityTree",
239
530
  connector: "=",
240
- label: "Calculs de probabilités à l'aide d'un arbre pondéré",
531
+ label: "Calculer une probabilité dans un arbre pondéré (tous calculs)",
241
532
  isSingleStep: false,
242
533
  generator: (nb, opts) => getDistinctQuestions(() => getProbabilityTree(opts), nb),
243
534
  qcmTimer: 60,
244
535
  freeTimer: 60,
245
536
  getPropositions,
246
537
  isAnswerValid,
247
- hasGeogebra: true,
248
538
  subject: "Mathématiques",
249
539
  options,
250
540
  getQuestionFromIdentifiers,
541
+ hasHintAndCorrection: true,
542
+ };
543
+ export const probabilityTreeIntersection = {
544
+ id: "probabilityTreeIntersection",
545
+ connector: "=",
546
+ label: "Calculer une intersection dans un arbre pondéré",
547
+ isSingleStep: false,
548
+ generator: (nb, opts) => getDistinctQuestions(() => getProbabilityTree({
549
+ eventTypes: ["Probabilité d'intersection $P(A\\cap C)$"],
550
+ allowApproximate: opts?.allowApproximate,
551
+ probaType: opts?.probaType,
552
+ eventsNames: opts?.eventsNames,
553
+ }), nb),
554
+ qcmTimer: 60,
555
+ freeTimer: 60,
556
+ getPropositions,
557
+ isAnswerValid,
558
+ subject: "Mathématiques",
559
+ options: partialOptions,
560
+ getQuestionFromIdentifiers,
561
+ hasHintAndCorrection: true,
562
+ };
563
+ export const probabilityTreeTotalProbability = {
564
+ id: "probabilityTreeTotalProbability",
565
+ connector: "=",
566
+ label: "Calculer une probabilité totale dans un arbre pondéré",
567
+ isSingleStep: false,
568
+ generator: (nb, opts) => getDistinctQuestions(() => getProbabilityTree({
569
+ eventTypes: ["Probabilité totale $P(C)$"],
570
+ allowApproximate: opts?.allowApproximate,
571
+ probaType: opts?.probaType,
572
+ eventsNames: opts?.eventsNames,
573
+ }), nb),
574
+ qcmTimer: 60,
575
+ freeTimer: 60,
576
+ getPropositions,
577
+ isAnswerValid,
578
+ subject: "Mathématiques",
579
+ options: partialOptions,
580
+ getQuestionFromIdentifiers,
581
+ hasHintAndCorrection: true,
582
+ };
583
+ export const probabilityTreeReadProbability = {
584
+ id: "probabilityTreeReadProbability",
585
+ connector: "=",
586
+ label: "Lire une probabilité dans un arbre pondéré",
587
+ isSingleStep: false,
588
+ generator: (nb, opts) => getDistinctQuestions(() => getProbabilityTree({
589
+ eventTypes: [
590
+ "Probabilité conditionnelle $P_B(A)$",
591
+ "Probabilité 'simple' $P(A)$",
592
+ ],
593
+ allowApproximate: opts?.allowApproximate,
594
+ probaType: opts?.probaType,
595
+ eventsNames: opts?.eventsNames,
596
+ }), nb),
597
+ qcmTimer: 60,
598
+ freeTimer: 60,
599
+ getPropositions,
600
+ isAnswerValid,
601
+ subject: "Mathématiques",
602
+ options: partialOptions,
603
+ getQuestionFromIdentifiers,
604
+ hasHintAndCorrection: true,
605
+ };
606
+ export const probabilityTreeInversionProbability = {
607
+ id: "probabilityTreeInversionProbability",
608
+ connector: "=",
609
+ label: "Calculer une probabilité d'inversion de causalité du type $P_B(A)$ dans un arbre pondéré",
610
+ isSingleStep: false,
611
+ generator: (nb, opts) => getDistinctQuestions(() => getProbabilityTree({
612
+ eventTypes: ["Probabilité d'inversion de causalité $P_B(A)$"],
613
+ allowApproximate: opts?.allowApproximate,
614
+ probaType: opts?.probaType,
615
+ eventsNames: opts?.eventsNames,
616
+ }), nb),
617
+ qcmTimer: 60,
618
+ freeTimer: 60,
619
+ getPropositions,
620
+ isAnswerValid,
621
+ subject: "Mathématiques",
622
+ options: partialOptions,
623
+ getQuestionFromIdentifiers,
624
+ hasHintAndCorrection: true,
251
625
  };
@@ -1 +1 @@
1
- {"version":3,"file":"arithmeticFindRankFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAKhE,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAM1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAsOF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmB1E,CAAC"}
1
+ {"version":3,"file":"arithmeticFindRankFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAKhE,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAM1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA0OF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmB1E,CAAC"}
@@ -42,7 +42,7 @@ const getCorrection = (identifiers, optsIn) => {
42
42
  const firstRank = opts?.firstTermRankOne ? 1 : 0;
43
43
  const { situationIndex, initial, reason, valueAsked } = identifiers;
44
44
  const situation = situations[situationIndex];
45
- return situation.variationFindRank.getCorrectionStuff(initial, reason, firstRank, valueAsked, situation.rankDecoder).str;
45
+ return situation.variationFindRank.getCorrectionStuff(initial, reason, firstRank, valueAsked, situation.rankDecoder, situation.digitsValue, situation.digitsTarget).str;
46
46
  };
47
47
  const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
48
48
  const opts = optsIn ?? optsDefault;
@@ -54,12 +54,12 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
54
54
  const arrNodeWrong = [];
55
55
  //student: uses valueAsked as if it were rankAsked
56
56
  {
57
- const nodeWrong = situation.variationFindRandomTerm.getAnswerNode(initial, reason, firstRank, valueAsked);
57
+ const nodeWrong = situation.variationFindRandomTerm.getAnswerNode(initial, reason, firstRank, valueAsked, situation.rankDecoder);
58
58
  tryToAddWrongProp(propositions, nodeWrong.simplify().toTex());
59
59
  arrNodeWrong.push(nodeWrong);
60
60
  }
61
61
  const rankValid = (() => {
62
- const { rankNode } = situation.variationFindRank.getAnswerStuff(initial, reason, firstRank, valueAsked);
62
+ const { rankNode } = situation.variationFindRank.getAnswerStuff(initial, reason, firstRank, valueAsked, situation.rankDecoder);
63
63
  return round(rankNode.evaluate(), 0);
64
64
  })();
65
65
  //pseudo terror
@@ -1 +1 @@
1
- {"version":3,"file":"arithmeticFindThresholdFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAGhE,OAAO,EACL,gBAAgB,EAGjB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAM1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,gBAAgB,CAAC;CAC9B,CAAC;AA0PF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,oCAAoC,EAAE,QAAQ,CACzD,WAAW,EACX,OAAO,CAoBR,CAAC"}
1
+ {"version":3,"file":"arithmeticFindThresholdFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAGhE,OAAO,EACL,gBAAgB,EAGjB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAM1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,gBAAgB,CAAC;CAC9B,CAAC;AA6PF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,oCAAoC,EAAE,QAAQ,CACzD,WAAW,EACX,OAAO,CAoBR,CAAC"}
@@ -46,7 +46,7 @@ const getCorrection = (identifiers, optsIn) => {
46
46
  const { situationIndex, initial, reason, valueThreshold, inegSymbol } = identifiers;
47
47
  const situation = situations[situationIndex];
48
48
  const inequationSymbol = new InequationSymbol(inegSymbol);
49
- return situation.variationFindThreshold.getCorrectionStuff(initial, reason, firstRank, valueThreshold, inequationSymbol, situation.rankDecoder).str;
49
+ return situation.variationFindThreshold.getCorrectionStuff(initial, reason, firstRank, valueThreshold, inequationSymbol, situation.rankDecoder, situation.digitsValue, situation.digitsTarget).str;
50
50
  };
51
51
  const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
52
52
  const opts = optsIn ?? optsDefault;
@@ -58,7 +58,7 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
58
58
  addValidProp(propositions, answer);
59
59
  const arrNodeWrong = [];
60
60
  const rankValid = (() => {
61
- const { rankNode } = situation.variationFindRank.getAnswerStuff(initial, reason, firstRank, valueThreshold, inequationSymbol);
61
+ const { rankNode } = situation.variationFindThreshold.getAnswerStuff(initial, reason, firstRank, valueThreshold, inequationSymbol, situation.rankDecoder);
62
62
  return round(rankNode.evaluate(), 0);
63
63
  })();
64
64
  //student: gives u[threshold] instead of threshold
@@ -1,4 +1,6 @@
1
1
  export * from "./arithmeticFindExplicitFormulaFromSituation.js";
2
2
  export * from "./arithmeticFindRecurrenceFormulaFromSituation.js";
3
3
  export * from "./arithmeticFindTermFromSituation.js";
4
+ export * from "./arithmeticFindRankFromSituation.js";
5
+ export * from "./arithmeticFindThresholdFromSituation.js";
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/index.ts"],"names":[],"mappings":"AAAA,cAAc,iDAAiD,CAAC;AAChE,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/index.ts"],"names":[],"mappings":"AAAA,cAAc,iDAAiD,CAAC;AAChE,cAAc,mDAAmD,CAAC;AAClE,cAAc,sCAAsC,CAAC;AAErD,cAAc,sCAAsC,CAAC;AACrD,cAAc,2CAA2C,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export * from "./arithmeticFindExplicitFormulaFromSituation.js";
2
2
  export * from "./arithmeticFindRecurrenceFormulaFromSituation.js";
3
3
  export * from "./arithmeticFindTermFromSituation.js";
4
- // export * from "./arithmeticFindRankFromSituation.js";
5
- // export * from "./arithmeticFindThresholdFromSituation.js";
4
+ export * from "./arithmeticFindRankFromSituation.js";
5
+ export * from "./arithmeticFindThresholdFromSituation.js";
package/lib/index.d.ts CHANGED
@@ -3380,6 +3380,19 @@ declare const mathExercises: (Exercise<{
3380
3380
  reason: number;
3381
3381
  superfluousData?: import("./math/utils/sequences/situations/seqArithmeticSituations.js").SituationArithmeticSuperfluousData;
3382
3382
  rankAsked: number;
3383
+ }, import("./exercises/options/optionFirstTermRankOne.js").OptionFirstTermRankOne & import("./exercises/options/optionIsWithSuperfluousData.js").OptionIsWithSuperfluousData> | Exercise<{
3384
+ situationIndex: number;
3385
+ initial: number;
3386
+ reason: number;
3387
+ superfluousData?: import("./math/utils/sequences/situations/seqArithmeticSituations.js").SituationArithmeticSuperfluousData;
3388
+ valueAsked: number;
3389
+ }, import("./exercises/options/optionFirstTermRankOne.js").OptionFirstTermRankOne & import("./exercises/options/optionIsWithSuperfluousData.js").OptionIsWithSuperfluousData> | Exercise<{
3390
+ situationIndex: number;
3391
+ initial: number;
3392
+ reason: number;
3393
+ superfluousData?: import("./math/utils/sequences/situations/seqArithmeticSituations.js").SituationArithmeticSuperfluousData;
3394
+ valueThreshold: number;
3395
+ inegSymbol: import("./math/inequations/inequation.js").InegalitySymbols;
3383
3396
  }, import("./exercises/options/optionFirstTermRankOne.js").OptionFirstTermRankOne & import("./exercises/options/optionIsWithSuperfluousData.js").OptionIsWithSuperfluousData> | Exercise<{
3384
3397
  final: number;
3385
3398
  }, Record<string, string | boolean | string[]>> | Exercise<{