math-exercises 2.2.33 → 2.2.35

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 (57) hide show
  1. package/README.md +6 -62
  2. package/lib/exercises/math/calcul/proportionality/proportionalityTable.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/proportionality/proportionalityTable.js +18 -8
  4. package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.js +18 -10
  6. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts +2 -0
  7. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -1
  8. package/lib/exercises/math/functions/affines/affineAdjustment.js +16 -8
  9. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts +2 -0
  10. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -1
  11. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +7 -6
  12. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts +2 -0
  13. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -1
  14. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +7 -6
  15. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.js +19 -7
  17. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.d.ts.map +1 -1
  18. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.js +3 -1
  19. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.js +2 -2
  20. package/lib/exercises/math/percent/globalPercent.d.ts.map +1 -1
  21. package/lib/exercises/math/percent/globalPercent.js +3 -4
  22. package/lib/exercises/math/percent/isTableProportional.d.ts +4 -1
  23. package/lib/exercises/math/percent/isTableProportional.d.ts.map +1 -1
  24. package/lib/exercises/math/percent/isTableProportional.js +13 -9
  25. package/lib/exercises/math/percent/populationEffectifFromSubPopulation.d.ts.map +1 -1
  26. package/lib/exercises/math/percent/populationEffectifFromSubPopulation.js +9 -3
  27. package/lib/exercises/math/percent/reciprocalPercentage.d.ts.map +1 -1
  28. package/lib/exercises/math/percent/reciprocalPercentage.js +3 -4
  29. package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
  30. package/lib/exercises/math/probaStat/probaFromTableNoContext.js +35 -18
  31. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  32. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +26 -18
  33. package/lib/exercises/math/probaStat/stats1var/averageWithTable.d.ts.map +1 -1
  34. package/lib/exercises/math/probaStat/stats1var/averageWithTable.js +17 -9
  35. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.d.ts.map +1 -1
  36. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +81 -38
  37. package/lib/exercises/math/probaStat/stats1var/median.d.ts +1 -0
  38. package/lib/exercises/math/probaStat/stats1var/median.d.ts.map +1 -1
  39. package/lib/exercises/math/probaStat/stats1var/median.js +16 -8
  40. package/lib/exercises/math/probaStat/stats1var/quartiles.d.ts.map +1 -1
  41. package/lib/exercises/math/probaStat/stats1var/quartiles.js +16 -24
  42. package/lib/exercises/math/probaStat/stats2var/averagePoint.d.ts.map +1 -1
  43. package/lib/exercises/math/probaStat/stats2var/averagePoint.js +18 -10
  44. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -1
  45. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +42 -29
  46. package/lib/index.d.ts +11 -1
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/utils/latex/dollarize.d.ts +2 -0
  49. package/lib/utils/latex/dollarize.d.ts.map +1 -0
  50. package/lib/utils/latex/dollarize.js +7 -0
  51. package/lib/utils/markdown/mdCode.d.ts +2 -0
  52. package/lib/utils/markdown/mdCode.d.ts.map +1 -0
  53. package/lib/utils/markdown/mdCode.js +9 -0
  54. package/lib/utils/markdown/mdTable.d.ts +2 -0
  55. package/lib/utils/markdown/mdTable.d.ts.map +1 -0
  56. package/lib/utils/markdown/mdTable.js +17 -0
  57. package/package.json +1 -1
@@ -7,6 +7,29 @@ const rational_1 = require("../../../math/numbers/rationals/rational");
7
7
  const randint_1 = require("../../../math/utils/random/randint");
8
8
  const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
9
9
  const random_1 = require("../../../utils/alea/random");
