math-exercises 3.0.88 → 3.0.89

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 (75) hide show
  1. package/lib/exercises/exercise.d.ts +1 -1
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/arithmetics/findZeroesProductQuotient.d.ts +11 -0
  4. package/lib/exercises/math/calcul/arithmetics/findZeroesProductQuotient.d.ts.map +1 -0
  5. package/lib/exercises/math/calcul/arithmetics/findZeroesProductQuotient.js +213 -0
  6. package/lib/exercises/math/calcul/arithmetics/index.d.ts +1 -0
  7. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/arithmetics/index.js +1 -0
  9. package/lib/exercises/math/functions/basics/index.d.ts +1 -0
  10. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  11. package/lib/exercises/math/functions/basics/index.js +2 -0
  12. package/lib/exercises/math/functions/basics/signOfFunction.d.ts +8 -0
  13. package/lib/exercises/math/functions/basics/signOfFunction.d.ts.map +1 -0
  14. package/lib/exercises/math/functions/basics/signOfFunction.js +122 -0
  15. package/lib/exercises/math/functions/square/squareImageInterval.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/square/squareImageInterval.js +7 -1
  17. package/lib/exercises/math/geometry/vectors/colinearity/alignementViaColinearity.d.ts +12 -0
  18. package/lib/exercises/math/geometry/vectors/colinearity/alignementViaColinearity.d.ts.map +1 -0
  19. package/lib/exercises/math/geometry/vectors/colinearity/alignementViaColinearity.js +127 -0
  20. package/lib/exercises/math/geometry/vectors/colinearity/colinearity.d.ts +11 -0
  21. package/lib/exercises/math/geometry/vectors/colinearity/colinearity.d.ts.map +1 -0
  22. package/lib/exercises/math/geometry/vectors/colinearity/colinearity.js +118 -0
  23. package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromBasis.d.ts +11 -0
  24. package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromBasis.d.ts.map +1 -0
  25. package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromBasis.js +158 -0
  26. package/lib/exercises/math/geometry/vectors/colinearity/index.d.ts +4 -0
  27. package/lib/exercises/math/geometry/vectors/colinearity/index.d.ts.map +1 -0
  28. package/lib/exercises/math/geometry/vectors/colinearity/index.js +3 -0
  29. package/lib/exercises/math/geometry/vectors/distributeAndReduceVectors.d.ts +9 -0
  30. package/lib/exercises/math/geometry/vectors/distributeAndReduceVectors.d.ts.map +1 -0
  31. package/lib/exercises/math/geometry/vectors/distributeAndReduceVectors.js +155 -0
  32. package/lib/exercises/math/geometry/vectors/index.d.ts +1 -2
  33. package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
  34. package/lib/exercises/math/geometry/vectors/index.js +2 -2
  35. package/lib/exercises/math/index.d.ts +1 -0
  36. package/lib/exercises/math/index.d.ts.map +1 -1
  37. package/lib/exercises/math/index.js +1 -0
  38. package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
  39. package/lib/exercises/math/primitive/polynomialPrimitive.js +10 -1
  40. package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.js +1 -1
  41. package/lib/exercises/math/python/variableAffectation.js +2 -2
  42. package/lib/exercises/math/tests/index.d.ts +4 -0
  43. package/lib/exercises/math/tests/index.d.ts.map +1 -0
  44. package/lib/exercises/math/tests/index.js +3 -0
  45. package/lib/exercises/math/tests/testMultiLineSignTable.d.ts +9 -0
  46. package/lib/exercises/math/tests/testMultiLineSignTable.d.ts.map +1 -0
  47. package/lib/exercises/math/tests/testMultiLineSignTable.js +156 -0
  48. package/lib/exercises/math/tests/testSignTable.d.ts +8 -0
  49. package/lib/exercises/math/tests/testSignTable.d.ts.map +1 -0
  50. package/lib/exercises/math/tests/testSignTable.js +90 -0
  51. package/lib/exercises/math/tests/testVarTable.d.ts +11 -0
  52. package/lib/exercises/math/tests/testVarTable.d.ts.map +1 -0
  53. package/lib/exercises/math/tests/testVarTable.js +147 -0
  54. package/lib/exercises/math/trigonometry/index.d.ts +1 -0
  55. package/lib/exercises/math/trigonometry/index.d.ts.map +1 -1
  56. package/lib/exercises/math/trigonometry/index.js +1 -0
  57. package/lib/exercises/math/trigonometry/trigoFundamentalEquation.d.ts +9 -0
  58. package/lib/exercises/math/trigonometry/trigoFundamentalEquation.d.ts.map +1 -0
  59. package/lib/exercises/math/trigonometry/trigoFundamentalEquation.js +151 -0
  60. package/lib/index.d.ts +42 -12
  61. package/lib/index.d.ts.map +1 -1
  62. package/lib/latexTester.js +2 -0
  63. package/lib/math/numbers/reals/real.d.ts.map +1 -1
  64. package/lib/math/numbers/reals/real.js +7 -2
  65. package/lib/tests/exoTest.d.ts.map +1 -1
  66. package/lib/tests/exoTest.js +9 -3
  67. package/lib/tests/questionTest.d.ts.map +1 -1
  68. package/lib/tests/questionTest.js +19 -10
  69. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  70. package/lib/tree/nodes/operators/addNode.js +3 -1
  71. package/lib/tree/parsers/latexParser.d.ts.map +1 -1
  72. package/lib/tree/parsers/latexParser.js +10 -0
  73. package/lib/types/keyIds.d.ts +1 -1
  74. package/lib/types/keyIds.d.ts.map +1 -1
  75. package/package.json +1 -1
