math-exercises 3.0.191 → 3.0.193

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 (94) 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/dataToGraphGraphToData.d.ts.map +1 -1
  26. package/lib/exercises/math/dataRepresentations/dataToGraphGraphToData.js +1 -1
  27. package/lib/exercises/math/dataRepresentations/index.d.ts +4 -7
  28. package/lib/exercises/math/dataRepresentations/index.d.ts.map +1 -1
  29. package/lib/exercises/math/dataRepresentations/index.js +4 -11
  30. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.d.ts +7 -0
  31. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.d.ts.map +1 -0
  32. package/lib/exercises/math/dataRepresentations/tables/buildDoubleTableFromContext.js +222 -0
  33. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.d.ts +7 -0
  34. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.d.ts.map +1 -0
  35. package/lib/exercises/math/dataRepresentations/tables/fillDoubleTable.js +187 -0
  36. package/lib/exercises/math/dataRepresentations/tables/index.d.ts +4 -0
  37. package/lib/exercises/math/dataRepresentations/tables/index.d.ts.map +1 -0
  38. package/lib/exercises/math/dataRepresentations/tables/index.js +3 -0
  39. package/lib/exercises/math/dataRepresentations/tables/tableReading.d.ts +8 -0
  40. package/lib/exercises/math/dataRepresentations/tables/tableReading.d.ts.map +1 -0
  41. package/lib/exercises/math/dataRepresentations/tables/tableReading.js +109 -0
  42. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.d.ts +8 -0
  43. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.d.ts.map +1 -0
  44. package/lib/exercises/math/derivation/applications/findYearForDecreasingPopulation.js +145 -0
  45. package/lib/exercises/math/derivation/applications/index.d.ts +1 -0
  46. package/lib/exercises/math/derivation/applications/index.d.ts.map +1 -1
  47. package/lib/exercises/math/derivation/applications/index.js +1 -0
  48. package/lib/exercises/math/functions/exponentials/computeImageByExponentialFunctionInSituation.d.ts +10 -0
  49. package/lib/exercises/math/functions/exponentials/computeImageByExponentialFunctionInSituation.d.ts.map +1 -0
  50. package/lib/exercises/math/functions/exponentials/computeImageByExponentialFunctionInSituation.js +96 -0
  51. package/lib/exercises/math/functions/exponentials/computeImageByExponentialFunctionWithUnitChange.d.ts +11 -0
  52. package/lib/exercises/math/functions/exponentials/computeImageByExponentialFunctionWithUnitChange.d.ts.map +1 -0
  53. package/lib/exercises/math/functions/exponentials/computeImageByExponentialFunctionWithUnitChange.js +116 -0
  54. package/lib/exercises/math/functions/exponentials/index.d.ts +3 -0
  55. package/lib/exercises/math/functions/exponentials/index.d.ts.map +1 -1
  56. package/lib/exercises/math/functions/exponentials/index.js +3 -0
  57. package/lib/exercises/math/functions/exponentials/modelizeSituationByExponentialFunction.d.ts +9 -0
  58. package/lib/exercises/math/functions/exponentials/modelizeSituationByExponentialFunction.d.ts.map +1 -0
  59. package/lib/exercises/math/functions/exponentials/modelizeSituationByExponentialFunction.js +105 -0
  60. package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.js +2 -2
  61. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.d.ts.map +1 -1
  62. package/lib/exercises/math/probaStat/conditional/fillTableConditionalProbabilitySituation.js +7 -2
  63. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.d.ts.map +1 -1
  64. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +131 -61
  65. package/lib/exercises/math/probaStat/stats2var/buildDataTableFromScatterplot.d.ts +8 -0
  66. package/lib/exercises/math/probaStat/stats2var/buildDataTableFromScatterplot.d.ts.map +1 -0
  67. package/lib/exercises/math/probaStat/stats2var/buildDataTableFromScatterplot.js +114 -0
  68. package/lib/exercises/math/probaStat/stats2var/buildScatterPlotFromDataTable.d.ts +8 -0
  69. package/lib/exercises/math/probaStat/stats2var/buildScatterPlotFromDataTable.d.ts.map +1 -0
  70. package/lib/exercises/math/probaStat/stats2var/buildScatterPlotFromDataTable.js +110 -0
  71. package/lib/exercises/math/probaStat/stats2var/index.d.ts +2 -0
  72. package/lib/exercises/math/probaStat/stats2var/index.d.ts.map +1 -1
  73. package/lib/exercises/math/probaStat/stats2var/index.js +2 -0
  74. package/lib/exercises/math/sequences/geometric/graph/compareGeometricReasonWithOneFromGraph.d.ts +8 -0
  75. package/lib/exercises/math/sequences/geometric/graph/compareGeometricReasonWithOneFromGraph.d.ts.map +1 -0
  76. package/lib/exercises/math/sequences/geometric/graph/compareGeometricReasonWithOneFromGraph.js +87 -0
  77. package/lib/exercises/math/sequences/geometric/graph/index.d.ts +4 -1
  78. package/lib/exercises/math/sequences/geometric/graph/index.d.ts.map +1 -1
  79. package/lib/exercises/math/sequences/geometric/graph/index.js +4 -1
  80. package/lib/exercises/math/sequences/geometric/graph/plausibleGeometricSequenceExpressionFromGraph.d.ts +12 -0
  81. package/lib/exercises/math/sequences/geometric/graph/plausibleGeometricSequenceExpressionFromGraph.d.ts.map +1 -0
  82. package/lib/exercises/math/sequences/geometric/graph/plausibleGeometricSequenceExpressionFromGraph.js +133 -0
  83. package/lib/exercises/math/sequences/geometric/graph/readGeometricExpressionFromGraph.d.ts +8 -0
  84. package/lib/exercises/math/sequences/geometric/graph/readGeometricExpressionFromGraph.d.ts.map +1 -0
  85. package/lib/exercises/math/sequences/geometric/graph/readGeometricExpressionFromGraph.js +132 -0
  86. package/lib/exercises/math/sequences/geometric/graph/recognizeGeometricFromGraph.d.ts +11 -0
  87. package/lib/exercises/math/sequences/geometric/graph/recognizeGeometricFromGraph.d.ts.map +1 -0
  88. package/lib/exercises/math/sequences/geometric/graph/recognizeGeometricFromGraph.js +137 -0
  89. package/lib/exercises/math/sequences/geometric/index.d.ts +1 -0
  90. package/lib/exercises/math/sequences/geometric/index.d.ts.map +1 -1
  91. package/lib/exercises/math/sequences/geometric/index.js +1 -0
  92. package/lib/index.d.ts +71 -25
  93. package/lib/index.d.ts.map +1 -1
  94. package/package.json +1 -1