10
+ const dollarize_1 = require("../../../utils/latex/dollarize");
11
+ const mdTable_1 = require("../../../utils/markdown/mdTable");
12
+ const getInstruction = ({ aBarreCapB, aBarreCapBBarre, aCapB, aCapBBarre, event, probaFrac, type, }) => {
13
+ const total = aBarreCapB + aBarreCapBBarre + aCapB + aCapBBarre;
14
+ const aTotal = aCapB + aCapBBarre;
15
+ const bTotal = aCapB + aBarreCapB;
16
+ const aBarreTotal = aBarreCapB + aBarreCapBBarre;
17
+ const bBarreTotal = aBarreCapBBarre + aCapBBarre;
18
+ return `On considère deux événements $A$ et $B$. Le tableau suivant donne le nombre d'issues pour chacun des événements $A\\cap B$, $\\overline A\\cap B$, $A\\cap \\overline B$ et $\\overline A \\cap \\overline B$. Calculer la probabilité $${event}$.
19
+
20
+ ${(0, mdTable_1.mdTable)([
21
+ [" ", "$B$", "$\\overline{B}$", "Total"],
22
+ ["$A$", (0, dollarize_1.dollarize)(aCapB), `$${aCapBBarre}$`, `$${aTotal}$`],
23
+ [
24
+ "$\\overline{A}$",
25
+ (0, dollarize_1.dollarize)(aBarreCapB),
26
+ (0, dollarize_1.dollarize)(aBarreCapBBarre),
27
+ (0, dollarize_1.dollarize)(aBarreTotal),
28
+ ],
29
+ ["Total", (0, dollarize_1.dollarize)(bTotal), (0, dollarize_1.dollarize)(bBarreTotal), (0, dollarize_1.dollarize)(total)],
30
+ ])}
31
+ `;
32
+ };
10
33
  const getProbaFromTableNoContextQuestion = () => {
11
34
  const aCapB = (0, randint_1.randint)(1, 20);
12
35
  const aCapBBarre = (0, randint_1.randint)(1, 20, [aCapB]);
@@ -58,28 +81,21 @@ const getProbaFromTableNoContextQuestion = () => {
58
81
  ]);
59
82
  }
60
83
  const answer = new rational_1.Rational(proba[0], proba[1]).simplify().toTree().toTex();
84
+ const identifiers = {
85
+ aBarreCapB,
86
+ aBarreCapBBarre,
87
+ aCapB,
88
+ aCapBBarre,
89
+ event,
90
+ type,
91
+ probaFrac: proba,
92
+ };
61
93
  const question = {
62
94
  answer,
63
- instruction: `On considère deux événements $A$ et $B$. Le tableau suivant donne le nombre d'issues pour chacun des événements $A\\cap B$, $\\overline A\\cap B$, $A\\cap \\overline B$ et $\\overline A \\cap \\overline B$. Calculer la probabilité $${event}$.
64
-
65
- | | $B$ | $\\overline{B}$| Total
66
- |-|-|-|-|
67
- |$A$|${aCapB}|${aCapBBarre}|${aTotal}|
68
- |$\\overline{A}$|${aBarreCapB}|${aBarreCapBBarre}|${aBarreTotal}|
69
- |Total|${bTotal}|${bBarreTotal}|${total}|
70
-
71
- `,
95
+ instruction: getInstruction(identifiers),
72
96
  keys: [],
73
97
  answerFormat: "tex",
74
- identifiers: {
75
- aBarreCapB,
76
- aBarreCapBBarre,
77
- aCapB,
78
- aCapBBarre,
79
- event,
80
- type,
81
- probaFrac: proba,
82
- },
98
+ identifiers,
83
99
  };
84
100
  return question;
85
101
  };
@@ -114,4 +130,5 @@ exports.probaFromTableNoContext = {
114
130
  getPropositions,
115
131
  isAnswerValid,
116
132
  subject: "Mathématiques",
133
+ getInstruction,
117
134
  };
@@ -1 +1 @@
1
- {"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAOlC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAsHF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAe3D,CAAC"}
1
+ {"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAoIF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAgB3D,CAAC"}
@@ -7,6 +7,20 @@ const rational_1 = require("../../../math/numbers/rationals/rational");
7
7
  const randint_1 = require("../../../math/utils/random/randint");
8
8
  const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
9
9
  const random_1 = require("../../../utils/alea/random");
