math-exercises 3.0.190 → 3.0.192

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 (125) hide show
  1. package/lib/exercises/math/dataRepresentations/barChart/barChartInterpreting.d.ts +53 -0
  2. package/lib/exercises/math/dataRepresentations/barChart/barChartInterpreting.d.ts.map +1 -0
  3. package/lib/exercises/math/dataRepresentations/barChart/barChartInterpreting.js +543 -0
  4. package/lib/exercises/math/dataRepresentations/barChart/barChartReading.d.ts +94 -0
  5. package/lib/exercises/math/dataRepresentations/barChart/barChartReading.d.ts.map +1 -0
  6. package/lib/exercises/math/dataRepresentations/barChart/barChartReading.js +280 -0
  7. package/lib/exercises/math/dataRepresentations/barChart/index.d.ts +3 -0
  8. package/lib/exercises/math/dataRepresentations/barChart/index.d.ts.map +1 -0
  9. package/lib/exercises/math/dataRepresentations/barChart/index.js +2 -0
  10. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotInterpreting.d.ts +7 -0
  11. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotInterpreting.d.ts.map +1 -0
  12. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotInterpreting.js +223 -0
  13. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReading.d.ts +9 -0
  14. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReading.d.ts.map +1 -0
  15. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReading.js +133 -0
  16. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReadingPercentages.d.ts +11 -0
  17. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReadingPercentages.d.ts.map +1 -0
  18. package/lib/exercises/math/dataRepresentations/boxPlot/boxPlotReadingPercentages.js +198 -0
  19. package/lib/exercises/math/dataRepresentations/boxPlot/compareBoxPlot.d.ts +13 -0
  20. package/lib/exercises/math/dataRepresentations/boxPlot/compareBoxPlot.d.ts.map +1 -0
  21. package/lib/exercises/math/dataRepresentations/boxPlot/compareBoxPlot.js +192 -0
  22. package/lib/exercises/math/dataRepresentations/boxPlot/index.d.ts +5 -0
  23. package/lib/exercises/math/dataRepresentations/boxPlot/index.d.ts.map +1 -0
  24. package/lib/exercises/math/dataRepresentations/boxPlot/index.js +4 -0
  25. package/lib/exercises/math/dataRepresentations/index.d.ts +4 -7
  26. package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
  27. package/lib/exercises/math/dataRepresentations/index.js +4 -11
  28. package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts +6 -0
  29. package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts.map +1 -0
  30. package/lib/exercises/math/dataRepresentations/scatterPlot/index.js +5 -0
  31. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.d.ts +12 -0
  32. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.d.ts.map +1 -0
  33. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotBuildScatterPlotFromDataTable.js +206 -0
  34. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.d.ts +9 -0
  35. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.d.ts.map +1 -0
  36. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotCommenting.js +210 -0
  37. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.d.ts +10 -0
  38. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.d.ts.map +1 -0
  39. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.js +252 -0
  40. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts +12 -0
  41. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts.map +1 -0
  42. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.js +352 -0
  43. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts +11 -0
  44. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts.map +1 -0
  45. package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.js +403 -0
  46. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.d.ts +7 -0
  47. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.d.ts.map +1 -0
  48. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.js +222 -0
  49. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.d.ts +7 -0
  50. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.d.ts.map +1 -0
  51. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.js +187 -0
  52. package/lib/exercises/math/dataRepresentations/tables/index.d.ts +4 -0
  53. package/lib/exercises/math/dataRepresentations/tables/index.d.ts.map +1 -0
  54. package/lib/exercises/math/dataRepresentations/tables/index.js +3 -0
  55. package/lib/exercises/math/dataRepresentations/tables/tableReading.d.ts +8 -0
  56. package/lib/exercises/math/dataRepresentations/tables/tableReading.d.ts.map +1 -0
  57. package/lib/exercises/math/dataRepresentations/tables/tableReading.js +109 -0
  58. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.d.ts +8 -0
  59. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.d.ts.map +1 -0
  60. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.js +145 -0
  61. package/lib/exercises/math/derivation/applications/index.d.ts +1 -0
  62. package/lib/exercises/math/derivation/applications/index.d.ts.map +1 -1
  63. package/lib/exercises/math/derivation/applications/index.js +1 -0
  64. package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +1 -1
  65. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -1
  66. package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +4 -1
  67. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.d.ts +13 -0
  68. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.d.ts.map +1 -0
  69. package/lib/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.js +205 -0
  70. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts +9 -0
  71. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts.map +1 -0
  72. package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.js +157 -0
  73. package/lib/exercises/math/functions/affines/affineVariations.d.ts +12 -0
  74. package/lib/exercises/math/functions/affines/affineVariations.d.ts.map +1 -0
  75. package/lib/exercises/math/functions/affines/affineVariations.js +176 -0
  76. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.d.ts +8 -0
  77. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.d.ts.map +1 -0
  78. package/lib/exercises/math/functions/affines/affineVariationsFromGraph.js +203 -0
  79. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.d.ts +12 -0
  80. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.d.ts.map +1 -0
  81. package/lib/exercises/math/functions/affines/affineVariationsFromTwoImages.js +259 -0
  82. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.d.ts +9 -0
  83. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.d.ts.map +1 -0
  84. package/lib/exercises/math/functions/exponentials/exponentialFunctionImage.js +99 -0
  85. package/lib/exercises/math/functions/exponentials/index.d.ts +5 -0
  86. package/lib/exercises/math/functions/exponentials/index.d.ts.map +1 -1
  87. package/lib/exercises/math/functions/exponentials/index.js +5 -0
  88. package/lib/exercises/math/functions/exponentials/realPowersFraction.d.ts +10 -0
  89. package/lib/exercises/math/functions/exponentials/realPowersFraction.d.ts.map +1 -0
  90. package/lib/exercises/math/functions/exponentials/realPowersFraction.js +125 -0
  91. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.d.ts +12 -0
  92. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.d.ts.map +1 -0
  93. package/lib/exercises/math/functions/exponentials/realPowersMixOperations.js +148 -0
  94. package/lib/exercises/math/functions/exponentials/realPowersPower.d.ts +10 -0
  95. package/lib/exercises/math/functions/exponentials/realPowersPower.d.ts.map +1 -0
  96. package/lib/exercises/math/functions/exponentials/realPowersPower.js +128 -0
  97. package/lib/exercises/math/functions/exponentials/realPowersProduct.d.ts +10 -0
  98. package/lib/exercises/math/functions/exponentials/realPowersProduct.d.ts.map +1 -0
  99. package/lib/exercises/math/functions/exponentials/realPowersProduct.js +128 -0
  100. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts.map +1 -1
  101. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.js +7 -2
  102. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.d.ts.map +1 -1
  103. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +131 -61
  104. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.d.ts +12 -0
  105. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.d.ts.map +1 -0
  106. package/lib/exercises/math/sequences/geometric/geometricFindNextTermFromTwoConsecutiveTerms.js +217 -0
  107. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.d.ts +10 -0
  108. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.d.ts.map +1 -0
  109. package/lib/exercises/math/sequences/geometric/geometricFindRecurrenceFormula.js +186 -0
  110. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.d.ts +14 -0
  111. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.d.ts.map +1 -0
  112. package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.js +189 -0
  113. package/lib/exercises/math/sequences/geometric/graph/index.d.ts +2 -0
  114. package/lib/exercises/math/sequences/geometric/graph/index.d.ts.map +1 -0
  115. package/lib/exercises/math/sequences/geometric/graph/index.js +1 -0
  116. package/lib/index.d.ts +53 -25
  117. package/lib/index.d.ts.map +1 -1
  118. package/lib/tree/nodes/algebraicNode.d.ts +3 -0
  119. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  120. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  121. package/lib/tree/nodes/operators/fractionNode.js +5 -3
  122. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  123. package/lib/tree/nodes/operators/multiplyNode.js +5 -3
  124. package/lib/tree/nodes/operators/powerNode.js +1 -1
  125. package/package.json +1 -1