@@ -0,0 +1,222 @@
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
+ [" ", "Hommes", "Femmes", "Total"],
53
+ ["Plus de $40$ ans", ...rightCoeffs[0].map((e) => e.frenchify())],
54
+ ["Moins de $40$ ans", ...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
+ const strings = [
61
+ [
62
+ "hommes de plus de $40$ ans",
63
+ "femmes de plus de $40$ ans",
64
+ "employés de plus de $40$ ans",
65
+ ],
66
+ [
67
+ "hommes de moins de $40$ ans",
68
+ "femmes de moins de $40$ ans",
69
+ "employés de moins de $40$ ans",
70
+ ],
71
+ ["hommes", "femmes", "employés"],
72
+ ];
73
+ const givenStrings = [];
74
+ for (let i = 0; i < coeffs.length; i++) {
75
+ for (let j = 0; j < coeffs[i].length; j++) {
76
+ if (coeffs[i][j] !== undefined)
77
+ givenStrings.push(`$${coeffs[i][j]}$ ${strings[i][j]}`);
78
+ }
79
+ }
80
+ return `Dans une entreprise, il y a :
81
+
82
+ - ${givenStrings[0]};
83
+
84
+ - ${givenStrings[1]};
85
+
86
+ - ${givenStrings[2]};
87
+
88
+ - ${givenStrings[3]}.
89
+
90
+ Compléter le tableau croisé d'effectifs ci-dessous pour décrire la répartition des employés de l'entreprise.`;
91
+ };
92
+ const getHint = () => {
93
+ return `Commence par remplir les cases que l'on peut déterminer grâce aux données de l'énoncé.
94
+
95
+ Puis, détermine les cases manquantes en faisant des additions ou des soustractions.`;
96
+ };
97
+ const getCorrection = (identifiers) => {
98
+ const { coeffs } = identifiers;
99
+ const ansTable = getAnswerTable(identifiers);
100
+ const dollarized = ansTable.map((e, i) => i === 0 ? e : [e[0], ...e.slice(1).map((e) => dollarize(e))]);
101
+ return `On commence par remplir les cases que l'on peut déterminer grâce aux données de l'énoncé :
102
+
103
+ ${mdTable([
104
+ [" ", "Hommes", "Femmes", "Total"],
105
+ [
106
+ "Plus de $40$ ans",
107
+ ...coeffs[0].map((e) => (e ? dollarize(e.frenchify()) : "")),
108
+ ],
109
+ [
110
+ "Moins de $40$ ans",
111
+ ...coeffs[1].map((e) => (e ? dollarize(e.frenchify()) : "")),
112
+ ],
113
+ ["Total", ...coeffs[2].map((e) => (e ? dollarize(e.frenchify()) : ""))],
114
+ ])}
115
+
116
+ Puis, on complète les cases manquantes :
117
+
118
+ ${mdTable(dollarized)}`;
119
+ };
120
+ const getKeys = () => {
121
+ return [];
122
+ };
123
+ const isAnswerTableValid = (ans, { answerTable }) => {
124
+ try {
125
+ return valueTableVEA(ans, answerTable);
126
+ }
127
+ catch (err) {
128
+ return handleVEAError(err);
129
+ }
130
+ };
131
+ function rank(vectors) {
132
+ const basis = [];
133
+ for (let v of vectors) {
134
+ for (const b of basis) {
135
+ v = Math.min(v, v ^ b); // réduction
136
+ }
137
+ if (v !== 0)
138
+ basis.push(v);
139
+ }
140
+ return basis.length;
141
+ }
142
+ const getBuildDoubleTableFromContextQuestion = () => {
143
+ const [a, b, c, d] = randTupleInt(4, {
144
+ from: 1,
145
+ to: 100,
146
+ });
147
+ //on calcule le rang de 4 vecteurs ci-dessous pris au hasard, si linéairement indépendants alors le tableau est remplissable
148
+ const vecs = [
149
+ [1, 0, 0, 0], //A1
150
+ [0, 1, 0, 0], //A2
151
+ [1, 1, 0, 0], //TA
152
+ [0, 0, 1, 0], //B1
153
+ [0, 0, 0, 1], //B2
154
+ [0, 0, 1, 1], //TB
155
+ [1, 0, 1, 0], //T1
156
+ [0, 1, 0, 1], //T2
157
+ [1, 1, 1, 1], //T
158
+ ];
159
+ const coeffs = [
160
+ [a, b, a + b],
161
+ [c, d, c + d],
162
+ [a + c, b + d, a + b + c + d],
163
+ ];
164
+ let choices = [];
165
+ do {
166
+ choices = randTupleInt(4, {
167
+ from: 0,
168
+ to: vecs.length,
169
+ allDifferent: true,
170
+ });
171
+ } while (rank(choices.map((i) => parseInt(vecs[i].join(""), 2))) !== 4);
172
+ for (let i = 0; i < 9; i++) {
173
+ if (choices.includes(i))
174
+ continue;
175
+ coeffs[Math.floor(i / 3)][i % 3] = undefined;
176
+ }
177
+ const identifiers = {
178
+ coeffs,
179
+ };
180
+ return getQuestionFromIdentifiers(identifiers);
181
+ };
182
+ const getQuestionFromIdentifiers = (identifiers) => {
183
+ return {
184
+ answerTable: getAnswerTable(identifiers),
185
+ instruction: getInstruction(identifiers),
186
+ keys: getKeys(identifiers),
187
+ answerFormat: "tex",
188
+ identifiers,
189
+ hint: getHint(identifiers),
190
+ correction: getCorrection(identifiers),
191
+ initTable: [
192
+ [" ", "Hommes", "Femmes", "Total"],
193
+ ["Plus de $40$ ans", "", "", ""],
194
+ ["Moins de $40$ ans", "", "", ""],
195
+ ["Total", "", "", ""],
196
+ ],
197
+ style: {
198
+ tableOptions: {
199
+ firstColumnIsHeader: true,
200
+ firstCellIsDivided: false,
201
+ firstRowIsHeader: true,
202
+ },
203
+ },
204
+ };
205
+ };
206
+ export const buildDoubleTableFromContext = {
207
+ id: "buildDoubleTableFromContext",
208
+ label: "Construire un tableau croisé d'effectifs à partir d'un contexte",
209
+ isSingleStep: true,
210
+ generator: (nb, opts) => getDistinctQuestions(() => getBuildDoubleTableFromContextQuestion(opts), nb),
211
+ qcmTimer: 60,
212
+ freeTimer: 60,
213
+ isAnswerTableValid,
214
+ subject: "Mathématiques",
215
+ getInstruction,
216
+ getHint,
217
+ getCorrection,
218
+ getAnswerTable,
219
+ getQuestionFromIdentifiers,
220
+ hasHintAndCorrection: true,
221
+ answerType: "valueTable",
222
+ };
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ coeffs: (number | undefined)[][];
4
+ };
5
+ export declare const fillDoubleTable: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=fillDoubleTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fillDoubleTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/dataRepresentations/tables/fillDoubleTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAAE,CAAC;CAClC,CAAC;AAqLF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAiBjD,CAAC"}
@@ -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"}