math-exercises 3.0.140 → 3.0.142

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 (95) hide show
  1. package/lib/exercises/math/calcul/arithmetics/euclideanDivision.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/arithmetics/euclideanDivision.js +65 -8
  3. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.d.ts +9 -0
  4. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.d.ts.map +1 -0
  5. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.js +111 -0
  6. package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.js +3 -6
  8. package/lib/exercises/math/calcul/arithmetics/index.d.ts +4 -0
  9. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/arithmetics/index.js +4 -1
  11. package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.d.ts +8 -0
  12. package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.d.ts.map +1 -0
  13. package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.js +128 -0
  14. package/lib/exercises/math/calcul/fractions/fractionEquality.d.ts +10 -0
  15. package/lib/exercises/math/calcul/fractions/fractionEquality.d.ts.map +1 -0
  16. package/lib/exercises/math/calcul/fractions/fractionEquality.js +123 -0
  17. package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
  18. package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
  19. package/lib/exercises/math/calcul/fractions/index.js +1 -0
  20. package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.d.ts +8 -0
  21. package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.d.ts.map +1 -0
  22. package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.js +392 -0
  23. package/lib/exercises/math/calcul/proportionality/index.d.ts +2 -0
  24. package/lib/exercises/math/calcul/proportionality/index.d.ts.map +1 -1
  25. package/lib/exercises/math/calcul/proportionality/index.js +2 -0
  26. package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.d.ts +8 -0
  27. package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.d.ts.map +1 -0
  28. package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.js +349 -0
  29. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.d.ts.map +1 -1
  30. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.js +10 -1
  31. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts +4 -1
  32. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
  33. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +32 -9
  34. package/lib/exercises/math/calculLitteral/equation/index.d.ts +2 -0
  35. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  36. package/lib/exercises/math/calculLitteral/equation/index.js +2 -0
  37. package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.js +1 -1
  38. package/lib/exercises/math/calculLitteral/equation/proportionEquation.d.ts +11 -0
  39. package/lib/exercises/math/calculLitteral/equation/proportionEquation.d.ts.map +1 -0
  40. package/lib/exercises/math/calculLitteral/equation/proportionEquation.js +152 -0
  41. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts +12 -0
  42. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts.map +1 -0
  43. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.js +197 -0
  44. package/lib/exercises/math/calculLitteral/factorisation/factoType2.d.ts.map +1 -1
  45. package/lib/exercises/math/calculLitteral/factorisation/factoType2.js +30 -4
  46. package/lib/exercises/math/calculLitteral/factorisation/factoType3.d.ts.map +1 -1
  47. package/lib/exercises/math/calculLitteral/factorisation/factoType3.js +30 -4
  48. package/lib/exercises/math/calculLitteral/factorisation/factoType4.d.ts.map +1 -1
  49. package/lib/exercises/math/calculLitteral/factorisation/factoType4.js +30 -5
  50. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.js +1 -1
  51. package/lib/exercises/math/dataRepresentations/index.js +1 -0
  52. package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.d.ts +12 -0
  53. package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.d.ts.map +1 -0
  54. package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.js +175 -0
  55. package/lib/exercises/math/functions/affines/index.d.ts +2 -0
  56. package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
  57. package/lib/exercises/math/functions/affines/index.js +2 -0
  58. package/lib/exercises/math/functions/affines/placePointsFromAffine.d.ts +8 -0
  59. package/lib/exercises/math/functions/affines/placePointsFromAffine.d.ts.map +1 -0
  60. package/lib/exercises/math/functions/affines/placePointsFromAffine.js +135 -0
  61. package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.d.ts +10 -0
  62. package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.d.ts.map +1 -0
  63. package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.js +208 -0
  64. package/lib/exercises/math/functions/basics/index.d.ts +1 -0
  65. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  66. package/lib/exercises/math/functions/basics/index.js +1 -0
  67. package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts +8 -0
  68. package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts.map +1 -0
  69. package/lib/exercises/math/functions/basics/placePointsFromValueTable.js +128 -0
  70. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
  71. package/lib/exercises/math/geometry/areas/rightTriangleArea.js +41 -0
  72. package/lib/exercises/math/geometry/pythagore/isTriangleRight.d.ts.map +1 -1
  73. package/lib/exercises/math/geometry/pythagore/isTriangleRight.js +19 -9
  74. package/lib/exercises/math/powers/powersOfTenMixOperations.js +1 -1
  75. package/lib/exercises/utils/data/boxXY.d.ts +7 -0
  76. package/lib/exercises/utils/data/boxXY.d.ts.map +1 -0
  77. package/lib/exercises/utils/data/boxXY.js +16 -0
  78. package/lib/exercises/utils/data/isBoxable.d.ts +2 -0
  79. package/lib/exercises/utils/data/isBoxable.d.ts.map +1 -0
  80. package/lib/exercises/utils/data/isBoxable.js +5 -0
  81. package/lib/exercises/utils/data/randomDataTable.d.ts +11 -0
  82. package/lib/exercises/utils/data/randomDataTable.d.ts.map +1 -0
  83. package/lib/exercises/utils/data/randomDataTable.js +65 -0
  84. package/lib/index.d.ts +43 -1
  85. package/lib/index.d.ts.map +1 -1
  86. package/lib/math/utils/random/randfloat.d.ts +1 -0
  87. package/lib/math/utils/random/randfloat.d.ts.map +1 -1
  88. package/lib/math/utils/random/randfloat.js +35 -0
  89. package/lib/utils/arrays/transpose.d.ts +2 -0
  90. package/lib/utils/arrays/transpose.d.ts.map +1 -0
  91. package/lib/utils/arrays/transpose.js +10 -0
  92. package/lib/utils/strings/randomFirstname.d.ts +5 -0
  93. package/lib/utils/strings/randomFirstname.d.ts.map +1 -0
  94. package/lib/utils/strings/randomFirstname.js +41 -0
  95. package/package.json +1 -1