@@ -0,0 +1,187 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { valueTableVEA } from "../../../../exercises/vea/valueTableVEA.js";
3
+ import { randTupleInt } from "../../../../math/utils/random/randTupleInt.js";
4
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
5
+ import { dollarize } from "../../../../utils/latex/dollarize.js";
6
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
7
+ const getAnswerTable = (identifiers) => {
8
+ const { coeffs } = identifiers;
9
+ let done = false;
10
+ let counter = 1;
11
+ const rightCoeffs = coeffs.map((e) => [...e]);
12
+ while (!done && counter < 1000) {
13
+ counter++;
14
+ if (counter > 1000)
15
+ throw new Error("Too many iterations in fillDoubleTable");
16
+ // console.log(rightCoeffs);
17
+ for (let i = 0; i < 9; i++) {
18
+ const cellLine = Math.floor(i / 3);
19
+ const cellColumn = i % 3;
20
+ const cell = rightCoeffs[cellLine][cellColumn];
21
+ if (cell)
22
+ continue;
23
+ const isLineCalculable = rightCoeffs[cellLine].filter((e) => !!e).length === 2;
24
+ if (isLineCalculable) {
25
+ //si total ligne
26
+ if ((cellColumn + 1) % 3 === 0)
27
+ rightCoeffs[cellLine][cellColumn] = rightCoeffs[cellLine]
28
+ .filter((e) => !!e)
29
+ .reduce((acc, e) => acc + e, 0);
30
+ else
31
+ rightCoeffs[cellLine][cellColumn] =
32
+ rightCoeffs[cellLine][2] -
33
+ (rightCoeffs[cellLine][0] ?? rightCoeffs[cellLine][1]);
34
+ }
35
+ const isColCalculable = rightCoeffs[(cellLine + 1) % 3][cellColumn] &&
36
+ rightCoeffs[(cellLine + 2) % 3][cellColumn];
37
+ if (isColCalculable) {
38
+ const prev = rightCoeffs[(cellLine + 1) % 3][cellColumn];
39
+ const next = rightCoeffs[(cellLine + 2) % 3][cellColumn];
40
+ //si total colomne
41
+ if (cellLine === 2)
42
+ rightCoeffs[cellLine][cellColumn] = prev + next;
43
+ else
44
+ rightCoeffs[cellLine][cellColumn] =
45
+ rightCoeffs[2][cellColumn] -
46
+ rightCoeffs[1 - cellLine][cellColumn];
47
+ }
48
+ }
49
+ done = rightCoeffs.every((line) => line.every((a) => a !== undefined));
50
+ }
51
+ return [
52
+ [" ", "A", "A'", "Total"],
53
+ ["B", ...rightCoeffs[0].map((e) => e.frenchify())],
54
+ ["B'", ...rightCoeffs[1].map((e) => e.frenchify())],
55
+ ["Total", ...rightCoeffs[2].map((e) => e.frenchify())],
56
+ ];
57
+ };
58
+ const getInstruction = (identifiers) => {
59
+ const { coeffs } = identifiers;
60
+ return `Compléter entièrement le tableau croisé d'effectifs suivant :
61
+
62
+ ${mdTable([
63
+ [" ", "$A$", "$A'$", "Total"],
64
+ ["$B$", ...coeffs[0].map((e) => (e ? dollarize(e.frenchify()) : ""))],
65
+ ["$B'$", ...coeffs[1].map((e) => (e ? dollarize(e.frenchify()) : ""))],
66
+ ["Total", ...coeffs[2].map((e) => (e ? dollarize(e.frenchify()) : ""))],
67
+ ])}`;
68
+ };
69
+ const getHint = () => {
70
+ return `Pour chaque ligne, le total doit être égal à la somme des deux cases précédentes.
71
+
72
+ De même, sur chaque colonne, le total doit être égal à la somme des deux cases précédentes.`;
73
+ };
74
+ const getCorrection = (identifiers) => {
75
+ const ansTable = getAnswerTable(identifiers);
76
+ const dollarized = ansTable.map((e, i) => i === 0 ? e : [e[0], ...e.slice(1).map((e) => dollarize(e))]);
77
+ return `On s'assure que sur chaque ligne, le total est bien égal à la somme des deux cases précédentes, et que sur chaque colonne, le total est bien égal à la somme des deux cases précédentes.
78
+
79
+ On obtient le tableau suivant :
80
+
81
+ ${mdTable(dollarized)}
82
+ `;
83
+ };
84
+ const getKeys = () => {
85
+ return [];
86
+ };
87
+ const isAnswerTableValid = (ans, { answerTable }) => {
88
+ try {
89
+ return valueTableVEA(ans, answerTable);
90
+ }
91
+ catch (err) {
92
+ return handleVEAError(err);
93
+ }
94
+ };
95
+ function rank(vectors) {
96
+ const basis = [];
97
+ for (let v of vectors) {
98
+ for (const b of basis) {
99
+ v = Math.min(v, v ^ b); // réduction
100
+ }
101
+ if (v !== 0)
102
+ basis.push(v);
103
+ }
104
+ return basis.length;
105
+ }
106
+ const getFillDoubleTableQuestion = () => {
107
+ const [a, b, c, d] = randTupleInt(4, {
108
+ from: 1,
109
+ to: 100,
110
+ });
111
+ //on calcule le rang de 4 vecteurs ci-dessous pris au hasard, si linéairement indépendants alors le tableau est remplissable
112
+ const vecs = [
113
+ [1, 0, 0, 0], //A1
114
+ [0, 1, 0, 0], //A2
115
+ [1, 1, 0, 0], //TA
116
+ [0, 0, 1, 0], //B1
117
+ [0, 0, 0, 1], //B2
118
+ [0, 0, 1, 1], //TB
119
+ [1, 0, 1, 0], //T1
120
+ [0, 1, 0, 1], //T2
121
+ [1, 1, 1, 1], //T
122
+ ];
123
+ const coeffs = [
124
+ [a, b, a + b],
125
+ [c, d, c + d],
126
+ [a + c, b + d, a + b + c + d],
127
+ ];
128
+ let choices = [];
129
+ do {
130
+ choices = randTupleInt(4, {
131
+ from: 0,
132
+ to: vecs.length,
133
+ allDifferent: true,
134
+ });
135
+ } while (rank(choices.map((i) => parseInt(vecs[i].join(""), 2))) !== 4);
136
+ for (let i = 0; i < 9; i++) {
137
+ if (choices.includes(i))
138
+ continue;
139
+ coeffs[Math.floor(i / 3)][i % 3] = undefined;
140
+ }
141
+ const identifiers = {
142
+ coeffs,
143
+ };
144
+ return getQuestionFromIdentifiers(identifiers);
145
+ };
146
+ const getQuestionFromIdentifiers = (identifiers) => {
147
+ const { coeffs } = identifiers;
148
+ return {
149
+ answerTable: getAnswerTable(identifiers),
150
+ instruction: getInstruction(identifiers),
151
+ keys: getKeys(identifiers),
152
+ answerFormat: "tex",
153
+ identifiers,
154
+ hint: getHint(identifiers),
155
+ correction: getCorrection(identifiers),
156
+ initTable: [
157
+ [" ", "A", "A'", "Total"],
158
+ ["B", ...coeffs[0].map((e) => (e ? e.frenchify() : ""))],
159
+ ["B'", ...coeffs[1].map((e) => (e ? e.frenchify() : ""))],
160
+ ["Total", ...coeffs[2].map((e) => (e ? e.frenchify() : ""))],
161
+ ],
162
+ style: {
163
+ tableOptions: {
164
+ firstColumnIsHeader: true,
165
+ firstCellIsDivided: false,
166
+ firstRowIsHeader: true,
167
+ },
168
+ },
169
+ };
170
+ };
171
+ export const fillDoubleTable = {
172
+ id: "fillDoubleTable",
173
+ label: "Compléter un tableau croisé d'effectifs",
174
+ isSingleStep: true,
175
+ generator: (nb, opts) => getDistinctQuestions(() => getFillDoubleTableQuestion(opts), nb),
176
+ qcmTimer: 60,
177
+ freeTimer: 60,
178
+ isAnswerTableValid,
179
+ subject: "Mathématiques",
180
+ getInstruction,
181
+ getHint,
182
+ getCorrection,
183
+ getAnswerTable,
184
+ getQuestionFromIdentifiers,
185
+ hasHintAndCorrection: true,
186
+ answerType: "valueTable",
187
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./tableReading.js";
2
+ export * from "./fillDoubleTable.js";
3
+ export * from "./buildDoubleTableFromContext.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/tables/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./tableReading.js";
2
+ export * from "./fillDoubleTable.js";
3
+ export * from "./buildDoubleTableFromContext.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ values: number[][];
4
+ caseAsked: number;
5
+ };
6
+ export declare const tableReading: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=tableReading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/tables/tableReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IAIjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAsGF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}
@@ -0,0 +1,109 @@
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 { random } from "../../../../utils/alea/random.js";
6
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
7
+ import { dollarize } from "../../../../utils/latex/dollarize.js";
8
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
9
+ const getPropositions = (n, { answer, values }) => {
10
+ const propositions = [];
11
+ addValidProp(propositions, answer);
12
+ propWhile(propositions, n, () => {
13
+ tryToAddWrongProp(propositions, random(values.flat()).frenchify());
14
+ });
15
+ return shuffleProps(propositions, n);
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { values, caseAsked } = identifiers;
19
+ const flatValues = values.flat();
20
+ return flatValues[caseAsked].frenchify();
21
+ };
22
+ const getInstruction = (identifiers) => {
23
+ const { values, caseAsked } = identifiers;
24
+ const population = caseAsked % 3 === 0
25
+ ? "de la $6^e$ A"
26
+ : caseAsked % 3 === 1
27
+ ? "de la $6^e$ B"
28
+ : "";
29
+ const caractere = caseAsked < 3
30
+ ? "préfèrent le jeu Minecraft"
31
+ : caseAsked < 6
32
+ ? "préfèrent le jeu The Legend of Zelda"
33
+ : "ont répondu au sondage";
34
+ return `Un sondage a été réalisé auprès des élèves de deux classes de $6^e$ pour connaître leur jeu vidéo préféré. Voici leurs réponses :
35
+
36
+ ${mdTable([
37
+ ["", "$6^e$ A", "$6^e$ B", "Total"],
38
+ ["Minecraft", ...values[0].map(dollarize)],
39
+ ["The Legend of Zelda", ...values[1].map(dollarize)],
40
+ ["Total", ...values[2].map(dollarize)],
41
+ ])}
42
+
43
+ Combien d'élèves ${population} ${caractere} ?
44
+ `;
45
+ };
46
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
47
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
48
+ const getKeys = () => {
49
+ return [];
50
+ };
51
+ const isAnswerValid = (ans, { answer }) => {
52
+ try {
53
+ return numberVEA(ans, answer);
54
+ }
55
+ catch (err) {
56
+ return handleVEAError(err);
57
+ }
58
+ };
59
+ const getTableReadingQuestion = () => {
60
+ const caseAsked = randint(0, 9);
61
+ const totalA = randint(20, 30);
62
+ const totalB = randint(20, 30, [totalA]);
63
+ const case0 = randint(3, totalA - 5);
64
+ const case1 = randint(3, totalB - 5, [case0]);
65
+ const case3 = totalA - case0;
66
+ const case4 = totalB - case1;
67
+ const values = [
68
+ [case0, case1, case0 + case1],
69
+ [case3, case4, case3 + case4],
70
+ [totalA, totalB, totalA + totalB],
71
+ ];
72
+ const identifiers = {
73
+ caseAsked,
74
+ values,
75
+ };
76
+ return getQuestionFromIdentifiers(identifiers);
77
+ };
78
+ const getQuestionFromIdentifiers = (identifiers) => {
79
+ const question = {
80
+ answer: getAnswer(identifiers),
81
+ instruction: getInstruction(identifiers),
82
+ keys: getKeys(identifiers),
83
+ answerFormat: "tex",
84
+ identifiers,
85
+ // hint: getHint(identifiers),
86
+ // correction: getCorrection(identifiers),
87
+ style: {
88
+ tableOptions: {
89
+ firstColumnIsHeader: true,
90
+ firstCellIsDivided: false,
91
+ firstRowIsHeader: true,
92
+ },
93
+ },
94
+ };
95
+ return question;
96
+ };
97
+ export const tableReading = {
98
+ id: "tableReading",
99
+ connector: "=",
100
+ label: "Lire un tableau à double entrée",
101
+ isSingleStep: true,
102
+ generator: (nb, opts) => getDistinctQuestions(() => getTableReadingQuestion(opts), nb),
103
+ qcmTimer: 60,
104
+ freeTimer: 60,
105
+ getPropositions,
106
+ isAnswerValid,
107
+ subject: "Mathématiques",
108
+ getQuestionFromIdentifiers,
109
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ coeffs: number[];
4
+ isAskingX: boolean;
5
+ };
6
+ export declare const findYearForDecreasingPopulation: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=findYearForDecreasingPopulation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findYearForDecreasingPopulation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/applications/findYearForDecreasingPopulation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AA4IF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAqBjE,CAAC"}
@@ -0,0 +1,145 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { Affine } from "../../../../math/polynomials/affine.js";
5
+ import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
6
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
7
+ import { randint } from "../../../../math/utils/random/randint.js";
8
+ import { round } from "../../../../math/utils/round.js";
9
+ import { firstDegreeInequationResolutionTex } from "../../../../tree/nodes/inequations/inequationNode.js";
10
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
11
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
+ const getPropositions = (n, { answer, coeffs, isAskingX }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ const trinom = TrinomConstructor.fromCoeffs(coeffs);
17
+ propWhile(propositions, n, () => {
18
+ if (isAskingX)
19
+ tryToAddWrongProp(propositions, (2013 + randint(1, 20)).frenchify());
20
+ else
21
+ tryToAddWrongProp(propositions, trinom
22
+ .toTree()
23
+ .toDetailedEvaluation({
24
+ x: randint(1, 20).toTree(),
25
+ })
26
+ .simplify()
27
+ .toTex());
28
+ });
29
+ return shuffleProps(propositions, n);
30
+ };
31
+ const getAnswer = (identifiers) => {
32
+ const { coeffs, isAskingX } = identifiers;
33
+ const trinom = TrinomConstructor.fromCoeffs(coeffs);
34
+ const a = round(2 * coeffs[2], 4);
35
+ const b = coeffs[1];
36
+ const root = frac(-b, a).simplify();
37
+ if (isAskingX) {
38
+ return round(2013 + root.evaluate(), 4).frenchify();
39
+ }
40
+ return trinom
41
+ .toTree()
42
+ .toDetailedEvaluation({
43
+ x: root,
44
+ })
45
+ .simplify()
46
+ .toTex();
47
+ };
48
+ const getInstruction = (identifiers) => {
49
+ const { coeffs, isAskingX } = identifiers;
50
+ const trinom = TrinomConstructor.fromCoeffs(coeffs);
51
+ return `On estime que la population d'une ville, exprimée en milliers d'habitants, peut être modélisée par la fonction $f$ définie sur $[0; +\\infty[$ par :
52
+
53
+ $$
54
+ f(x) = ${trinom.toTree().toTex()}
55
+ $$
56
+
57
+ où $x$ est la durée, en année, écoulée depuis $2013$.
58
+
59
+ ${isAskingX
60
+ ? `En quelle année la population de la ville est-elle maximale ?`
61
+ : `Quelle est la population maximale de la ville ?`}`;
62
+ };
63
+ const getHint = () => {
64
+ return `Calcule la dérivée $f'$ de $f$, puis étudie son signe. Le maximum de $f$ est atteint pour la valeur de $x$ telle que $f'(x) = 0$ et telle que $f'$ change de signe en $x$.`;
65
+ };
66
+ const getCorrection = (identifiers) => {
67
+ const { coeffs } = identifiers;
68
+ const trinom = TrinomConstructor.fromCoeffs(coeffs);
69
+ const a = round(2 * coeffs[2], 4);
70
+ const b = coeffs[1];
71
+ const affine = new Affine(a, b);
72
+ const root = frac(-b, a).simplify();
73
+ const froot = trinom.toTree().toDetailedEvaluation({ x: root }).simplify();
74
+ return `On calcule $f'(x)$ :
75
+
76
+ $$
77
+ f'(x) = ${trinom.derivate().toTree().toTex()}
78
+ $$
79
+
80
+ On étudie ensuite le signe de $f'(x)$ :
81
+
82
+ $$
83
+ ${firstDegreeInequationResolutionTex(affine, "\\ge", (0).toTree())}
84
+ $$
85
+
86
+ On en déduit donc que $f$ atteint son maximum pour $x = ${root.toTex()}$, et on a alors :
87
+
88
+ $$
89
+ f(${root.toTex()}) = ${froot.toTex()}
90
+ $$
91
+
92
+ La population de la ville est donc maximale à l'année $${round(2013 + root.evaluate(), 4)}$, et elle est alors de $${froot.toTex()}$ milliers d'habitants.`;
93
+ };
94
+ const getKeys = () => {
95
+ return [];
96
+ };
97
+ const isAnswerValid = (ans, { answer }) => {
98
+ try {
99
+ return numberVEA(ans, answer);
100
+ }
101
+ catch (err) {
102
+ return handleVEAError(err);
103
+ }
104
+ };
105
+ const getFindYearForDecreasingPopulationQuestion = () => {
106
+ const alpha = randint(1, 20);
107
+ const beta = randfloat(10, 100, 2);
108
+ const a = randfloat(-0.9, -0.1, 2);
109
+ const b = round(-2 * a * alpha, 4);
110
+ const c = round((beta + a * alpha) ^ 2, 4);
111
+ const identifiers = {
112
+ isAskingX: coinFlip(),
113
+ coeffs: [c, b, a],
114
+ };
115
+ return getQuestionFromIdentifiers(identifiers);
116
+ };
117
+ const getQuestionFromIdentifiers = (identifiers) => {
118
+ return {
119
+ answer: getAnswer(identifiers),
120
+ instruction: getInstruction(identifiers),
121
+ keys: getKeys(identifiers),
122
+ answerFormat: "tex",
123
+ identifiers,
124
+ hint: getHint(identifiers),
125
+ correction: getCorrection(identifiers),
126
+ };
127
+ };
128
+ export const findYearForDecreasingPopulation = {
129
+ id: "findYearForDecreasingPopulation",
130
+ connector: "=",
131
+ label: "Déterminer le maximum d'une population (dérivation)",
132
+ isSingleStep: true,
133
+ generator: (nb, opts) => getDistinctQuestions(() => getFindYearForDecreasingPopulationQuestion(opts), nb),
134
+ qcmTimer: 60,
135
+ freeTimer: 60,
136
+ getPropositions,
137
+ isAnswerValid,
138
+ subject: "Mathématiques",
139
+ getInstruction,
140
+ getHint,
141
+ getCorrection,
142
+ getAnswer,
143
+ getQuestionFromIdentifiers,
144
+ hasHintAndCorrection: true,
145
+ };
@@ -1,3 +1,4 @@
1
1
  export * from "./maxBenefice.js";