@@ -0,0 +1,118 @@
1
+ import { addValidProp, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Vector, VectorConstructor } from "../../../../../math/geometry/vector.js";
4
+ import { RationalConstructor } from "../../../../../math/numbers/rationals/rational.js";
5
+ import { randint } from "../../../../../math/utils/random/randint.js";
6
+ import { reifyAlgebraic, } from "../../../../../tree/nodes/nodeConstructor.js";
7
+ import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
8
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
9
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
10
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
11
+ const rebuildIdentifiers = (oldIds) => {
12
+ if (oldIds.xu?.id)
13
+ return oldIds;
14
+ return {
15
+ xu: oldIds.xu.toTree().toIdentifiers(),
16
+ yu: oldIds.yu.toTree().toIdentifiers(),
17
+ xv: oldIds.xv.toTree().toIdentifiers(),
18
+ yv: oldIds.yv.toTree().toIdentifiers(),
19
+ };
20
+ };
21
+ const getInstruction = (identifiers) => {
22
+ const { xu, yu, xv, yv } = identifiers;
23
+ const u = new Vector("u", reifyAlgebraic(xu), reifyAlgebraic(yu));
24
+ const v = new Vector("v", reifyAlgebraic(xv), reifyAlgebraic(yv));
25
+ return `Soit deux vecteurs $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$.
26
+
27
+ Les vecteurs $${u.toTex()}$ et $${v.toTex()}$ sont-ils colinéaires ?`;
28
+ };
29
+ const getHint = (identifiers) => {
30
+ const u = new Vector("u", "x".toTree(), "y".toTree());
31
+ const v = new Vector("v", "x'".toTree(), "y'".toTree());
32
+ return `Deux vecteurs sont colinéaires si et seulement si leur déterminant est nul.
33
+
34
+ Le déterminant de deux vecteurs $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$ est :
35
+
36
+ $$
37
+ \\det(${u.toTex()}, ${v.toTex()}) = ${u.determinant(v).simplify().toTex()}
38
+ $$`;
39
+ };
40
+ const getCorrection = (identifiers) => {
41
+ const { xu, yu, xv, yv } = identifiers;
42
+ const u = new Vector("u", reifyAlgebraic(xu), reifyAlgebraic(yu));
43
+ const v = new Vector("v", reifyAlgebraic(xv), reifyAlgebraic(yv));
44
+ const det = u.determinant(v);
45
+ const detSimp = det.simplify();
46
+ const isCol = detSimp.evaluate() === 0;
47
+ return `On calcule le déterminant de $${u.toTex()}$ et $${v.toTex()}$ :
48
+
49
+ ${alignTex([
50
+ ["", `\\det(${u.toTex()}, ${v.toTex()})`],
51
+ ["=", det.toTex()],
52
+ ["=", detSimp.toTex()],
53
+ ])}
54
+
55
+ ${isCol
56
+ ? `Puisque le déterminant est nul, les vecteurs sont bien colinéaires.`
57
+ : `Puisque le déterminant n'est pas nul, les vecteurs ne sont pas colinéaires.`}`;
58
+ };
59
+ const getQuestionFromIdentifiers = (identifiers) => {
60
+ const question = {
61
+ instruction: getInstruction(identifiers),
62
+ answerFormat: "raw",
63
+ identifiers,
64
+ hint: getHint(identifiers),
65
+ correction: getCorrection(identifiers),
66
+ };
67
+ return question;
68
+ };
69
+ const getColinearityQuestion = () => {
70
+ const u = VectorConstructor.random("u", false);
71
+ const isColinear = coinFlip();
72
+ let v;
73
+ if (isColinear) {
74
+ const coeff = coinFlip()
75
+ ? new NumberNode(randint(-5, 5, [0, 1]))
76
+ : RationalConstructor.randomIrreductible(5).toTree();
77
+ v = u.times(coeff, "v");
78
+ }
79
+ else {
80
+ do {
81
+ v = VectorConstructor.random("v", false);
82
+ } while (u.isColinear(v));
83
+ }
84
+ const identifiers = {
85
+ xu: u.x.toIdentifiers(),
86
+ xv: v.x.toIdentifiers(),
87
+ yu: u.y.toIdentifiers(),
88
+ yv: v.y.toIdentifiers(),
89
+ };
90
+ return getQuestionFromIdentifiers(identifiers);
91
+ };
92
+ const getPropositions = (n, { answer, ...identifiers }) => {
93
+ const propositions = [];
94
+ // addValidProp(propositions, answer, "raw");
95
+ const { xu, yu, xv, yv } = identifiers;
96
+ const u = new Vector("u", reifyAlgebraic(xu), reifyAlgebraic(yu));
97
+ const v = new Vector("v", reifyAlgebraic(xv), reifyAlgebraic(yv));
98
+ const isCol = u.isColinear(v);
99
+ addValidProp(propositions, isCol ? "Oui" : "Non", "raw");
100
+ tryToAddWrongProp(propositions, "Oui", "raw");
101
+ tryToAddWrongProp(propositions, "Non", "raw");
102
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
103
+ return shuffle(propositions);
104
+ };
105
+ export const colinearity = {
106
+ id: "colinearity",
107
+ label: "Déterminer si deux vecteurs sont colinéaires (par les coordonnées)",
108
+ isSingleStep: true,
109
+ generator: (nb) => getDistinctQuestions(getColinearityQuestion, nb),
110
+ qcmTimer: 60,
111
+ freeTimer: 60,
112
+ getPropositions,
113
+ answerType: "QCU",
114
+ subject: "Mathématiques",
115
+ getQuestionFromIdentifiers,
116
+ hasHintAndCorrection: true,
117
+ rebuildIdentifiers,
118
+ };
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ a: NodeIdentifiers;
5
+ b: NodeIdentifiers;
6
+ c: NodeIdentifiers;
7
+ d: NodeIdentifiers;
8
+ };
9
+ export declare const colinearityFromBasis: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=colinearityFromBasis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colinearityFromBasis.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/colinearity/colinearityFromBasis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IAEjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AAgKF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAmBtD,CAAC"}
@@ -0,0 +1,158 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { RationalConstructor } from "../../../../../math/numbers/rationals/rational.js";
4
+ import { randint } from "../../../../../math/utils/random/randint.js";
5
+ import { reifyAlgebraic, } from "../../../../../tree/nodes/nodeConstructor.js";
6
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
7
+ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
10
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
11
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
12
+ const getPropositions = (n, { answer }) => {
13
+ const propositions = [];
14
+ addValidProp(propositions, answer, "raw");
15
+ tryToAddWrongProp(propositions, "Oui", "raw");
16
+ tryToAddWrongProp(propositions, "Non", "raw");
17
+ tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
18
+ return shuffleProps(propositions, n);
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { a, b, c, d } = identifiers;
22
+ const coeffs = [a, b, c, d].map((e) => reifyAlgebraic(e));
23
+ const det = substract(multiply(coeffs[0], coeffs[3]), multiply(coeffs[1], coeffs[2])).simplify({ forceDistributeFractions: true, forbidFactorize: true });
24
+ return Math.abs(det.evaluate()) < 0.001 ? "Oui" : "Non";
25
+ };
26
+ const getUNode = (identifiers) => {
27
+ const { a, b } = identifiers;
28
+ const coeffs = [a, b].map((e) => reifyAlgebraic(e));
29
+ return add(multiply(coeffs[0], "\\overrightarrow{AB}"), multiply(coeffs[1], "\\overrightarrow{AC}")).simplify({ forceDistributeFractions: true, forbidFactorize: true });
30
+ };
31
+ const getVNode = (identifiers) => {
32
+ const { c, d } = identifiers;
33
+ const coeffs = [c, d].map((e) => reifyAlgebraic(e));
34
+ return add(multiply(coeffs[0], "\\overrightarrow{AB}"), multiply(coeffs[1], "\\overrightarrow{AC}")).simplify({ forceDistributeFractions: true, forbidFactorize: true });
35
+ };
36
+ const getInstruction = (identifiers) => {
37
+ return `$A$, $B$ et $C$ sont trois points distincts et non alignés.
38
+
39
+ On considère les vecteurs :
40
+
41
+ $$
42
+ \\overrightarrow{u} = ${getUNode(identifiers).toTex()}
43
+ $$
44
+
45
+ et
46
+
47
+ $$
48
+ \\overrightarrow{v} = ${getVNode(identifiers).toTex()}
49
+ $$
50
+
51
+ Les vecteurs $\\overrightarrow{u}$ et $\\overrightarrow{v}$ sont-ils colinéaires ?`;
52
+ };
53
+ const getHint = (identifiers) => {
54
+ return `Peux-tu trouver un nombre $k$ tel que $\\overrightarrow{u} = k \\overrightarrow{v}$ ?`;
55
+ };
56
+ const getCorrection = (identifiers) => {
57
+ const { a, b, c, d } = identifiers;
58
+ const coeffs = [a, b, c, d].map((e) => reifyAlgebraic(e));
59
+ const det = substract(multiply(coeffs[0], coeffs[3]), multiply(coeffs[1], coeffs[2])).simplify({ forceDistributeFractions: true, forbidFactorize: true });
60
+ const isColinear = Math.abs(det.evaluate()) < 0.001;
61
+ const k = frac(coeffs[2], coeffs[0]).simplify();
62
+ const k2 = frac(coeffs[3], coeffs[1]).simplify();
63
+ return `On cherche un nombre $k$ tel que $\\overrightarrow{u} = k \\overrightarrow{v}$.
64
+
65
+ Puisque les vecteurs $\\overrightarrow{AB}$ et $\\overrightarrow{AC}$ ne sont pas colinéaires, ce nombre $k$ doit vérifier :
66
+
67
+ $$
68
+ ${multiply(coeffs[0], "\\overrightarrow{AB}").toTex()} \\times k = ${multiply(coeffs[2], "\\overrightarrow{AB}").toTex()}
69
+ $$
70
+
71
+ ce qui donne $k = ${k.toTex()}$, et :
72
+
73
+ $$
74
+ ${multiply(coeffs[1], "\\overrightarrow{AC}").toTex()} \\times k = ${multiply(coeffs[3], "\\overrightarrow{AC}").toTex()}
75
+ $$
76
+
77
+ ce qui donne $k = ${k2.toTex()}$.
78
+
79
+ ${isColinear
80
+ ? `Les vecteurs $\\overrightarrow{u}$ et $\\overrightarrow{v}$ sont donc colinéaires.
81
+ `
82
+ : `
83
+ On en conclut que les vecteurs $\\overrightarrow{u}$ et $\\overrightarrow{v}$ ne sont pas colinéaires.`}
84
+
85
+ `;
86
+ };
87
+ const getKeys = (identifiers) => {
88
+ return [];
89
+ };
90
+ const isAnswerValid = (ans, { answer }) => {
91
+ try {
92
+ throw Error("VEA not implemented");
93
+ }
94
+ catch (err) {
95
+ return handleVEAError(err);
96
+ }
97
+ };
98
+ const getColinearityFromBasisQuestion = (ops) => {
99
+ const isColinear = coinFlip();
100
+ let a;
101
+ let b;
102
+ let c;
103
+ let d;
104
+ if (isColinear) {
105
+ const k = coinFlip()
106
+ ? randint(-5, 5, [0, 1]).toTree()
107
+ : RationalConstructor.randomIrreductible().toTree();
108
+ a = randint(-8, 8, [0]).toTree();
109
+ b = randint(-8, 8, [0]).toTree();
110
+ c = multiply(a, k).simplify();
111
+ d = multiply(b, k).simplify();
112
+ }
113
+ else {
114
+ do {
115
+ a = randint(-8, 8, [0]).toTree();
116
+ b = randint(-8, 8, [0]).toTree();
117
+ c = randint(-8, 8, [0]).toTree();
118
+ d = randint(-8, 8, [0]).toTree();
119
+ } while (substract(multiply(a, d), multiply(b, c)).evaluate() === 0);
120
+ }
121
+ const identifiers = {
122
+ a: a.toIdentifiers(),
123
+ b: b.toIdentifiers(),
124
+ c: c.toIdentifiers(),
125
+ d: d.toIdentifiers(),
126
+ };
127
+ return getQuestionFromIdentifiers(identifiers);
128
+ };
129
+ const getQuestionFromIdentifiers = (identifiers) => {
130
+ return {
131
+ answer: getAnswer(identifiers),
132
+ instruction: getInstruction(identifiers),
133
+ keys: getKeys(identifiers),
134
+ answerFormat: "tex",
135
+ identifiers,
136
+ hint: getHint(identifiers),
137
+ correction: getCorrection(identifiers),
138
+ };
139
+ };
140
+ export const colinearityFromBasis = {
141
+ id: "colinearityFromBasis",
142
+ connector: "=",
143
+ label: "Reconnaître des vecteurs colinéaires (à partir d'expressions)",
144
+ isSingleStep: true,
145
+ generator: (nb, opts) => getDistinctQuestions(() => getColinearityFromBasisQuestion(opts), nb),
146
+ qcmTimer: 60,
147
+ freeTimer: 60,
148
+ getPropositions,
149
+ isAnswerValid,
150
+ subject: "Mathématiques",
151
+ getInstruction,
152
+ getHint,
153
+ getCorrection,
154
+ getAnswer,
155
+ getQuestionFromIdentifiers,
156
+ hasHintAndCorrection: true,
157
+ answerType: "QCU",
158
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./colinearity.js";
2
+ export * from "./alignementViaColinearity.js";
3
+ export * from "./colinearityFromBasis.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/colinearity/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./colinearity.js";
2
+ export * from "./alignementViaColinearity.js";
3
+ export * from "./colinearityFromBasis.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ expression: NodeIdentifiers;
5
+ type: number;
6
+ };
7
+ export declare const distributeAndReduceVectors: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=distributeAndReduceVectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distributeAndReduceVectors.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/distributeAndReduceVectors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,eAAe,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA4LF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAkB5D,CAAC"}
@@ -0,0 +1,155 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
5
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
7
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
8
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ const getPropositions = (n, { answer, type }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer);
13
+ while (propositions.length < n) {
14
+ switch (type) {
15
+ case 1:
16
+ case 2:
17
+ const a = randint(-9, 10, [0]);
18
+ const b = randint(-9, 10, [0]);
19
+ tryToAddWrongProp(propositions, add(multiply(a, "\\overrightarrow{u}"), multiply(b, "\\overrightarrow{v}")).toTex());
20
+ break;
21
+ case 3:
22
+ default:
23
+ const a2 = randint(-9, 10, [0]);
24
+ const b2 = randint(-9, 10, [0]);
25
+ const c2 = randint(-9, 10, [0]);
26
+ tryToAddWrongProp(propositions, add(add(multiply(a2, "\\overrightarrow{u}"), multiply(b2, "\\overrightarrow{u}")), multiply(c2, "\\overrightarrow{w}")).toTex());
27
+ break;
28
+ }
29
+ }
30
+ return shuffleProps(propositions, n);
31
+ };
32
+ const getAnswer = (identifiers) => {
33
+ const node = reifyAlgebraic(identifiers.expression);
34
+ const simp = node
35
+ .simplify({ towardsDistribute: true, forbidFactorize: true })
36
+ .toTex();
37
+ if (simp === "0")
38
+ return "\\overrightarrow{0}";
39
+ return simp;
40
+ };
41
+ const getInstruction = (identifiers) => {
42
+ const node = reifyAlgebraic(identifiers.expression);
43
+ return `Simplifier :
44
+
45
+ $$
46
+ ${node.toTex()}
47
+ $$`;
48
+ };
49
+ const getHint = (identifiers) => {
50
+ if (identifiers.type === 0) {
51
+ return `Regroupe les termes de même vecteur entre eux.`;
52
+ }
53
+ return `Utilise la propriété :
54
+
55
+ $$
56
+ k(a+b) = ka+kb
57
+ $$`;
58
+ };
59
+ const getCorrection = (identifiers) => {
60
+ const node = reifyAlgebraic(identifiers.expression);
61
+ if (identifiers.type === 0) {
62
+ return `On regroupe les termes de même vecteur entre eux :
63
+
64
+ $$
65
+ ${node.toTex()} = ${getAnswer(identifiers)}
66
+ $$`;
67
+ }
68
+ return `On distribue, puis on réduit :
69
+
70
+ $$
71
+
72
+ $$
73
+ `;
74
+ };
75
+ const getKeys = (identifiers) => {
76
+ return ["vectorU", "vectorV", "vectorW", "vectorNul"];
77
+ };
78
+ const isAnswerValid = (ans, { answer }) => {
79
+ try {
80
+ const parsed = parseAlgebraic(ans);
81
+ console.log(parsed.toTex());
82
+ return (parsed
83
+ .simplify({
84
+ forbidFactorize: true,
85
+ })
86
+ .toTex() === answer);
87
+ }
88
+ catch (err) {
89
+ return handleVEAError(err);
90
+ }
91
+ };
92
+ const getDistributeAndReduceVectorsQuestion = (ops) => {
93
+ const type = randint(0, 3);
94
+ let expression;
95
+ switch (type) {
96
+ case 0:
97
+ const a = randint(-9, 10, [0]);
98
+ const b = randint(-9, 10, [0]);
99
+ const c = randint(-9, 10, [0]);
100
+ const d = randint(-9, 10, [0]);
101
+ const vecs = shuffle(["u", "u", "v", "v"]);
102
+ expression = add(multiply(a, `\\overrightarrow{${vecs[0]}}`), add(multiply(b, `\\overrightarrow{${vecs[1]}}`), add(multiply(c, `\\overrightarrow{${vecs[2]}}`), multiply(d, `\\overrightarrow{${vecs[3]}}`)))).toIdentifiers();
103
+ break;
104
+ case 1:
105
+ const k = randint(-9, 10, [0, 1]);
106
+ const a2 = randint(-9, 10, [0]);
107
+ const b2 = randint(-9, 10, [0]);
108
+ expression = multiply(k, add(multiply(a2, `\\overrightarrow{u}`), multiply(b2, `\\overrightarrow{v}`))).toIdentifiers();
109
+ break;
110
+ case 2:
111
+ default:
112
+ const k2 = randint(-9, 10, [0, 1]);
113
+ const k3 = randint(-9, 10, [0, 1]);
114
+ const a3 = randint(-9, 10, [0]);
115
+ const b3 = randint(-9, 10, [0]);
116
+ const a4 = randint(-9, 10, [0]);
117
+ const b4 = randint(-9, 10, [0]);
118
+ expression = add(multiply(k2, add(multiply(a3, `\\overrightarrow{u}`), multiply(b3, `\\overrightarrow{v}`))), multiply(k3, add(multiply(a4, `\\overrightarrow{v}`), multiply(b4, `\\overrightarrow{w}`)))).toIdentifiers();
119
+ break;
120
+ }
121
+ const identifiers = {
122
+ type,
123
+ expression,
124
+ };
125
+ return getQuestionFromIdentifiers(identifiers);
126
+ };
127
+ const getQuestionFromIdentifiers = (identifiers) => {
128
+ return {
129
+ answer: getAnswer(identifiers),
130
+ instruction: getInstruction(identifiers),
131
+ keys: getKeys(identifiers),
132
+ answerFormat: "tex",
133
+ identifiers,
134
+ hint: getHint(identifiers),
135
+ correction: getCorrection(identifiers),
136
+ };
137
+ };
138
+ export const distributeAndReduceVectors = {
139
+ id: "distributeAndReduceVectors",
140
+ connector: "=",
141
+ label: "Simplifier une expression avec des vecteurs (distributivité)",
142
+ isSingleStep: true,
143
+ generator: (nb, opts) => getDistinctQuestions(() => getDistributeAndReduceVectorsQuestion(opts), nb),
144
+ qcmTimer: 60,
145
+ freeTimer: 60,
146
+ getPropositions,
147
+ isAnswerValid,
148
+ subject: "Mathématiques",
149
+ getInstruction,
150
+ getHint,
151
+ getCorrection,
152
+ getAnswer,
153
+ getQuestionFromIdentifiers,
154
+ hasHintAndCorrection: true,
155
+ };
@@ -2,8 +2,6 @@ export * from "./chasles.js";
2
2
  export * from "./coordinatesReading.js";