10
+ const dollarize_1 = require("../../../utils/latex/dollarize");
11
+ const mdTable_1 = require("../../../utils/markdown/mdTable");
12
+ const getInstruction = ({ aBarreCapB, aBarreCapBBarre, aCapB, aCapBBarre, event, probaFrac, type, }) => {
13
+ return `Le tableau suivant donne le nombre de filles et de garçons portant des lunettes dans un lycée :
14
+
15
+ ${(0, mdTable_1.mdTable)([
16
+ [" ", "Porte des lunettes", "Ne porte pas de lunettes"],
17
+ ["Filles", (0, dollarize_1.dollarize)(aCapB), (0, dollarize_1.dollarize)(aCapBBarre)],
18
+ ["Garçons", (0, dollarize_1.dollarize)(aBarreCapB), (0, dollarize_1.dollarize)(aBarreCapBBarre)],
19
+ ])}
20
+
21
+ On choisit un élève au hasard. Quelle est la probabilité de tomber sur ${event} ?
22
+ `;
23
+ };
10
24
  const getProbaFromTableWithContextQuestion = () => {
11
25
  const aCapB = (0, randint_1.randint)(1, 20);
12
26
  const aCapBBarre = (0, randint_1.randint)(1, 20);
@@ -63,28 +77,21 @@ const getProbaFromTableWithContextQuestion = () => {
63
77
  break;
64
78
  }
65
79
  const answer = new rational_1.Rational(proba[0], proba[1]).simplify().toTree().toTex();
80
+ const identifiers = {
81
+ aBarreCapB,
82
+ aBarreCapBBarre,
83
+ aCapB,
84
+ aCapBBarre,
85
+ event,
86
+ type,
87
+ probaFrac: proba,
88
+ };
66
89
  const question = {
67
90
  answer,
68
- instruction: `Le tableau suivant donne le nombre de filles et de garçons portant des lunettes dans un lycée :
69
-
70
- | | Porte des lunettes | Ne porte pas de lunettes |
71
- |-------|:----------------------:|----------------------------|
72
- |Filles |${aCapB} |${aCapBBarre}|
73
- |Garçons |${aBarreCapB} |${aBarreCapBBarre} |
74
-
75
- On choisit un élève au hasard. Quelle est la probabilité de tomber sur ${event} ?
76
- `,
91
+ instruction: getInstruction(identifiers),
77
92
  keys: [],
78
93
  answerFormat: "tex",
79
- identifiers: {
80
- aBarreCapB,
81
- aBarreCapBBarre,
82
- aCapB,
83
- aCapBBarre,
84
- event,
85
- type,
86
- probaFrac: proba,
87
- },
94
+ identifiers,
88
95
  };
89
96
  return question;
90
97
  };
@@ -119,4 +126,5 @@ exports.probaFromTableWithContext = {
119
126
  getPropositions,
120
127
  isAnswerValid,
121
128
  subject: "Mathématiques",
129
+ getInstruction,
122
130
  };