2
2
  export * from "./minimalCost.js";
3
+ export * from "./findYearForDecreasingPopulation.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/applications/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/applications/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sCAAsC,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from "./maxBenefice.js";
2
2
  export * from "./minimalCost.js";
3
+ export * from "./findYearForDecreasingPopulation.js";
@@ -254,7 +254,7 @@ const getPropositions = (n, { answer, ...identifiers }) => {
254
254
  ]);
255
255
  };
256
256
  const getKeys = () => {
257
- return [];
257
+ return ["x", "y", "equal"];
258
258
  };
259
259
  const isAnswerValid = (ans, { answer }) => {
260
260
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"signVarTableFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgM7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAkXF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAyCF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CACvD,WAAW,EACX,OAAO,CAuBR,CAAC"}
1
+ {"version":3,"file":"signVarTableFromFunctionExpression.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/variations/signVarTableFromFunctionExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAarC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAgM7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAqXF,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAyCF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CACvD,WAAW,EACX,OAAO,CAuBR,CAAC"}
@@ -266,7 +266,10 @@ const getAnswerTable = (identifiers) => {
266
266
  [
267
267
  "$f'(x)$",
268
268
  "\\ ",
269
- ...arrSignOutsideRoots.flatMap((sign) => [sign > 0 ? "+" : "-", "\\ "]),
269
+ ...arrSignOutsideRoots.flatMap((sign, i, arr) => [
270
+ sign > 0 ? "+" : "-",
271
+ i === arr.length - 1 ? "\\ " : "0",
272
+ ]),
270
273
  ],
271
274
  [
272
275
  "$\\ $",
@@ -0,0 +1,13 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ nodeIdsAbscissa: NodeIdentifiers[];
5
+ nodeIdsSlope: NodeIdentifiers;
6
+ typeAbscissa: string;
7
+ };
8
+ type Options = {
9
+ typeAbscissa: string;
10
+ };
11
+ export declare const affineCompareTwoImagesFromVariations: Exercise<Identifiers, Options>;
12
+ export {};
13
+ //# sourceMappingURL=affineCompareTwoImagesFromVariations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affineCompareTwoImagesFromVariations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineCompareTwoImagesFromVariations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAiB7C,KAAK,WAAW,GAAG;IACjB,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,YAAY,EAAE,eAAe,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAwNF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAiBF,eAAO,MAAM,oCAAoC,EAAE,QAAQ,CACzD,WAAW,EACX,OAAO,CAoBR,CAAC"}