3
3
  export * from "./determinant.js";
4
4
  export * from "./vectorCoordinatesFromTwoPoints.js";
5
- export * from "./colinearity.js";
6
- export * from "./alignementViaColinearity.js";
7
5
  export * from "./paralellismViaColinearity.js";
8
6
  export * from "./parallelogramViaEqualVectors.js";
9
7
  export * from "./fourthParallelogramPoint.js";
@@ -18,4 +16,5 @@ export * from "./traceVectorDifference.js";
18
16
  export * from "./traceOppositeVector.js";
19
17
  export * from "./traceVectorMultiple.js";
20
18
  export * from "./findCoordForAligment.js";
19
+ export * from "./colinearity/index.js";
21
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qCAAqC,CAAC;AACpD,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC"}
@@ -2,8 +2,6 @@ export * from "./chasles.js";
2
2
  export * from "./coordinatesReading.js";
3
3
  export * from "./determinant.js";
4
4
  export * from "./vectorCoordinatesFromTwoPoints.js";
5
- export * from "./colinearity.js";
6
- export * from "./alignementViaColinearity.js";
7
5
  export * from "./paralellismViaColinearity.js";
8
6
  export * from "./parallelogramViaEqualVectors.js";
9
7
  export * from "./fourthParallelogramPoint.js";