@@ -1 +1 @@
1
- {"version":3,"file":"averageWithTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/averageWithTable.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EAQT,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAwEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
1
+ {"version":3,"file":"averageWithTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/averageWithTable.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAgFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAelD,CAAC"}
@@ -4,8 +4,20 @@ exports.averageWithTable = void 0;
4
4
  const randint_1 = require("../../../../math/utils/random/randint");
5
5
  const round_1 = require("../../../../math/utils/round");
6
6
  const shuffle_1 = require("../../../../utils/alea/shuffle");
7
+ const mdTable_1 = require("../../../../utils/markdown/mdTable");
8
+ const dollarize_1 = require("../../../../utils/latex/dollarize");
7
9
  const exercise_1 = require("../../../exercise");
8
10
  const getDistinctQuestions_1 = require("../../../utils/getDistinctQuestions");
11
+ const getInstruction = ({ randomEffectives, randomValues, }) => {
12
+ return `On considère le tableau d'effectifs suivant :
13
+
14
+ ${(0, mdTable_1.mdTable)([
15
+ ["Valeur", ...randomValues.map((e) => (0, dollarize_1.dollarize)(e))],
16
+ ["Effectif", ...randomEffectives.map((e) => (0, dollarize_1.dollarize)(e))],
17
+ ])}
18
+
19
+ Calculer la moyenne de cette série de valeurs (arrondir au centième).`;
20
+ };
9
21
  const getAverageWithTableQuestion = () => {
10
22
  const getRandomUniqueValues = (count, min, max) => {
11
23
  const uniqueValues = new Set();
@@ -22,20 +34,15 @@ const getAverageWithTableQuestion = () => {
22
34
  average += randomValues[i] * randomEffectives[i];
23
35
  average /= sumEffectives;
24
36
  average = (0, round_1.round)(average, 2);
37
+ const identifiers = { randomEffectives, randomValues };
25
38
  const answer = (average + "").replace(".", ",");
26
39
  const question = {
27
- instruction: `On considère le tableau d'effectifs suivant :
28
-
29
- | | | | | | |
30
- |-|-|-|-|-|-|
31
- |Valeur|${randomValues[0]}|${randomValues[1]}|${randomValues[2]}|${randomValues[3]}|${randomValues[4]}|
32
- |Effectif|${randomEffectives[0]}|${randomEffectives[1]}|${randomEffectives[2]}|${randomEffectives[3]}|${randomEffectives[4]}|
33
-
34
- Calculer la moyenne de cette série de valeurs (arrondir au centième).`,
40
+ instruction: getInstruction(identifiers),
35
41
  answer,
36
42
  keys: [],
37
43
  answerFormat: "tex",
38
- identifiers: { randomEffectives, randomValues },
44
+ identifiers,
45
+ style: { tableHasNoHeader: true },
39
46
  };
40
47
  return question;
41
48
  };
@@ -66,4 +73,5 @@ exports.averageWithTable = {
66
73
  getPropositions,
67
74
  isAnswerValid,
68
75
  subject: "Mathématiques",
76
+ getInstruction,
69
77
  };
@@ -1 +1 @@
1
- {"version":3,"file":"marginalAndConditionalFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EAQT,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAmIF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAcjE,CAAC"}
1
+ {"version":3,"file":"marginalAndConditionalFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA8KF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAejE,CAAC"}
@@ -4,93 +4,135 @@ exports.marginalAndConditionalFrequency = void 0;
4
4
  const rational_1 = require("../../../../math/numbers/rationals/rational");
5
5
  const randint_1 = require("../../../../math/utils/random/randint");
6
6
  const shuffle_1 = require("../../../../utils/alea/shuffle");
7
+ const dollarize_1 = require("../../../../utils/latex/dollarize");
8
+ const mdTable_1 = require("../../../../utils/markdown/mdTable");
7
9
  const exercise_1 = require("../../../exercise");
8
10
  const getDistinctQuestions_1 = require("../../../utils/getDistinctQuestions");
9
- const getAnswer = (rand, x1, x2, x3, x4) => {
11
+ const getFreqStrings = (rand) => {
12
+ let freqString = "";
13
+ let frequence = "";
14
+ switch (rand) {
15
+ case 0:
16
+ freqString = "marginale de $A$";
17
+ frequence = "f(A)";
18
+ break;
19
+ case 1:
20
+ freqString = "marginale de $B$";
21
+ frequence = "f(B)";
22
+ break;
23
+ case 2:
24
+ freqString = "marginale de $C$";
25
+ frequence = "f(C)";
26
+ break;
27
+ case 3:
28
+ freqString = "marginale de $D$";
29
+ frequence = "f(D)";
30
+ break;
31
+ case 4:
32
+ freqString = "conditionnelle de $A$ parmi $C$";
33
+ frequence = "f_C(A)";
34
+ break;
35
+ case 5:
36
+ freqString = "conditionnelle de $A$ parmi $D$";
37
+ frequence = "f_D(A)";
38
+ break;
39
+ case 6:
40
+ freqString = "conditionnelle de $B$ parmi $C$";
41
+ frequence = "f_C(B)";
42
+ break;
43
+ case 7:
44
+ freqString = "conditionnelle de $B$ parmi $D$";
45
+ frequence = "f_D(B)";
46
+ break;
47
+ case 8:
48
+ freqString = "conditionnelle de $C$ parmi $A$";
49
+ frequence = "f_A(C)";
50
+ break;
51
+ case 9:
52
+ freqString = "conditionnelle de $C$ parmi $B$";
53
+ frequence = "f_B(C)";
54
+ break;
55
+ case 10:
56
+ freqString = "conditionnelle de $D$ parmi $A$";
57
+ frequence = "f_A(D)";
58
+ break;
59
+ case 11:
60
+ freqString = "conditionnelle de $D$ parmi $B$";
61
+ frequence = "f_B(D)";
62
+ break;
63
+ default:
64
+ throw Error("error");
65
+ }
66
+ return { freqString, frequence };
67
+ };
68
+ const getInstruction = ({ x1, x2, x3, x4, rand, }) => {
69
+ const { freqString } = getFreqStrings(rand);
70
+ return `On considère le tableau d'effectifs suivant :
71
+
72
+ ${(0, mdTable_1.mdTable)([
73
+ [" ", "$A$", "$B$"],
74
+ ["$C$", (0, dollarize_1.dollarize)(x1), (0, dollarize_1.dollarize)(x2)],
75
+ ["$D$", (0, dollarize_1.dollarize)(x3), (0, dollarize_1.dollarize)(x4)],
76
+ ])}
77
+
78
+ Calculer la fréquence ${freqString}.`;
79
+ };
80
+ const getAnswerNode = (rand, x1, x2, x3, x4) => {
10
81
  const x = x1 + x2 + x3 + x4;
11
82
  let freqString;
12
83
  let frequence;
13
84
  let answer;
14
85
  switch (rand) {
15
86
  case 0:
16
- freqString = "marginale de A";
17
- frequence = "f(A)";
18
87
  answer = new rational_1.Rational(x1 + x3, x).simplify().toTree();
19
88
  break;
20
89
  case 1:
21
- freqString = "marginale de B";
22
- frequence = "f(B)";
23
90
  answer = new rational_1.Rational(x2 + x4, x).simplify().toTree();
24
91
  break;
25
92
  case 2:
26
- freqString = "marginale de C";
27
- frequence = "f(C)";
28
93
  answer = new rational_1.Rational(x1 + x2, x).simplify().toTree();
29
94
  break;
30
95
  case 3:
31
- freqString = "marginale de D";
32
- frequence = "f(D)";
33
96
  answer = new rational_1.Rational(x3 + x4, x).simplify().toTree();
34
97
  break;
35
98
  case 4:
36
- freqString = "conditionnelle de A parmi C";
37
- frequence = "f_C(A)";
38
99
  answer = new rational_1.Rational(x1, x1 + x2).simplify().toTree();
39
100
  break;
40
101
  case 5:
41
- freqString = "conditionnelle de A parmi D";
42
- frequence = "f_D(A)";
43
102
  answer = new rational_1.Rational(x3, x3 + x4).simplify().toTree();
44
103
  break;
45
104
  case 6:
46
- freqString = "conditionnelle de B parmi C";
47
- frequence = "f_C(B)";
48
105
  answer = new rational_1.Rational(x2, x1 + x2).simplify().toTree();
49
106
  break;
50
107
  case 7:
51
- freqString = "conditionnelle de B parmi D";
52
- frequence = "f_D(B)";
53
108
  answer = new rational_1.Rational(x4, x3 + x4).simplify().toTree();
54
109
  break;
55
110
  case 8:
56
- freqString = "conditionnelle de C parmi A";
57
- frequence = "f_A(C)";
58
111
  answer = new rational_1.Rational(x1, x1 + x3).simplify().toTree();
59
112
  break;
60
113
  case 9:
61
- freqString = "conditionnelle de C parmi B";
62
- frequence = "f_B(C)";
63
114
  answer = new rational_1.Rational(x2, x2 + x4).simplify().toTree();
64
115
  break;
65
116
  case 10:
66
- freqString = "conditionnelle de D parmi A";
67
- frequence = "f_A(D)";
68
117
  answer = new rational_1.Rational(x3, x1 + x3).simplify().toTree();
69
118
  break;
70
119
  case 11:
71
- freqString = "conditionnelle de D parmi B";
72
- frequence = "f_B(D)";
73
120
  answer = new rational_1.Rational(x4, x2 + x4).simplify().toTree();
74
121
  break;
75
122
  default:
76
123
  throw Error("error");
77
124
  }
78
- return { answer, freqString, frequence };
125
+ return answer;
79
126
  };
80
127
  const getMarginalAndConditionalFrequency = () => {
81
128
  const [x1, x2, x3, x4] = [1, 2, 3, 4].map((el) => (0, randint_1.randint)(1, 100));
82
129
  const rand = (0, randint_1.randint)(0, 12);
83
- const { freqString, frequence, answer: answerTree, } = getAnswer(rand, x1, x2, x3, x4);
84
- const answer = answerTree.toTex();
130
+ const answerNode = getAnswerNode(rand, x1, x2, x3, x4);
131
+ const answer = answerNode.toTex();
132
+ const identifiers = { rand, x1, x2, x3, x4 };
133
+ const { frequence } = getFreqStrings(rand);
85
134
  const question = {
86
- instruction: `On considère le tableau d'effectifs suivant :
87
-
88
- | |A|B|
89
- |-|-|-|
90
- |C|${x1}|${x2}|
91
- |D|${x3}|${x4}|
92
-
93
- Calculer la fréquence ${freqString}.`,
135
+ instruction: getInstruction(identifiers),
94
136
  startStatement: `${frequence}`,
95
137
  answer,
96
138
  keys: ["f", "cap", "underscore"],
@@ -105,13 +147,13 @@ const getPropositions = (n, { answer, rand, x1, x2, x3, x4 }) => {
105
147
  while (propositions.length < n) {
106
148
  const fakeRand = (0, randint_1.randint)(0, 12);
107
149
  // console.log("marg and cond freq", answer, rand, x1, x2, x3, x4);
108
- const { answer: answerTree } = getAnswer(fakeRand, x1, x2, x3, x4);
150
+ const answerTree = getAnswerNode(fakeRand, x1, x2, x3, x4);
109
151
  (0, exercise_1.tryToAddWrongProp)(propositions, answerTree.toTex());
110
152
  }
111
153
  return (0, shuffle_1.shuffle)(propositions);
112
154
  };
113
155
  const isAnswerValid = (ans, { rand, x1, x2, x3, x4 }) => {
114
- const { answer: answerTree } = getAnswer(rand, x1, x2, x3, x4);
156
+ const answerTree = getAnswerNode(rand, x1, x2, x3, x4);
115
157
  const texs = answerTree.toAllValidTexs({ allowFractionToDecimal: true });
116
158
  return texs.includes(ans);
117
159
  };
@@ -128,4 +170,5 @@ exports.marginalAndConditionalFrequency = {
128
170
  getPropositions,
129
171
  isAnswerValid,
130
172
  subject: "Mathématiques",
173
+ getInstruction,
131
174
  };
@@ -1,6 +1,7 @@
1
1
  import { Exercise } from "../../../exercise";
2
2
  type Identifiers = {
3
3
  randomValues: number[];
4
+ randomEffectives: number[];
4
5
  };
5
6
  export declare const medianWithTable: Exercise<Identifiers>;
6
7
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"median.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/median.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EAQT,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA6EF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
1
+ {"version":3,"file":"median.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/median.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAmFF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
@@ -3,8 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.medianWithTable = void 0;
4
4
  const randint_1 = require("../../../../math/utils/random/randint");
5
5
  const shuffle_1 = require("../../../../utils/alea/shuffle");
6
+ const dollarize_1 = require("../../../../utils/latex/dollarize");
7
+ const mdTable_1 = require("../../../../utils/markdown/mdTable");
6
8
  const exercise_1 = require("../../../exercise");
7
9
  const getDistinctQuestions_1 = require("../../../utils/getDistinctQuestions");
10
+ const getInstruction = ({ randomValues, randomEffectives, }) => {
11
+ return `On considère le tableau d'effectifs suivant :
12
+
13
+ ${(0, mdTable_1.mdTable)([
14
+ ["Valeur", ...randomValues.map((e) => (0, dollarize_1.dollarize)(e))],
15
+ ["Effectif", ...randomEffectives.map((e) => (0, dollarize_1.dollarize)(e))],
16
+ ])}
17
+
18
+ Calculer la médiane de cette série de valeurs.`;
19
+ };
8
20
  const getMedianWithTable = () => {
9
21
  const getRandomUniqueValues = (count, min, max) => {
10
22
  const uniqueValues = new Set();
@@ -28,19 +40,14 @@ const getMedianWithTable = () => {
28
40
  else {
29
41
  median = sortedValues[middleIndex];
30
42
  }
43
+ const identifiers = { randomValues, randomEffectives };
31
44
  const answer = (median + "").replace(".", ",");
32
45
  const question = {
33
- instruction: `On considère le tableau d'effectifs suivant :
34
-
35
- |Valeur|${randomValues[0]}|${randomValues[1]}|${randomValues[2]}|${randomValues[3]}|${randomValues[4]}|
36
- |-|-|-|-|-|-|
37
- |Effectif|${randomEffectives[0]}|${randomEffectives[1]}|${randomEffectives[2]}|${randomEffectives[3]}|${randomEffectives[4]}|
38
-
39
- Calculer la médiane de cette série de valeurs.`,
46
+ instruction: getInstruction(identifiers),
40
47
  answer,
41
48
  keys: [],
42
49
  answerFormat: "tex",
43
- identifiers: { randomValues },
50
+ identifiers,
44
51
  style: { tableHasNoHeader: true },
45
52
  };
46
53
  return question;
@@ -69,4 +76,5 @@ exports.medianWithTable = {
69
76
  getPropositions,
70
77
  isAnswerValid,
71
78
  subject: "Mathématiques",
79
+ getInstruction,
72
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"quartiles.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/quartiles.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EAQT,MAAM,mBAAmB,CAAC;AAI3B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAiGF,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,WAAW,CAa3C,CAAC"}
1
+ {"version":3,"file":"quartiles.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/quartiles.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAI3B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAuFF,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,WAAW,CAc3C,CAAC"}
@@ -3,8 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.quartiles = void 0;
4
4
  const randint_1 = require("../../../../math/utils/random/randint");
5
5
  const shuffle_1 = require("../../../../utils/alea/shuffle");
6
+ const dollarize_1 = require("../../../../utils/latex/dollarize");
7
+ const mdTable_1 = require("../../../../utils/markdown/mdTable");
6
8
  const exercise_1 = require("../../../exercise");
7
9
  const getDistinctQuestions_1 = require("../../../utils/getDistinctQuestions");
10
+ const getInstruction = ({ randomEffectives, randomQuartile, randomValues, }) => {
11
+ return `On considère le tableau d'effectifs suivant :
12
+
13
+ ${(0, mdTable_1.mdTable)([
14
+ ["Valeur", ...randomValues.map((e) => (0, dollarize_1.dollarize)(e))],
15
+ ["Effectif", ...randomEffectives.map((e) => (0, dollarize_1.dollarize)(e))],
16
+ ])}
17
+
18
+ Calculer le ${randomQuartile === 0 ? "premier" : "troisième"} quartile de cette série de valeurs.`;
19
+ };
8
20
  const getQuartiles = () => {
9
21
  const getRandomUniqueValues = (count, min, max) => {
10
22
  const uniqueValues = new Set();
@@ -25,31 +37,10 @@ const getQuartiles = () => {
25
37
  const firstQuartile = sortedValues[firstQuartileIndex - 1];
26
38
  const thirdQuartile = sortedValues[thirdQuartileIndex - 1];
27
39
  const randomQuartile = (0, randint_1.randint)(0, 2);
28
- let quartileToString;
29
- let choosenQuartile;
30
- switch (randomQuartile) {
31
- case 0:
32
- quartileToString = "premier quartile";
33
- choosenQuartile = firstQuartile;
34
- break;
35
- case 1:
36
- quartileToString = "troisième quartile";
37
- choosenQuartile = thirdQuartile;
38
- break;
39
- default:
40
- quartileToString = "troisième quartile";
41
- choosenQuartile = thirdQuartile;
42
- break;
43
- }
44
- const answer = choosenQuartile + "";
40
+ const answer = (randomQuartile === 0 ? firstQuartile : thirdQuartile) + "";
41
+ const identifiers = { randomValues, randomEffectives, randomQuartile };
45
42
  const question = {
46
- instruction: `On considère le tableau d'effectifs suivant :
47
-
48
- |Valeur|${randomValues[0]}|${randomValues[1]}|${randomValues[2]}|${randomValues[3]}|${randomValues[4]}|
49
- |-|-|-|-|-|-|
50
- |Effectif|${randomEffectives[0]}|${randomEffectives[1]}|${randomEffectives[2]}|${randomEffectives[3]}|${randomEffectives[4]}|
51
-
52
- Calculer le ${quartileToString} de cette série de valeurs.`,
43
+ instruction: getInstruction(identifiers),
53
44
  answer,
54
45
  keys: [],
55
46
  answerFormat: "tex",
@@ -82,4 +73,5 @@ exports.quartiles = {
82
73
  getPropositions,
83
74
  isAnswerValid,
84
75
  subject: "Mathématiques",
76
+ getInstruction,
85
77
  };
@@ -1 +1 @@
1
- {"version":3,"file":"averagePoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats2var/averagePoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAclC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA+DF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}
1
+ {"version":3,"file":"averagePoint.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats2var/averagePoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAgBlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAqEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAc9C,CAAC"}
@@ -10,24 +10,31 @@ const randTupleInt_1 = require("../../../../math/utils/random/randTupleInt");
10
10
  const randint_1 = require("../../../../math/utils/random/randint");
11
11
  const pointNode_1 = require("../../../../tree/nodes/geometry/pointNode");
12
12
  const average_1 = require("../../../../utils/average");
13
- const getAveragePointQuestion = () => {
14
- const points = (0, randTupleInt_1.distinctRandTupleInt)(4, 2, { from: -9, to: 10 });
15
- const sortedPoints = points.sort((a, b) => a[0] - b[0]);
16
- const tab = `
17
- |x|${sortedPoints[0][0]}|${sortedPoints[1][0]}|${sortedPoints[2][0]}|${sortedPoints[3][0]}|
18
- |-|-|-|-|-|
19
- |y|${sortedPoints[0][1]}|${sortedPoints[1][1]}|${sortedPoints[2][1]}|${sortedPoints[3][1]}|
20
- `;
21
- const instruction = `On considère la liste de points suivante : ${tab}
13
+ const dollarize_1 = require("../../../../utils/latex/dollarize");
14
+ const mdTable_1 = require("../../../../utils/markdown/mdTable");
15
+ const getInstruction = ({ xValues, yValues }) => {
16
+ const tab = (0, mdTable_1.mdTable)([
17
+ ["$x$", ...xValues.map((el) => (0, dollarize_1.dollarize)(el))],
18
+ ["$y$", ...yValues.map((el) => (0, dollarize_1.dollarize)(el))],
19
+ ]);
20
+ return `On considère la liste de points suivante : ${tab}
22
21
 
23
22
  Déterminer les coordonnées du point moyen $G$.
24
23
  `;
24
+ };
25
+ const getAveragePointQuestion = () => {
26
+ const points = (0, randTupleInt_1.distinctRandTupleInt)(4, 2, { from: -9, to: 10 });
27
+ const sortedPoints = points.sort((a, b) => a[0] - b[0]);
25
28
  const xG = (0, frenchify_1.frenchify)((0, average_1.average)(sortedPoints.map((el) => el[0])) + "");
26
29
  const yG = (0, frenchify_1.frenchify)((0, average_1.average)(sortedPoints.map((el) => el[1])) + "");
27
30
  const answer = `\\left(${xG};${yG}\\right)`;
31
+ const identifiers = {
32
+ xValues: sortedPoints.map((el) => el[0]),
33
+ yValues: sortedPoints.map((el) => el[1]),
34
+ };
28
35
  const question = {
29
36
  answer,
30
- instruction,
37
+ instruction: getInstruction(identifiers),
31
38
  keys: ["semicolon"],
32
39
  answerFormat: "tex",
33
40
  identifiers: {
@@ -71,4 +78,5 @@ exports.averagePoint = {
71
78
  getPropositions,
72
79
  isAnswerValid,
73
80
  subject: "Mathématiques",
81
+ getInstruction,
74
82
  };
@@ -1 +1 @@
1
- {"version":3,"file":"spaceVectorNormCalculation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwEF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAc5D,CAAC"}
1
+ {"version":3,"file":"spaceVectorNormCalculation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2FF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAkB5D,CAAC"}