math-exercises 3.0.170 → 3.0.171

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 (21) hide show
  1. package/lib/exercises/math/functions/trinoms/problems/index.d.ts +1 -0
  2. package/lib/exercises/math/functions/trinoms/problems/index.d.ts.map +1 -1
  3. package/lib/exercises/math/functions/trinoms/problems/index.js +1 -0
  4. package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.d.ts +9 -0
  5. package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.d.ts.map +1 -0
  6. package/lib/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.js +202 -0
  7. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductIdentities.js +1 -1
  8. package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.d.ts +11 -0
  9. package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.d.ts.map +1 -0
  10. package/lib/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.js +232 -0
  11. package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -0
  12. package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
  13. package/lib/exercises/math/probaStat/randomVariable/index.js +1 -0
  14. package/lib/exercises/math/sequences/arithmetic/arithmeticVariations.js +1 -1
  15. package/lib/index.d.ts +7 -0
  16. package/lib/index.d.ts.map +1 -1
  17. package/lib/math/geometry/point.js +2 -2
  18. package/lib/math/utils/random/randTupleInt.d.ts +1 -0
  19. package/lib/math/utils/random/randTupleInt.d.ts.map +1 -1
  20. package/lib/math/utils/random/randTupleInt.js +3 -0
  21. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
1
  export * from "./swedishFlag.js";
2
2
  export * from "./maxSurfaceForGivenClosure.js";
3
+ export * from "./rectangleSizesFromPerimeterAndArea.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/problems/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/problems/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yCAAyC,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from "./swedishFlag.js";
2
2
  export * from "./maxSurfaceForGivenClosure.js";