@@ -18,3 +16,5 @@ export * from "./traceVectorDifference.js";
18
16
  export * from "./traceOppositeVector.js";
19
17
  export * from "./traceVectorMultiple.js";
20
18
  export * from "./findCoordForAligment.js";
19
+ export * from "./colinearity/index.js";
20
+ // export * from "./distributeAndReduceVectors.js";
@@ -22,4 +22,5 @@ export * from "./trigonometry/index.js";
22
22
  export * from "./python/index.js";
23
23
  export * from "./sampling/index.js";
24
24
  export * from "./dataRepresentations/index.js";
25
+ export * from "./tests/index.js";
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC"}
@@ -22,3 +22,4 @@ export * from "./trigonometry/index.js";
22
22
  export * from "./python/index.js";
23
23
  export * from "./sampling/index.js";
24
24
  export * from "./dataRepresentations/index.js";
25
+ export * from "./tests/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"polynomialPrimitive.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/primitive/polynomialPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,0BAA0B,EAE1B,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAiBF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,WAAW,CAKjE,CAAC;AAEF,eAAO,MAAM,6CAA6C,EAAE,0BAA0B,CACpF,WAAW,CAYZ,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,YAAY,CAAC,WAAW,CAexE,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,GAAG,CAAC,WAAW,CAqB7D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAYrD,CAAC"}
1
+ {"version":3,"file":"polynomialPrimitive.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/primitive/polynomialPrimitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGR,0BAA0B,EAE1B,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAiBF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,WAAW,CAKjE,CAAC;AAEF,eAAO,MAAM,6CAA6C,EAAE,0BAA0B,CACpF,WAAW,CAYZ,CAAC;AAEF,eAAO,MAAM,kCAAkC,EAAE,YAAY,CAAC,WAAW,CAexE,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,GAAG,CAAC,WAAW,CA8B7D,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAYrD,CAAC"}
@@ -51,6 +51,7 @@ export const isPolynomialPrimitiveAnswerValid = (ans, { coeffs, answer }) => {
51
51
  const parsed = parseAlgebraic(ans);
52
52
  if (!parsed)
53
53
  return false;
54
+ const ansParsed = parseAlgebraic(ans);
54
55
  return (parsed
55
56
  .simplify({
56
57
  towardsDistribute: true,
@@ -58,7 +59,15 @@ export const isPolynomialPrimitiveAnswerValid = (ans, { coeffs, answer }) => {
58
59
  forceDistributeFractions: true,
59
60
  decimalToFractions: true,
60
61
  })
61
- .toTex() === answer);
62
+ .toTex() ===
63
+ ansParsed
64
+ .simplify({
65
+ towardsDistribute: true,
66
+ forbidFactorize: true,
67
+ forceDistributeFractions: true,
68
+ decimalToFractions: true,
69
+ })
70
+ .toTex());
62
71
  }