@@ -0,0 +1,152 @@
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 { 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 { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { isVariableNode, VariableNode, } from "../../../../tree/nodes/variables/variableNode.js";
10
+ import { arrayRotation } from "../../../../utils/arrays/rotation.js";
11
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
13
+ const getPropositions = (n, { answer, aIds, bIds, cIds, dIds }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ const ids = [aIds, bIds, cIds, dIds];
17
+ for (let i = 0; i < 3; i++) {
18
+ const rotated = arrayRotation(ids, i + 1);
19
+ tryToAddWrongProp(propositions, getAnswerNode({
20
+ aIds: rotated[0],
21
+ bIds: rotated[1],
22
+ cIds: rotated[2],
23
+ dIds: rotated[3],
24
+ }).toTex());
25
+ }
26
+ propWhile(propositions, n, () => {
27
+ tryToAddWrongProp(propositions, RationalConstructor.randomIrreductible().toTree().toTex());
28
+ });
29
+ return shuffleProps(propositions, n);
30
+ };
31
+ const getAnswerNode = (identifiers) => {
32
+ const { aIds, bIds, cIds, dIds } = identifiers;
33
+ const values = [aIds, bIds, cIds, dIds].map((e) => reifyAlgebraic(e));
34
+ //a/b=c/d
35
+ //a=cb/d, b=ad/c, c=ad/b, d=cb/a
36
+ const xIndex = values.findIndex((x) => isVariableNode(x));
37
+ return frac(multiply(values[(xIndex + 2) % 4], values[xIndex % 2 === 0 ? xIndex + 1 : xIndex - 1]), values[3 - xIndex]).simplify();
38
+ };
39
+ const getAnswer = (identifiers) => {
40
+ return getAnswerNode(identifiers).toTex();
41
+ };
42
+ const getInstruction = (identifiers) => {
43
+ const { aIds, bIds, cIds, dIds } = identifiers;
44
+ const [a, b, c, d] = [aIds, bIds, cIds, dIds].map((e) => reifyAlgebraic(e).toTex());
45
+ return `Déterminer la valeur de $x$ solution de l'équation suivante :
46
+
47
+ $$
48
+ \\frac{${a}}{${b}}=\\frac{${c}}{${d}}
49
+ $$`;
50
+ };
51
+ const getHint = () => {
52
+ return `Si deux fractions sont égales :
53
+
54
+ $$
55
+ \\frac{a}{b}=\\frac{c}{d}
56
+ $$
57
+
58
+ alors on a :
59
+
60
+ $$
61
+ a\\times d = b\\times c
62
+ $$`;
63
+ };
64
+ const getCorrection = (identifiers) => {
65
+ const { aIds, bIds, cIds, dIds } = identifiers;
66
+ const values = [aIds, bIds, cIds, dIds].map((e) => reifyAlgebraic(e));
67
+ const xIndex = values.findIndex((x) => isVariableNode(x));
68
+ const answerRaw = frac(multiply(values[(xIndex + 2) % 4], values[xIndex % 2 === 0 ? xIndex + 1 : xIndex - 1]), values[3 - xIndex]);
69
+ return `Puisque :
70
+
71
+ $$
72
+ \\frac{${values[0].toTex()}}{${values[1].toTex()}}=\\frac{${values[2].toTex()}}{${values[3].toTex()}}
73
+ $$
74
+
75
+ alors :
76
+
77
+ $$
78
+ ${multiply(values[0], values[3]).toTex()}= ${multiply(values[1], values[2]).toTex()}
79
+ $$
80
+
81
+ On a donc :
82
+
83
+ ${alignTex([
84
+ ["x", "=", answerRaw.toTex()],
85
+ ["", "=", answerRaw.simplify().toTex()],
86
+ ])}
87
+ `;
88
+ };
89
+ const getKeys = () => {
90
+ return [];
91
+ };
92
+ const isAnswerValid = (ans, { answer }) => {
93
+ try {
94
+ return rationalVEA(ans, answer, {
95
+ allowNonIrreductible: true,
96
+ allowDecimal: true,
97
+ });
98
+ }
99
+ catch (err) {
100
+ return handleVEAError(err);
101
+ }
102
+ };
103
+ const getProportionEquationQuestion = () => {
104
+ const x = new VariableNode("x");
105
+ const values = [];
106
+ const numbers = [];
107
+ const xIndex = randint(0, 4);
108
+ for (let i = 0; i < 4; i++) {
109
+ if (i === xIndex)
110
+ values[i] = x.toIdentifiers();
111
+ else {
112
+ numbers[i] = randint(1, 12, i % 2 !== 0 ? [1, numbers[i - 1]] : []);
113
+ values[i] = numbers[i].toTree().toIdentifiers();
114
+ }
115
+ }
116
+ const identifiers = {
117
+ aIds: values[0],
118
+ bIds: values[1],
119
+ cIds: values[2],
120
+ dIds: values[3],
121
+ };
122
+ return getQuestionFromIdentifiers(identifiers);
123
+ };
124
+ const getQuestionFromIdentifiers = (identifiers) => {
125
+ return {
126
+ answer: getAnswer(identifiers),
127
+ instruction: getInstruction(identifiers),
128
+ keys: getKeys(identifiers),
129
+ answerFormat: "tex",
130
+ identifiers,
131
+ hint: getHint(identifiers),
132
+ correction: getCorrection(identifiers),
133
+ };
134
+ };
135
+ export const proportionEquation = {
136
+ id: "proportionEquation",
137
+ connector: "=",
138
+ label: "Résoudre une équation de proportionnalité du type $\\frac ab = \\frac xc$",
139
+ isSingleStep: true,
140
+ generator: (nb, opts) => getDistinctQuestions(() => getProportionEquationQuestion(opts), nb),
141
+ qcmTimer: 60,
142
+ freeTimer: 60,
143
+ getPropositions,
144
+ isAnswerValid,
145
+ subject: "Mathématiques",
146
+ getInstruction,
147
+ getHint,
148
+ getCorrection,
149
+ getAnswer,
150
+ getQuestionFromIdentifiers,
151
+ hasHintAndCorrection: true,
152
+ };
@@ -0,0 +1,12 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ aIds: NodeIdentifiers;
5
+ bIds: NodeIdentifiers;
6
+ };
7
+ type Options = {
8
+ useSetAsAnswer: boolean;
9
+ };
10
+ export declare const solveByFactorizingWithIdRmq3: Exercise<Identifiers, Options>;
11
+ export {};
12
+ //# sourceMappingURL=solveByFactorizingWithIdRmq3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solveByFactorizingWithIdRmq3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAW7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AA0LF,KAAK,OAAO,GAAG;IACb,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAUF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBvE,CAAC"}
@@ -0,0 +1,197 @@
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 { EquationSolutionNode } from "../../../../tree/nodes/equations/equationSolutionNode.js";
6
+ import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
7
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
8
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
9
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
+ import { square } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
12
+ import { DiscreteSetNode } from "../../../../tree/nodes/sets/discreteSetNode.js";
13
+ import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
14
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
15
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
16
+ const getPropositions = (n, { answer }) => {
17
+ const propositions = [];
18
+ addValidProp(propositions, answer);
19
+ propWhile(propositions, n, () => {
20
+ let a = randint(-10, 11, [0]);
21
+ let b = randint(-10, 11, [0, a]);
22
+ if (a > b)
23
+ [a, b] = [b, a];
24
+ tryToAddWrongProp(propositions, `x=${a}\\text{ ou }x=${b}`);
25
+ });
26
+ return shuffleProps(propositions, n);
27
+ };
28
+ const getSolutions = (identifiers) => {
29
+ const { aIds, bIds } = identifiers;
30
+ const a = reifyAlgebraic(aIds);
31
+ const b = reifyAlgebraic(bIds);
32
+ const sols = [add(a, b).simplify(), substract(a, b).simplify()].sort((a, b) => a.evaluate() - b.evaluate());
33
+ return sols;
34
+ };
35
+ const getAnswer = (identifiers, opts) => {
36
+ const sols = getSolutions(identifiers);
37
+ if (opts?.useSetAsAnswer)
38
+ return new EquationSolutionNode(new DiscreteSetNode(sols)).toTex();
39
+ else
40
+ return `x=${sols[0].toTex()}\\text{ ou }x=${sols[1].toTex()}`;
41
+ };
42
+ const getInstruction = (identifiers) => {
43
+ const { aIds, bIds } = identifiers;
44
+ const a = reifyAlgebraic(aIds);
45
+ const b = reifyAlgebraic(bIds);
46
+ return `Factoriser, puis résoudre l'équation suivante :
47
+
48
+ $$
49
+ ${substract(square(substract("x", a).simplify()), square(b).simplify()).toTex()} = 0
50
+ $$`;
51
+ };
52
+ const getHint = () => {
53
+ return `Tu peux factoriser cette équation en utilisant l'identité remarquable :
54
+
55
+ $$
56
+ a^2-b^2 = (a+b)(a-b)
57
+ $$
58
+
59
+ Ensuite, il faut résoudre une équation produit : un produit est nul si et seulement si un des deux facteurs est nul.`;
60
+ };
61
+ const getCorrection = (identifiers) => {
62
+ const { aIds, bIds } = identifiers;
63
+ const a = reifyAlgebraic(aIds);
64
+ const b = reifyAlgebraic(bIds);
65
+ return `On commence par factoriser l'équation en utilisant l'identité remarquable :
66
+
67
+ $$
68
+ a^2-b^2 = (a+b)(a-b)
69
+ $$
70
+
71
+ On a :
72
+
73
+ ${alignTex([
74
+ [
75
+ substract(square(substract("x", a).simplify()), square(b).simplify()).toTex(),
76
+ "=",
77
+ "0",
78
+ ],
79
+ [
80
+ substract(square(substract("x", a).simplify()), square(b)).toTex(),
81
+ "=",
82
+ "0",
83
+ ],
84
+ [
85
+ multiply(add("x", add(opposite(a).simplify(), b)), add("x", substract(opposite(a).simplify(), b))).toTex(),
86
+ "=",
87
+ "0",
88
+ ],
89
+ [
90
+ multiply(add("x", add(opposite(a), b).simplify()), add("x", substract(opposite(a), b).simplify())).toTex(),
91
+ "=",
92
+ "0",
93
+ ],
94
+ ])}
95
+
96
+ Un produit est nul si et seulement si un des deux facteurs est nul. On résout donc deux équations. D'une part :
97
+
98
+ $$
99
+ ${add("x", substract(b, a)).simplify().toTex()}=0
100
+ $$
101
+
102
+ ce qui donne $x=${substract(a, b).simplify().toTex()}$.
103
+
104
+ D'autre part :
105
+
106
+ $$
107
+ ${substract("x", add(a, b)).simplify().toTex()}=0
108
+ $$
109
+
110
+ ce qui donne $x=${add(a, b).simplify().toTex()}$.
111
+
112
+
113
+ Les solutions de cette équation sont donc $${substract(a, b)
114
+ .simplify()
115
+ .toTex()}$ et $${add(a, b).simplify().toTex()}$.
116
+ `;
117
+ };
118
+ const getKeys = (_identifiers, options) => {
119
+ return options?.useSetAsAnswer
120
+ ? ["S", "equal", "lbrace", "semicolon", "rbrace"]
121
+ : ["x", "equal", "ou"];
122
+ };
123
+ const isAnswerValid = (ans, { answer, ...identifiers }, opts) => {
124
+ try {
125
+ if (opts?.useSetAsAnswer) {
126
+ const setParsed = discreteSetParser(ans);
127
+ console.log(setParsed);
128
+ return false;
129
+ }
130
+ else {
131
+ const parsed = ans.split("\\text{ ou }");
132
+ if (parsed?.length !== 2)
133
+ return false;
134
+ const values = parsed.map((e) => e.replace("=", "").replace("x", ""));
135
+ const numbered = values
136
+ .map((v) => v.unfrenchify().toTree())
137
+ .sort((a, b) => a.evaluate() - b.evaluate());
138
+ const sols = getSolutions(identifiers);
139
+ if (!numberVEA(numbered[0].toTex(), sols[0].toTex()) ||
140
+ !numberVEA(numbered[1].toTex(), sols[1].toTex()))
141
+ return false;
142
+ return true;
143
+ }
144
+ throw Error("VEA not implemented");
145
+ }
146
+ catch (err) {
147
+ return handleVEAError(err);
148
+ }
149
+ };
150
+ const getSolveByFactorizingWithIdRmq3Question = () => {
151
+ const a = randint(-10, 11, [0]);
152
+ const b = randint(1, 11);
153
+ const identifiers = {
154
+ aIds: a.toTree().toIdentifiers(),
155
+ bIds: b.toTree().toIdentifiers(),
156
+ };
157
+ return getQuestionFromIdentifiers(identifiers);
158
+ };
159
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
160
+ return {
161
+ answer: getAnswer(identifiers, opts),
162
+ instruction: getInstruction(identifiers),
163
+ keys: getKeys(identifiers, opts),
164
+ answerFormat: "tex",
165
+ identifiers,
166
+ hint: getHint(identifiers),
167
+ correction: getCorrection(identifiers),
168
+ };
169
+ };
170
+ // const options: GeneratorOption[] = [
171
+ // {
172
+ // id: "useSetAsAnswer",
173
+ // label: "Écrire la réponse sous la forme d'ensemble",
174
+ // target: GeneratorOptionTarget.answer,
175
+ // type: GeneratorOptionType.checkbox,
176
+ // defaultValue: false,
177
+ // },
178
+ // ];
179
+ export const solveByFactorizingWithIdRmq3 = {
180
+ id: "solveByFactorizingWithIdRmq3",
181
+ connector: "=",
182
+ label: "Résoudre une équation par factorisation du type $(x-a)^2 -b^2 = 0$",
183
+ isSingleStep: true,
184
+ generator: (nb, opts) => getDistinctQuestions(() => getSolveByFactorizingWithIdRmq3Question(opts), nb),
185
+ qcmTimer: 60,
186
+ freeTimer: 60,
187
+ getPropositions,
188
+ isAnswerValid,
189
+ subject: "Mathématiques",
190
+ getInstruction,
191
+ getHint,
192
+ getCorrection,
193
+ getAnswer,
194
+ getQuestionFromIdentifiers,
195
+ hasHintAndCorrection: true,
196
+ // options,
197
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"factoType2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAqIF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
1
+ {"version":3,"file":"factoType2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAwBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAwJF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
@@ -3,10 +3,14 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
6
- import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { isMultiplyNode, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
7
7
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
8
8
  import { alignTex } from "../../../../utils/latex/alignTex.js";
9
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
+ import { isPowerNode, isSquareNode, } from "../../../../tree/nodes/operators/powerNode.js";
12
+ import { isOppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
14
  const getPropositions = (n, { answer, a, b, c, d, isSubstract }) => {
11
15
  const propositions = [];
12
16
  const affine1 = new Affine(a, b);
@@ -64,9 +68,31 @@ ${alignTex([
64
68
  const getKeys = () => {
65
69
  return ["x"];
66
70
  };
67
- const isAnswerValid = (ans, { answer, a, b, c, d, isSubstract }) => {
68
- const tree = getAnswerTree({ a, b, c, d, isSubstract });
69
- return ans === answer || tree.toAllValidTexs().includes(ans);
71
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
72
+ try {
73
+ const parsed = parseAlgebraic(ans);
74
+ if (!parsed)
75
+ return false;
76
+ if (answer !== "0" &&
77
+ !isMultiplyNode(parsed) &&
78
+ !isSquareNode(parsed) &&
79
+ !isPowerNode(parsed) &&
80
+ !isOppositeNode(parsed))
81
+ return false;
82
+ const simp = parsed.simplify({
83
+ forbidFactorize: true,
84
+ towardsDistribute: true,
85
+ });
86
+ const answerSimp = getAnswerTree(identifiers).simplify({
87
+ towardsDistribute: true,
88
+ forbidFactorize: true,
89
+ });
90
+ // const simp = parsed.simplify({});
91
+ return simp.toTex() === answerSimp.toTex();
92
+ }
93
+ catch (err) {
94
+ return handleVEAError(err);
95
+ }
70
96
  };
71
97
  const getFactoType2Question = () => {
72
98
  const b = randint(-10, 11);
@@ -1 +1 @@
1
- {"version":3,"file":"factoType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAyJF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
1
+ {"version":3,"file":"factoType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAyBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AA4KF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
@@ -3,10 +3,14 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
6
- import { multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { isMultiplyNode, multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
7
7
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
8
8
  import { alignTex } from "../../../../utils/latex/alignTex.js";
9
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
+ import { isPowerNode, isSquareNode, } from "../../../../tree/nodes/operators/powerNode.js";
12
+ import { isOppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
13
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
14
  const getPropositions = (n, { answer, a, b, c, d, k, isSubstract }) => {
11
15
  const propositions = [];
12
16
  const affine1 = new Affine(a, b);
@@ -72,9 +76,31 @@ ${alignTex([
72
76
  const getKeys = () => {
73
77
  return ["x"];
74
78
  };
75
- const isAnswerValid = (ans, { answer, a, b, c, d, k, isSubstract }) => {
76
- const tree = getAnswerTree({ a, b, c, d, k, isSubstract });
77
- return ans === answer || tree.toAllValidTexs().includes(ans);
79
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
80
+ try {
81
+ const parsed = parseAlgebraic(ans);
82
+ if (!parsed)
83
+ return false;
84
+ if (answer !== "0" &&
85
+ !isMultiplyNode(parsed) &&
86
+ !isSquareNode(parsed) &&
87
+ !isPowerNode(parsed) &&
88
+ !isOppositeNode(parsed))
89
+ return false;
90
+ const simp = parsed.simplify({
91
+ forbidFactorize: true,
92
+ towardsDistribute: true,
93
+ });
94
+ const answerSimp = getAnswerTree(identifiers).simplify({
95
+ towardsDistribute: true,
96
+ forbidFactorize: true,
97
+ });
98
+ // const simp = parsed.simplify({});
99
+ return simp.toTex() === answerSimp.toTex();
100
+ }
101
+ catch (err) {
102
+ return handleVEAError(err);
103
+ }
78
104
  };
79
105
  const getFactoType3Question = () => {
80
106
  const b = randint(-10, 11);
@@ -1 +1 @@
1
- {"version":3,"file":"factoType4.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType4.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAoKF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
1
+ {"version":3,"file":"factoType4.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType4.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AA0BrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAsLF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAe5C,CAAC"}
@@ -3,11 +3,14 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
6
- import { multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
6
+ import { isMultiplyNode, multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
7
7
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
8
8
  import { alignTex } from "../../../../utils/latex/alignTex.js";
9
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
- import { power } from "../../../../tree/nodes/operators/powerNode.js";
10
+ import { isPowerNode, isSquareNode, power, } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
+ import { isOppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
11
14
  const getPropositions = (n, { answer, a, b, c, d, k, isSubstract }) => {
12
15
  const propositions = [];
13
16
  const affine1 = new Affine(a, b);
@@ -69,9 +72,31 @@ ${alignTex([
69
72
  const getKeys = () => {
70
73
  return ["x"];
71
74
  };
72
- const isAnswerValid = (ans, { answer, a, b, c, d, k, isSubstract }) => {
73
- const tree = getAnswerTree({ a, b, c, d, k, isSubstract });
74
- return ans === answer || tree.toAllValidTexs().includes(ans);
75
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
76
+ try {
77
+ const parsed = parseAlgebraic(ans);
78
+ if (!parsed)
79
+ return false;
80
+ if (answer !== "0" &&
81
+ !isMultiplyNode(parsed) &&
82
+ !isSquareNode(parsed) &&
83
+ !isPowerNode(parsed) &&
84
+ !isOppositeNode(parsed))
85
+ return false;
86
+ const simp = parsed.simplify({
87
+ forbidFactorize: true,
88
+ towardsDistribute: true,
89
+ });
90
+ const answerSimp = getAnswerTree(identifiers).simplify({
91
+ towardsDistribute: true,
92
+ forbidFactorize: true,
93
+ });
94
+ // const simp = parsed.simplify({});
95
+ return simp.toTex() === answerSimp.toTex();
96
+ }
97
+ catch (err) {
98
+ return handleVEAError(err);
99
+ }
75
100
  };
76
101
  const getFactoType4Question = () => {
77
102
  const b = randint(-10, 11);
@@ -167,7 +167,7 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
167
167
  };
168
168
  export const compareAMinusB = {
169
169
  id: "compareAMinusB",
170
- label: "Comparer deux nombres $a$ et $b$ par le calcul de leur différence.",
170
+ label: "Comparer deux nombres $a$ et $b$ par le calcul de leur différence",
171
171
  isSingleStep: true,
172
172
  generator: (nb, opts) => getDistinctQuestions(() => getCompareAMinusBQuestion(opts), nb, 30),
173
173
  qcmTimer: 60,
@@ -15,6 +15,7 @@ export * from "./graphReading.js";
15
15
  export * from "./plausibleGraph.js";
16
16
  export * from "./halfPieChartReading.js";
17
17
  export * from "./halfPieChartCommenting.js";
18
+ // export * from "./placePointsFromDataTable.js";
18
19
  // export * from "./testGen.js";
19
20
  // export * from "./testGenGGB.js";
20
21
  // export * from "./testGenStudentGGB.js";
@@ -0,0 +1,12 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ isRowBased: boolean;
5
+ rowBasedDataTable: string[][];
6
+ indexX: number;
7
+ indexY: number;
8
+ arrCoordsAsNodeIds: NodeIdentifiers[][];
9
+ };
10
+ export declare const placePointsFromDataTable: Exercise<Identifiers>;
11
+ export {};
12
+ //# sourceMappingURL=placePointsFromDataTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placePointsFromDataTable.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/placePointsFromDataTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAWrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAiB7C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,EAAE,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,eAAe,EAAE,EAAE,CAAC;CACzC,CAAC;AAyOF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAiB1D,CAAC"}