3
+ export * from "./rectangleSizesFromPerimeterAndArea.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ perimeterIds: NodeIdentifiers;
5
+ areaIds: NodeIdentifiers;
6
+ };
7
+ export declare const rectangleSizesFromPerimeterAndArea: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=rectangleSizesFromPerimeterAndArea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rectangleSizesFromPerimeterAndArea.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/problems/rectangleSizesFromPerimeterAndArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAS7C,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC;AAqMF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAqBpE,CAAC"}
@@ -0,0 +1,202 @@
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 { randint } from "../../../../../math/utils/random/randint.js";
5
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
6
+ import { sqrt } from "../../../../../tree/nodes/functions/sqrtNode.js";
7
+ import { reifyAlgebraic, } from "../../../../../tree/nodes/nodeConstructor.js";
8
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
9
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
10
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
11
+ import { square } from "../../../../../tree/nodes/operators/powerNode.js";
12
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
13
+ import { valueParser } from "../../../../../tree/parsers/valueParser.js";
14
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
15
+ const getPropositions = (n, { answer }) => {
16
+ const propositions = [];
17
+ addValidProp(propositions, answer);
18
+ propWhile(propositions, n, () => {
19
+ const a = randint(1, 10);
20
+ const b = randint(a + 1, a + 10);
21
+ tryToAddWrongProp(propositions, `${a}\\text{ et }${b}`);
22
+ });
23
+ return shuffleProps(propositions, n);
24
+ };
25
+ const getAnswer = (identifiers) => {
26
+ const { areaIds, perimeterIds } = identifiers;
27
+ const area = reifyAlgebraic(areaIds);
28
+ const perimeter = reifyAlgebraic(perimeterIds);
29
+ const halfPerimeter = frac(perimeter, 2);
30
+ const yByX = substract(halfPerimeter, "x");
31
+ const a = (-1).toTree();
32
+ const b = halfPerimeter;
33
+ const c = opposite(area);
34
+ const delta = substract(square(b), multiply(4, multiply(a, c))).simplify();
35
+ const x1 = frac(substract(opposite(b), sqrt(delta)), multiply(2, a)).simplify();
36
+ const x = x1;
37
+ const y = yByX.toDetailedEvaluation({ x: x }).simplify();
38
+ const ordered = x.evaluate() < y.evaluate() ? [x, y] : [y, x];
39
+ return `${ordered[0].toTex()}\\text{ et }${ordered[1].toTex()}`;
40
+ };
41
+ const getInstruction = (identifiers) => {
42
+ const { areaIds, perimeterIds } = identifiers;
43
+ const area = reifyAlgebraic(areaIds);
44
+ const perimeter = reifyAlgebraic(perimeterIds);
45
+ return `On considère un rectangle de périmètre $${perimeter.toTex()}$ et d'aire $${area.toTex()}$.
46
+
47
+ Déterminer la longueur et la largeur de ce rectangle.`;
48
+ };
49
+ const getHint = () => {
50
+ return `Nomme $x$ et $y$ la longueur et la largeur du rectangle.
51
+
52
+ À l'aide du périmètre et de l'aire du rectangle, cela te donnera deux équations d'inconnues $x$ et $y$.
53
+
54
+ Utilise l'une des équations pour écrire $y$ en fonction de $x$.
55
+
56
+ Puis, réécris l'autre équation en utilisant ce résultat.
57
+
58
+ Tu obtiendras alors une équation du second degré, que tu peux résoudre en utilisant le discriminant.`;
59
+ };
60
+ const getCorrection = (identifiers) => {
61
+ const { areaIds, perimeterIds } = identifiers;
62
+ const perimeter = reifyAlgebraic(perimeterIds);
63
+ const halfPerimeter = frac(perimeter, 2).simplify();
64
+ const area = reifyAlgebraic(areaIds);
65
+ const yByX = substract(halfPerimeter, "x");
66
+ const a = (-1).toTree();
67
+ const b = halfPerimeter;
68
+ const c = opposite(area);
69
+ const delta = substract(square(b), multiply(4, multiply(a, c))).simplify();
70
+ const x1 = frac(substract(opposite(b), sqrt(delta)), multiply(2, a)).simplify();
71
+ const x2 = frac(add(opposite(b), sqrt(delta)), multiply(2, a)).simplify();
72
+ const x = x1;
73
+ const y = yByX.toDetailedEvaluation({ x: x }).simplify();
74
+ const oredered = x.evaluate() < y.evaluate() ? [x, y] : [y, x];
75
+ return `On note $x$ et $y$ les dimensions du rectangle. On a alors :
76
+
77
+ $$
78
+ 2x+2y = ${perimeter.toTex()}
79
+ $$
80
+
81
+ d'où
82
+
83
+ $$
84
+ x+y = ${halfPerimeter.toTex()}
85
+ $$
86
+
87
+ et
88
+
89
+
90
+ $$
91
+ xy = ${area.toTex()}
92
+ $$
93
+
94
+ La première équation permet d'exprimer $y$ en fonction de $x$ :
95
+
96
+ $$
97
+ y = ${halfPerimeter.toTex()} - x
98
+ $$
99
+
100
+ On injecte cela dans la deuxième équation :
101
+
102
+ $$
103
+ ${multiply("x", yByX).toTex()} = ${area.toTex()}
104
+ $$
105
+
106
+ Cela nous donne une équation du second degré :
107
+
108
+ $$
109
+ ${substract(multiply("x", yByX), area)
110
+ .simplify({
111
+ towardsDistribute: true,
112
+ forbidFactorize: true,
113
+ })
114
+ .toTex()}=0
115
+ $$
116
+
117
+ On calcule le discriminant :
118
+
119
+ $$
120
+ \\Delta = ${substract(square(b), multiply(4, multiply(a, c))).toSimplificationTex()}
121
+ $$
122
+
123
+ Il y a donc deux solutions :
124
+
125
+ $$
126
+ x_1 = ${frac(substract(opposite(b), sqrt(delta)), multiply(2, a)).toSimplificationTex()}
127
+ $$
128
+
129
+ ce qui donne $y = ${yByX
130
+ .toDetailedEvaluation({ x: x1 })
131
+ .toSimplificationTex()}$ ; et :
132
+
133
+ $$
134
+ x_2 = ${frac(add(opposite(b), sqrt(delta)), multiply(2, a)).toSimplificationTex()}
135
+ $$
136
+
137
+ ce qui donne $y = ${yByX
138
+ .toDetailedEvaluation({ x: x2 })
139
+ .toSimplificationTex()}$.
140
+
141
+ La largeur du rectangle est donc $${oredered[0].toTex()}$ et sa longueur est $${oredered[1].toTex()}$.
142
+ `;
143
+ };
144
+ const getKeys = () => {
145
+ return ["et"];
146
+ };
147
+ const isAnswerValid = (ans, { answer }) => {
148
+ try {
149
+ const answerValues = answer.split("\\text{ et }");
150
+ const values = ans.includes("et")
151
+ ? ans.split("\\text{ et }")
152
+ : ans.split(",");
153
+ const parsed = values.map((e) => valueParser(e));
154
+ if (parsed.some((e) => e === false))
155
+ return false;
156
+ return [...parsed]
157
+ .sort((a, b) => a - b)
158
+ .every((e, i) => numberVEA(e.frenchify(), answerValues[i]));
159
+ }
160
+ catch (err) {
161
+ return handleVEAError(err);
162
+ }
163
+ };
164
+ const getRectangleSizesFromPerimeterAndAreaQuestion = () => {
165
+ const largeur = randint(1, 10);
166
+ const longueur = randint(largeur + 1, largeur + 10);
167
+ const identifiers = {
168
+ perimeterIds: add(2 * longueur, 2 * largeur)
169
+ .simplify()
170
+ .toIdentifiers(),
171
+ areaIds: multiply(longueur, largeur).simplify().toIdentifiers(),
172
+ };
173
+ return getQuestionFromIdentifiers(identifiers);
174
+ };
175
+ const getQuestionFromIdentifiers = (identifiers) => {
176
+ return {
177
+ answer: getAnswer(identifiers),
178
+ instruction: getInstruction(identifiers),
179
+ keys: getKeys(identifiers),
180
+ answerFormat: "tex",
181
+ identifiers,
182
+ hint: getHint(identifiers),
183
+ correction: getCorrection(identifiers),
184
+ };
185
+ };
186
+ export const rectangleSizesFromPerimeterAndArea = {
187
+ id: "rectangleSizesFromPerimeterAndArea",
188
+ label: "Déterminer les dimensions d'un rectangle dont on connaît le périmètre et l'aire (second degré)",
189
+ isSingleStep: true,
190
+ generator: (nb, opts) => getDistinctQuestions(() => getRectangleSizesFromPerimeterAndAreaQuestion(opts), nb),
191
+ qcmTimer: 60,
192
+ freeTimer: 60,
193
+ getPropositions,
194
+ isAnswerValid,
195
+ subject: "Mathématiques",
196
+ getInstruction,
197
+ getHint,
198
+ getCorrection,
199
+ getAnswer,
200
+ getQuestionFromIdentifiers,
201
+ hasHintAndCorrection: true,
202
+ };
@@ -108,7 +108,7 @@ const getCorrection = (identifiers) => {
108
108
  ["=", substract(square(normU), square(normV)).toTex()],
109
109
  ["=", getAnswer(identifiers)],
110
110
  ];