63
72
  catch (err) {
64
73
  return handleVEAError(err);
@@ -9,7 +9,7 @@ const getPropositions = (n, { answer }) => {
9
9
  const propositions = [];
10
10
  addValidProp(propositions, answer);
11
11
  while (propositions.length < n) {
12
- tryToAddWrongProp(propositions, randint(0, 36) + "");
12
+ tryToAddWrongProp(propositions, frac(randint(0, 36), 37).toTex());
13
13
  }
14
14
  return shuffleProps(propositions, n);
15
15
  };
@@ -36,8 +36,8 @@ const getInstruction = (identifiers) => {
36
36
  return `On exécute le script Python ci-dessous. Quelle est la valeur de \`${variableName}\` à la fin du script ?
37
37
 
38
38
  \`\`\`
39
- ${variableName} = ${initialVariable};
40
- ${variableName} = ${affinePythonStrings};
39
+ ${variableName} = ${initialVariable}
40
+ ${variableName} = ${affinePythonStrings}
41
41
  \`\`\`
42
42
  `;
43
43
  };
@@ -0,0 +1,4 @@
1
+ export * from "./testSignTable.js";
2
+ export * from "./testVarTable.js";
3
+ export * from "./testMultiLineSignTable.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/tests/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./testSignTable.js";
2
+ export * from "./testVarTable.js";
3
+ export * from "./testMultiLineSignTable.js";
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ affine1Coeffs: number[];
4
+ affine2Coeffs: number[];
5
+ initTable: string[][];
6
+ };
7
+ export declare const testMultiLineSignTable: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=testMultiLineSignTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testMultiLineSignTable.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/tests/testMultiLineSignTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AAiJF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAkBxD,CAAC"}