111
- return `On utilies une identité remarquable, ainsi que le fait que pour tout vecteur $\\overrightarrow{u}$ :
111
+ return `On utilise une identité remarquable, ainsi que le fait que pour tout vecteur $\\overrightarrow{u}$ :
112
112
 
113
113
  $$
114
114
  \\overrightarrow{u}^2 = \\lVert \\overrightarrow{u} \\rVert^2
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ import { IntervalNodeIdentifiers } from "../../../../tree/nodes/sets/intervalNode.js";
4
+ type Identifiers = {
5
+ valuesIds: NodeIdentifiers[];
6
+ probasIds: NodeIdentifiers[];
7
+ intervalIds: IntervalNodeIdentifiers;
8
+ };
9
+ export declare const calculateProbaFromVATableLaw: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=calculateProbaFromVATableLaw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateProbaFromVATableLaw.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/randomVariable/calculateProbaFromVATableLaw.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAO7C,OAAO,EAGL,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAQ/C,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,WAAW,EAAE,uBAAuB,CAAC;CACtC,CAAC;AAoPF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAsB9D,CAAC"}
@@ -0,0 +1,232 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { randTupleInt } from "../../../../math/utils/random/randTupleInt.js";
6
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
7
+ import { MinusInfinityNode, PlusInfinityNode, } from "../../../../tree/nodes/numbers/infiniteNode.js";
8
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
9
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
10
+ import { IntervalNode, IntervalNodeConstructor, } from "../../../../tree/nodes/sets/intervalNode.js";
11
+ import { random } from "../../../../utils/alea/random.js";
12
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
15
+ import { dollarize } from "../../../../utils/latex/dollarize.js";
16
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
17
+ const getPropositions = (n, { answer, probasIds }) => {
18
+ const propositions = [];
19
+ addValidProp(propositions, answer);
20
+ const probas = probasIds.map((e) => reifyAlgebraic(e));
21
+ propWhile(propositions, n, () => {
22
+ const a = randint(0, 4);
23
+ const b = randint(a + 1, 5);
24
+ tryToAddWrongProp(propositions, probas
25
+ .slice(a, b)
26
+ .reduce((acc, curr) => add(acc, curr))
27
+ .simplify()
28
+ .toTex());
29
+ });
30
+ return shuffleProps(propositions, n);
31
+ };
32
+ const getAnswer = (identifiers) => {
33
+ const { probasIds, valuesIds } = identifiers;
34
+ const probas = probasIds.map((e) => reifyAlgebraic(e));
35
+ const values = valuesIds.map((e) => reifyAlgebraic(e));
36
+ const interval = IntervalNodeConstructor.fromIdentifiers(identifiers.intervalIds);
37
+ const aIndex = values.findIndex((v) => v.evaluate() === interval.a.evaluate());
38
+ const bIndex = values.findIndex((v) => v.evaluate() === interval.b.evaluate());
39
+ const aIncluded = interval.isLeftClosed();
40
+ const bIncluded = interval.isRightClosed();
41
+ if (aIndex > -1 && bIndex > -1) {
42
+ return probas
43
+ .slice(aIncluded ? aIndex : aIndex + 1, bIncluded ? bIndex + 1 : bIndex)
44
+ .reduce((acc, curr) => add(acc, curr))
45
+ .simplify()
46
+ .toTex();
47
+ }
48
+ else if (aIndex > -1) {
49
+ return probas
50
+ .slice(aIncluded ? aIndex : aIndex + 1)
51
+ .reduce((acc, curr) => add(acc, curr))
52
+ .simplify()
53
+ .toTex();
54
+ }
55
+ else {
56
+ return probas
57
+ .slice(0, bIncluded ? bIndex + 1 : bIndex)
58
+ .reduce((acc, curr) => add(acc, curr))
59
+ .simplify()
60
+ .toTex();
61
+ }
62
+ };
63
+ const getInstruction = (identifiers) => {
64
+ const { probasIds, valuesIds } = identifiers;
65
+ const probas = probasIds.map((e) => reifyAlgebraic(e));
66
+ const values = valuesIds.map((e) => reifyAlgebraic(e));
67
+ const interval = IntervalNodeConstructor.fromIdentifiers(identifiers.intervalIds);
68
+ const inequality = interval.toInequality("X".toTree());
69
+ return `Soit $X$ une variable aléatoire dont la loi de probabilité est donnée ci-dessous.
70
+
71
+ ${mdTable([
72
+ ["$x_i$", ...values.map((e) => dollarize(e.toTex()))],
73
+ ["$P(X=x_i)$", ...probas.map((e) => dollarize(e.toTex()))],
74
+ ])}
75
+
76
+ Calculer $P\\left(${inequality.toTex()}\\right)$.
77
+ `;
78
+ };
79
+ const getHint = (identifiers) => {
80
+ const { intervalIds } = identifiers;
81
+ const interval = IntervalNodeConstructor.fromIdentifiers(intervalIds);
82
+ const inequality = interval.toInequality("X".toTree());
83
+ return `Repère les valeurs $x_i$ de $X$ qui vérifient l'inégalité $${inequality.toTex()}$.
84
+
85
+ Puis, additionne les probabilités correspondantes.`;
86
+ };
87
+ const getCorrection = (identifiers) => {
88
+ const { probasIds, valuesIds } = identifiers;
89
+ const probas = probasIds.map((e) => reifyAlgebraic(e));
90
+ const values = valuesIds.map((e) => reifyAlgebraic(e));
91
+ const interval = IntervalNodeConstructor.fromIdentifiers(identifiers.intervalIds);
92
+ const inequality = interval.toInequality("X".toTree());
93
+ const aIndex = values.findIndex((v) => v.evaluate() === interval.a.evaluate());
94
+ const bIndex = values.findIndex((v) => v.evaluate() === interval.b.evaluate());
95
+ const aIncluded = interval.isLeftClosed();
96
+ const bIncluded = interval.isRightClosed();
97
+ let plage = [];
98
+ if (aIndex > -1 && bIndex > -1) {
99
+ plage = [aIncluded ? aIndex : aIndex + 1, bIncluded ? bIndex + 1 : bIndex];
100
+ }
101
+ else if (aIndex > -1) {
102
+ plage = [aIncluded ? aIndex : aIndex + 1, 5];
103
+ }
104
+ else {
105
+ plage = [0, bIncluded ? bIndex + 1 : bIndex];
106
+ }
107
+ return `On repère les valeurs $x_i$ de $X$ qui vérifient l'inégalité $${inequality.toTex()}$. Ce sont :
108
+
109
+ $$
110
+ ${values
111
+ .slice(plage[0], plage[1])
112
+ .map((e) => e.toTex())
113
+ .join("\\ ; \\ ")}
114
+ $$
115
+
116
+ Puis, on additionne les probabilités correspondantes :
117
+
118
+ ${alignTex([
119
+ ["", `P\\left(${inequality.toTex()}\\right)`],
120
+ [
121
+ "=",
122
+ probas
123
+ .slice(plage[0], plage[1])
124
+ .reduce((acc, curr) => add(acc, curr))
125
+ .toTex(),
126
+ ],
127
+ ["=", getAnswer(identifiers)],
128
+ ])}
129
+
130
+ `;
131
+ };
132
+ const getKeys = () => {
133
+ return [];
134
+ };
135
+ const isAnswerValid = (ans, { answer }) => {
136
+ try {
137
+ return rationalVEA(ans, answer);
138
+ }
139
+ catch (err) {
140
+ return handleVEAError(err);
141
+ }
142
+ };
143
+ function generateNumbers(n) {
144
+ const total = 1000;
145
+ let remaining = total;
146
+ let parts = [];
147
+ for (let i = 0; i < n - 1; i++) {
148
+ const max = remaining - (n - i - 1);
149
+ const value = Math.floor(Math.random() * max) + 1;
150
+ parts.push(value);
151
+ remaining -= value;
152
+ }
153
+ parts.push(remaining);
154
+ parts = shuffle(parts);
155
+ return parts.map((v) => v / total);
156
+ }
157
+ const getCalculateProbaFromVaTableLawQuestion = () => {
158
+ const values = randTupleInt(5, {
159
+ from: -9,
160
+ to: 10,
161
+ allDifferent: true,
162
+ sorted: true,
163
+ });
164
+ //types : 0 : >a, 1 : a<=X<=b, 2 : <b
165
+ const type = randint(0, 3);
166
+ let a;
167
+ let b;
168
+ let intervalIds;
169
+ switch (type) {
170
+ case 0:
171
+ a = random([values[1], values[2]]);
172
+ intervalIds = new IntervalNode(a.toTree(), PlusInfinityNode, random([ClosureType.OF, ClosureType.OO])).toIdentifiers();
173
+ break;
174
+ case 1:
175
+ a = values[1];
176
+ b = values[4];
177
+ intervalIds = new IntervalNode(a.toTree(), b.toTree(), random([
178
+ ClosureType.OF,
179
+ ClosureType.OO,
180
+ ClosureType.FF,
181
+ ClosureType.FO,
182
+ ])).toIdentifiers();
183
+ break;
184
+ case 2:
185
+ default:
186
+ b = random([values[2], values[3]]);
187
+ intervalIds = new IntervalNode(MinusInfinityNode, b.toTree(), random([ClosureType.FO, ClosureType.OO])).toIdentifiers();
188
+ break;
189
+ }
190
+ const identifiers = {
191
+ valuesIds: values.map((e) => e.toTree().toIdentifiers()),
192
+ intervalIds,
193
+ probasIds: generateNumbers(5).map((e) => e.toTree().toIdentifiers()),
194
+ };
195
+ return getQuestionFromIdentifiers(identifiers);
196
+ };
197
+ const getQuestionFromIdentifiers = (identifiers) => {
198
+ return {
199
+ answer: getAnswer(identifiers),
200
+ instruction: getInstruction(identifiers),
201
+ keys: getKeys(identifiers),
202
+ answerFormat: "tex",
203
+ identifiers,
204
+ hint: getHint(identifiers),
205
+ correction: getCorrection(identifiers),
206
+ style: {
207
+ tableOptions: {
208
+ firstColumnIsHeader: true,
209
+ firstCellIsDivided: false,
210
+ firstRowIsHeader: false,
211
+ },
212
+ },
213
+ };
214
+ };
215
+ export const calculateProbaFromVATableLaw = {
216
+ id: "calculateProbaFromVATableLaw",
217
+ connector: "=",
218
+ label: "Calculer une probabilité du type $P(a\\leq X\\leq b)$ avec une loi de probabilité",
219
+ isSingleStep: true,
220
+ generator: (nb, opts) => getDistinctQuestions(() => getCalculateProbaFromVaTableLawQuestion(opts), nb),
221
+ qcmTimer: 60,
222
+ freeTimer: 60,
223
+ getPropositions,
224
+ isAnswerValid,
225
+ subject: "Mathématiques",
226
+ getInstruction,
227
+ getHint,
228
+ getCorrection,
229
+ getAnswer,
230
+ getQuestionFromIdentifiers,
231
+ hasHintAndCorrection: true,
232
+ };
@@ -3,4 +3,5 @@ export * from "./randomVariableVariance.js";
3
3
  export * from "./isTableProbabilityLaw.js";
4
4
  export * from "./randomVariableStandardDeviation.js";
5
5
  export * from "./findValueToMatchRandomVariableAverage.js";
6
+ export * from "./calculateProbaFromVATableLaw.js";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/randomVariable/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AAErD,cAAc,4CAA4C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/randomVariable/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AAErD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mCAAmC,CAAC"}
@@ -4,3 +4,4 @@ export * from "./isTableProbabilityLaw.js";
4
4
  export * from "./randomVariableStandardDeviation.js";
5
5
  // export * from "./findValueForFairRandomVariable.js";
6
6
  export * from "./findValueToMatchRandomVariableAverage.js";
7
+ export * from "./calculateProbaFromVATableLaw.js";
@@ -150,7 +150,7 @@ export const arithmeticVariations = {
150
150
  answerType: "QCU",
151
151
  options,
152
152
  validateOptions: (opts) => {
153
- return opts.forms.length > 0
153
+ return opts?.forms?.length > 0
154
154
  ? {
155
155
  message: "OK",
156
156
  valid: true,
package/lib/index.d.ts CHANGED
@@ -1545,6 +1545,9 @@ declare const mathExercises: (Exercise<{
1545
1545
  }, {
1546
1546
  askedParam: string[];
1547
1547
  }> | Exercise<{
1548
+ perimeterIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1549
+ areaIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1550
+ }, Record<string, string | boolean | string[]>> | Exercise<{
1548
1551
  a: number;
1549
1552
  k: number;
1550
1553
  }, Record<string, string | boolean | string[]>> | Exercise<{
@@ -2995,6 +2998,10 @@ declare const mathExercises: (Exercise<{
2995
2998
  valuesIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
2996
2999
  probasIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
2997
3000
  avgIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
3001
+ }, Record<string, string | boolean | string[]>> | Exercise<{
3002
+ valuesIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
3003
+ probasIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
3004
+ intervalIds: import("./tree/nodes/sets/intervalNode.js").IntervalNodeIdentifiers;
2998
3005
  }, Record<string, string | boolean | string[]>> | Exercise<{
2999
3006
  pA: number;
3000
3007
  pB: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
@@ -143,8 +143,8 @@ export class Point {
143
143
  return Math.sqrt(dx ** 2 + dy ** 2);
144
144
  }
145
145
  distanceToNode(B) {
146
- const dx = substract(this.x, B.x);
147
- const dy = substract(this.y, B.y);
146
+ const dx = substract(B.x, this.x);
147
+ const dy = substract(B.y, this.y);
148
148
  return sqrt(add(square(dx), square(dy)));
149
149
  }
150
150
  equals(B) {
@@ -3,6 +3,7 @@ interface RandTupleIntOptions {
3
3
  to?: number;
4
4
  excludes?: number[][];
5
5
  allDifferent?: boolean;
6
+ sorted?: boolean;
6
7
  }
7
8
  /**
8
9
  * @param size tuple length
@@ -1 +1 @@
1
- {"version":3,"file":"randTupleInt.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/random/randTupleInt.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,SAAS,mBAAmB,KAC3B,MAAM,EAuBR,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,IAAI,MAAM,EACV,MAAM,MAAM,EACZ,SAAS,mBAAmB,KAC3B,MAAM,EAAE,EAcV,CAAC"}
1
+ {"version":3,"file":"randTupleInt.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/random/randTupleInt.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,SAAS,mBAAmB,KAC3B,MAAM,EAyBR,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,IAAI,MAAM,EACV,MAAM,MAAM,EACZ,SAAS,mBAAmB,KAC3B,MAAM,EAAE,EAcV,CAAC"}
@@ -26,6 +26,9 @@ export const randTupleInt = (size, options) => {
26
26
  }
27
27
  } while (options?.excludes &&
28
28
  options.excludes.some((el) => arrayEqual(el, res)));
29
+ if (options?.sorted) {
30
+ return res.sort((a, b) => a - b);
31
+ }
29
32
  return res;
30
33
  };
31
34
  export const distinctRandTupleInt = (nb, size, options) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.170",
4
+ "version": "3.0.171",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [