math-exercises 2.2.95 → 2.2.97
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.
- package/lib/exercises/math/calcul/index.js +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivity.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivity.js +85 -32
- package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.js +82 -34
- package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.js +86 -36
- package/lib/exercises/math/calculLitteral/distributivity/simpleDistributivity.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/simpleDistributivity.js +17 -6
- package/lib/exercises/math/calculLitteral/distributivity/thirdIdentity.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/thirdIdentity.js +82 -32
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +1 -0
- package/lib/exercises/math/calculLitteral/simplifying/distributeAndSimplify.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/simplifying/distributeAndSimplify.js +38 -16
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts +3 -3
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.js +171 -75
- package/lib/exercises/math/dataReading/index.d.ts +2 -0
- package/lib/exercises/math/dataReading/index.d.ts.map +1 -0
- package/lib/exercises/math/dataReading/index.js +17 -0
- package/lib/exercises/math/dataReading/tableReading.d.ts +8 -0
- package/lib/exercises/math/dataReading/tableReading.d.ts.map +1 -0
- package/lib/exercises/math/dataReading/tableReading.js +105 -0
- package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.js +75 -11
- package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +0 -1
- package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
- package/lib/exercises/math/index.d.ts +1 -0
- package/lib/exercises/math/index.d.ts.map +1 -1
- package/lib/exercises/math/index.js +1 -0
- package/lib/exercises/math/probaStat/diceBasicProbas.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/diceBasicProbas.js +72 -20
- package/lib/exercises/vea/rationalVEA.js +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/tree/nodes/algebraicNode.d.ts +1 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts +2 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +21 -3
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts +2 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +12 -0
- package/lib/tree/nodes/operators/operatorNode.d.ts +5 -0
- package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/operatorNode.js +5 -1
- package/lib/tree/nodes/polynomials/monomNode.d.ts +2 -6
- package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -1
- package/lib/tree/nodes/polynomials/monomNode.js +102 -94
- package/lib/tree/parsers/affineParser.d.ts +1 -1
- package/lib/tree/parsers/affineParser.d.ts.map +1 -1
- package/lib/tree/parsers/affineParser.js +16 -21
- package/lib/tree/parsers/polynomialParser.d.ts +5 -1
- package/lib/tree/parsers/polynomialParser.d.ts.map +1 -1
- package/lib/tree/parsers/polynomialParser.js +4 -3
- package/lib/tree/parsers/purifyLatex.d.ts +1 -1
- package/lib/tree/parsers/purifyLatex.js +1 -1
- package/lib/utils/alea/shuffle.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doubleDistributivity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/doubleDistributivity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"doubleDistributivity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/doubleDistributivity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AA+JF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAmBtD,CAAC"}
|
|
@@ -10,12 +10,47 @@ const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
|
10
10
|
const operatorComposition_1 = require("../../../../tree/utilities/operatorComposition");
|
|
11
11
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
12
12
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
|
|
14
|
+
const polynomialParser_1 = require("../../../../tree/parsers/polynomialParser");
|
|
15
|
+
const getStatementNode = (identifiers) => {
|
|
16
|
+
const { affine1Coeffs, affine2Coeffs } = identifiers;
|
|
17
|
+
const affines = [
|
|
18
|
+
new affine_1.Affine(affine1Coeffs[1], affine1Coeffs[0]),
|
|
19
|
+
new affine_1.Affine(affine2Coeffs[1], affine2Coeffs[0]),
|
|
20
|
+
];
|
|
17
21
|
const statementTree = new multiplyNode_1.MultiplyNode(affines[0].toTree(), affines[1].toTree());
|
|
22
|
+
return statementTree;
|
|
23
|
+
};
|
|
24
|
+
const getStartStatement = (identifiers) => {
|
|
25
|
+
return getStatementNode(identifiers).toTex();
|
|
26
|
+
};
|
|
27
|
+
const getInstruction = (identifiers) => {
|
|
28
|
+
return `Développer et réduire :
|
|
29
|
+
|
|
30
|
+
$$
|
|
31
|
+
${getStartStatement(identifiers)}
|
|
32
|
+
$$`;
|
|
33
|
+
};
|
|
34
|
+
const getAnswer = (identifiers) => {
|
|
35
|
+
const { affine1Coeffs, affine2Coeffs } = identifiers;
|
|
36
|
+
const affines = [
|
|
37
|
+
new affine_1.Affine(affine1Coeffs[1], affine1Coeffs[0]),
|
|
38
|
+
new affine_1.Affine(affine2Coeffs[1], affine2Coeffs[0]),
|
|
39
|
+
];
|
|
18
40
|
const answer = affines[0].multiply(affines[1]).toTree().toTex();
|
|
41
|
+
return answer;
|
|
42
|
+
};
|
|
43
|
+
const getHint = (identifiers) => {
|
|
44
|
+
return "Multiplie chaque terme du premier facteur par chaque terme du second facteur, puis regroupe les termes similaires.";
|
|
45
|
+
};
|
|
46
|
+
const getCorrection = (identifiers) => {
|
|
47
|
+
const statementTex = getStartStatement(identifiers);
|
|
48
|
+
const answer = getAnswer(identifiers);
|
|
49
|
+
const { affine1Coeffs, affine2Coeffs } = identifiers;
|
|
50
|
+
const affines = [
|
|
51
|
+
new affine_1.Affine(affine1Coeffs[1], affine1Coeffs[0]),
|
|
52
|
+
new affine_1.Affine(affine2Coeffs[1], affine2Coeffs[0]),
|
|
53
|
+
];
|
|
19
54
|
const subTerms = [
|
|
20
55
|
new multiplyNode_1.MultiplyNode(affines[0].a.toTree(), "x".toTree()),
|
|
21
56
|
affines[0].b.toTree(),
|
|
@@ -28,30 +63,37 @@ const getDoubleDistributivityQuestion = () => {
|
|
|
28
63
|
new multiplyNode_1.MultiplyNode(subTerms[1], subTerms[2], { forceTimesSign: true }),
|
|
29
64
|
new multiplyNode_1.MultiplyNode(subTerms[1], subTerms[3], { forceTimesSign: true }),
|
|
30
65
|
];
|
|
31
|
-
|
|
66
|
+
return `
|
|
67
|
+
${(0, alignTex_1.alignTex)([
|
|
68
|
+
[statementTex, "=", (0, operatorComposition_1.operatorComposition)(addNode_1.AddNode, subMultiplications).toTex()],
|
|
69
|
+
[
|
|
70
|
+
"",
|
|
71
|
+
"=",
|
|
72
|
+
(0, operatorComposition_1.operatorComposition)(addNode_1.AddNode, subMultiplications.map((e) => e.simplify())).toTex(),
|
|
73
|
+
],
|
|
74
|
+
["", "=", answer],
|
|
75
|
+
])}
|
|
76
|
+
|
|
77
|
+
`;
|
|
78
|
+
};
|
|
79
|
+
const getDoubleDistributivityQuestion = () => {
|
|
80
|
+
const affines = affine_1.AffineConstructor.differentRandoms(2, undefined, {
|
|
81
|
+
excludes: [0],
|
|
82
|
+
});
|
|
83
|
+
const statementTree = new multiplyNode_1.MultiplyNode(affines[0].toTree(), affines[1].toTree());
|
|
84
|
+
const identifiers = {
|
|
85
|
+
affine1Coeffs: affines[0].coefficients,
|
|
86
|
+
affine2Coeffs: affines[1].coefficients,
|
|
87
|
+
};
|
|
32
88
|
const question = {
|
|
33
|
-
instruction:
|
|
89
|
+
instruction: getInstruction(identifiers),
|
|
34
90
|
startStatement: statementTree.toTex(),
|
|
35
|
-
answer,
|
|
91
|
+
answer: getAnswer(identifiers),
|
|
36
92
|
keys: ["x"],
|
|
37
93
|
answerFormat: "tex",
|
|
38
|
-
identifiers
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
hint: "Multiplie chaque terme du premier facteur par chaque terme du second facteur, puis regroupe les termes similaires.",
|
|
43
|
-
correction: `
|
|
44
|
-
${(0, alignTex_1.alignTex)([
|
|
45
|
-
[statementTex, "=", (0, operatorComposition_1.operatorComposition)(addNode_1.AddNode, subMultiplications).toTex()],
|
|
46
|
-
[
|
|
47
|
-
"",
|
|
48
|
-
"=",
|
|
49
|
-
(0, operatorComposition_1.operatorComposition)(addNode_1.AddNode, subMultiplications.map((e) => e.simplify())).toTex(),
|
|
50
|
-
],
|
|
51
|
-
["", "=", answer],
|
|
52
|
-
])}
|
|
53
|
-
|
|
54
|
-
`,
|
|
94
|
+
identifiers,
|
|
95
|
+
hint: getHint(identifiers),
|
|
96
|
+
correction: getCorrection(identifiers),
|
|
55
97
|
};
|
|
56
98
|
return question;
|
|
57
99
|
};
|
|
@@ -79,14 +121,21 @@ const getPropositions = (n, { answer, affine1Coeffs, affine2Coeffs }) => {
|
|
|
79
121
|
}
|
|
80
122
|
return (0, shuffle_1.shuffle)(propositions);
|
|
81
123
|
};
|
|
82
|
-
const isAnswerValid = (ans, {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
124
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
125
|
+
try {
|
|
126
|
+
const parsed = (0, polynomialParser_1.polynomialParser)(ans);
|
|
127
|
+
if (!parsed)
|
|
128
|
+
return false;
|
|
129
|
+
return (parsed
|
|
130
|
+
.simplify({
|
|
131
|
+
forbidFactorize: true,
|
|
132
|
+
towardsDistribute: true,
|
|
133
|
+
})
|
|
134
|
+
.toTex() === answer);
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
138
|
+
}
|
|
90
139
|
};
|
|
91
140
|
exports.doubleDistributivity = {
|
|
92
141
|
id: "doubleDistri",
|
|
@@ -102,4 +151,8 @@ exports.doubleDistributivity = {
|
|
|
102
151
|
isAnswerValid,
|
|
103
152
|
subject: "Mathématiques",
|
|
104
153
|
hasHintAndCorrection: true,
|
|
154
|
+
getInstruction,
|
|
155
|
+
getAnswer,
|
|
156
|
+
getCorrection,
|
|
157
|
+
getHint,
|
|
105
158
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firstIdentity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/firstIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"firstIdentity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/firstIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAOR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA2EF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,WAAW,CAwBnE,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,YAAY,CAAC,WAAW,CAkClE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,GAAG,CAAC,WAAW,CAgBvD,CAAC;AAMF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAmB/C,CAAC"}
|
|
@@ -11,34 +11,42 @@ const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
|
11
11
|
const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
12
12
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
13
13
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
max: 11,
|
|
21
|
-
});
|
|
14
|
+
const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
|
|
15
|
+
const latexParser_1 = require("../../../../tree/parsers/latexParser");
|
|
16
|
+
const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
|
|
17
|
+
const getStatementNode = (identifiers) => {
|
|
18
|
+
const { a, b } = identifiers;
|
|
19
|
+
const affine = new affine_1.Affine(a, b);
|
|
22
20
|
const statementTree = new powerNode_1.PowerNode(affine.toTree(), new numberNode_1.NumberNode(2));
|
|
23
|
-
|
|
21
|
+
return statementTree;
|
|
22
|
+
};
|
|
23
|
+
const getStartStatement = (identifiers) => {
|
|
24
|
+
return getStatementNode(identifiers).toTex();
|
|
25
|
+
};
|
|
26
|
+
const getInstruction = (identifiers) => {
|
|
27
|
+
return `Développer et réduire :
|
|
28
|
+
|
|
29
|
+
$$
|
|
30
|
+
${getStartStatement(identifiers)}
|
|
31
|
+
$$`;
|
|
32
|
+
};
|
|
33
|
+
const getHint = (identifiers) => {
|
|
34
|
+
const affine = new affine_1.Affine(identifiers.a, identifiers.b);
|
|
24
35
|
const aMonom = new multiplyNode_1.MultiplyNode(affine.a.toTree(), "x".toTree());
|
|
25
|
-
|
|
26
|
-
const question = {
|
|
27
|
-
instruction: `Développer et réduire : $${statementTex}$`,
|
|
28
|
-
startStatement: statementTex,
|
|
29
|
-
answer,
|
|
30
|
-
keys: ["x"],
|
|
31
|
-
answerFormat: "tex",
|
|
32
|
-
identifiers: { a: affine.a, b: affine.b },
|
|
33
|
-
hint: `Utilise l'identité remarquable :
|
|
36
|
+
return `Utilise l'identité remarquable :
|
|
34
37
|
|
|
35
38
|
$$
|
|
36
39
|
(a+b)^2 = a^2 + 2ab+b^2
|
|
37
40
|
$$
|
|
38
41
|
|
|
39
|
-
en prenant $a=${aMonom.toTex()}$ et $b=${affine.b}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
en prenant $a=${aMonom.toTex()}$ et $b=${affine.b}$.`;
|
|
43
|
+
};
|
|
44
|
+
const getCorrection = (identifiers) => {
|
|
45
|
+
const affine = new affine_1.Affine(identifiers.a, identifiers.b);
|
|
46
|
+
const statementTex = getStartStatement(identifiers);
|
|
47
|
+
const answer = getAnswer(identifiers);
|
|
48
|
+
const aMonom = new multiplyNode_1.MultiplyNode(affine.a.toTree(), "x".toTree());
|
|
49
|
+
return `On utilise l'identité remarquable :
|
|
42
50
|
|
|
43
51
|
$$
|
|
44
52
|
(a+b)^2 = a^2 + 2ab+b^2
|
|
@@ -46,15 +54,41 @@ $$
|
|
|
46
54
|
|
|
47
55
|
en prenant $a=${aMonom.toTex()}$ et $b=${affine.b}$.
|
|
48
56
|
|
|
57
|
+
Cela donne donc :
|
|
58
|
+
|
|
49
59
|
${(0, alignTex_1.alignTex)([
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
[
|
|
61
|
+
statementTex,
|
|
62
|
+
"=",
|
|
63
|
+
new addNode_1.AddNode(new addNode_1.AddNode(new powerNode_1.SquareNode(aMonom), new multiplyNode_1.MultiplyNode((2).toTree(), new multiplyNode_1.MultiplyNode(aMonom, affine.b.toTree()))), new powerNode_1.SquareNode(affine.b.toTree())).toTex(),
|
|
64
|
+
],
|
|
65
|
+
["", "=", answer],
|
|
66
|
+
])}
|
|
67
|
+
`;
|
|
68
|
+
};
|
|
69
|
+
const getAnswer = (identifiers) => {
|
|
70
|
+
const affine = new affine_1.Affine(identifiers.a, identifiers.b);
|
|
71
|
+
const answer = affine.multiply(affine).toTree().toTex();
|
|
72
|
+
return answer;
|
|
73
|
+
};
|
|
74
|
+
const getFirstIdentityQuestion = () => {
|
|
75
|
+
const affine = affine_1.AffineConstructor.random({
|
|
76
|
+
min: 1,
|
|
77
|
+
max: 11,
|
|
78
|
+
}, {
|
|
79
|
+
min: 1,
|
|
80
|
+
max: 11,
|
|
81
|
+
});
|
|
82
|
+
const identifiers = { a: affine.a, b: affine.b };
|
|
83
|
+
const question = {
|
|
84
|
+
instruction: getInstruction(identifiers),
|
|
85
|
+
startStatement: getStartStatement(identifiers),
|
|
86
|
+
answer: getAnswer(identifiers),
|
|
87
|
+
keys: ["x"],
|
|
88
|
+
answerFormat: "tex",
|
|
89
|
+
identifiers,
|
|
90
|
+
hint: getHint(identifiers),
|
|
91
|
+
correction: getCorrection(identifiers),
|
|
58
92
|
};
|
|
59
93
|
return question;
|
|
60
94
|
};
|
|
@@ -78,11 +112,20 @@ const getFirstIdentityPropositions = (n, { answer, a, b }) => {
|
|
|
78
112
|
return (0, shuffle_1.shuffle)(propositions);
|
|
79
113
|
};
|
|
80
114
|
exports.getFirstIdentityPropositions = getFirstIdentityPropositions;
|
|
81
|
-
const isFirstIdentityAnswerValid = (ans, { a, b }) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
115
|
+
const isFirstIdentityAnswerValid = (ans, { answer, a, b }) => {
|
|
116
|
+
try {
|
|
117
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
118
|
+
if (!parsed)
|
|
119
|
+
return false;
|
|
120
|
+
if (!(0, addNode_1.isAddNode)(parsed) && !(0, substractNode_1.isSubstractNode)(parsed))
|
|
121
|
+
return false;
|
|
122
|
+
return (parsed
|
|
123
|
+
.simplify({ forbidFactorize: true, towardsDistribute: true })
|
|
124
|
+
.toTex() === answer);
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
128
|
+
}
|
|
86
129
|
};
|
|
87
130
|
exports.isFirstIdentityAnswerValid = isFirstIdentityAnswerValid;
|
|
88
131
|
const tests = () => {
|
|
@@ -102,4 +145,9 @@ exports.firstIdentity = {
|
|
|
102
145
|
isAnswerValid: exports.isFirstIdentityAnswerValid,
|
|
103
146
|
subject: "Mathématiques",
|
|
104
147
|
hasHintAndCorrection: true,
|
|
148
|
+
getAnswer,
|
|
149
|
+
getInstruction,
|
|
150
|
+
getCorrection,
|
|
151
|
+
getHint,
|
|
152
|
+
getStartStatement,
|
|
105
153
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondIdentity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/secondIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"secondIdentity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/secondIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAOR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAiBlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiFF,eAAO,MAAM,yBAAyB,EAAE,iBAAiB,CAAC,WAAW,CAuBpE,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,YAAY,CAAC,WAAW,CAqCnE,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,GAAG,CAAC,WAAW,CAgBxD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAkBhD,CAAC"}
|
|
@@ -12,35 +12,54 @@ const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
|
12
12
|
const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
|
|
13
13
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
14
14
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
min: -10,
|
|
21
|
-
max: 0,
|
|
22
|
-
});
|
|
15
|
+
const latexParser_1 = require("../../../../tree/parsers/latexParser");
|
|
16
|
+
const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
|
|
17
|
+
const getStatementNode = (identifiers) => {
|
|
18
|
+
const { a, b } = identifiers;
|
|
19
|
+
const affine = new affine_1.Affine(a, b);
|
|
23
20
|
const statementTree = new powerNode_1.PowerNode(affine.toTree(), new numberNode_1.NumberNode(2));
|
|
24
|
-
|
|
21
|
+
return statementTree;
|
|
22
|
+
};
|
|
23
|
+
const getStartStatement = (identifiers) => {
|
|
24
|
+
const statementTree = getStatementNode(identifiers);
|
|
25
|
+
const statementTex = statementTree.toTex();
|
|
26
|
+
return statementTex;
|
|
27
|
+
};
|
|
28
|
+
const getInstruction = (identifiers) => {
|
|
29
|
+
const { a, b } = identifiers;
|
|
30
|
+
return `Développer et réduire :
|
|
31
|
+
|
|
32
|
+
$$
|
|
33
|
+
${getStartStatement(identifiers)}
|
|
34
|
+
$$`;
|
|
35
|
+
};
|
|
36
|
+
const getHint = (identifiers) => {
|
|
37
|
+
const { a, b } = identifiers;
|
|
38
|
+
const affine = new affine_1.Affine(a, b);
|
|
25
39
|
const aMonom = new multiplyNode_1.MultiplyNode(affine.a.toTree(), "x".toTree());
|
|
26
40
|
const bPositive = -affine.b;
|
|
27
|
-
|
|
28
|
-
const question = {
|
|
29
|
-
instruction: `Développer et réduire : $${statementTex}$`,
|
|
30
|
-
startStatement: statementTex,
|
|
31
|
-
answer,
|
|
32
|
-
keys: ["x"],
|
|
33
|
-
answerFormat: "tex",
|
|
34
|
-
identifiers: { a: affine.a, b: affine.b },
|
|
35
|
-
hint: `Utilise l'identité remarquable
|
|
41
|
+
return `Utilise l'identité remarquable
|
|
36
42
|
|
|
37
43
|
$$
|
|
38
44
|
(a-b)^2 = a^2 - 2ab+b^2
|
|
39
45
|
$$
|
|
40
46
|
|
|
41
|
-
en prenant $a=${aMonom.toTex()}$ et $b=${bPositive}
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
en prenant $a=${aMonom.toTex()}$ et $b=${bPositive}$`;
|
|
48
|
+
};
|
|
49
|
+
const getAnswer = (identifiers) => {
|
|
50
|
+
const { a, b } = identifiers;
|
|
51
|
+
const affine = new affine_1.Affine(a, b);
|
|
52
|
+
const answer = affine.multiply(affine).toTree().toTex();
|
|
53
|
+
return answer;
|
|
54
|
+
};
|
|
55
|
+
const getCorrection = (identifiers) => {
|
|
56
|
+
const { a, b } = identifiers;
|
|
57
|
+
const affine = new affine_1.Affine(a, b);
|
|
58
|
+
const aMonom = new multiplyNode_1.MultiplyNode(affine.a.toTree(), "x".toTree());
|
|
59
|
+
const bPositive = -affine.b;
|
|
60
|
+
const statementTex = getStartStatement(identifiers);
|
|
61
|
+
const answer = getAnswer(identifiers);
|
|
62
|
+
return `On utilise l'identité remarquable
|
|
44
63
|
|
|
45
64
|
$$
|
|
46
65
|
(a-b)^2 = a^2 - 2ab+b^2
|
|
@@ -49,14 +68,33 @@ $$
|
|
|
49
68
|
en prenant $a=${aMonom.toTex()}$ et $b=${bPositive}$ :
|
|
50
69
|
|
|
51
70
|
${(0, alignTex_1.alignTex)([
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
[
|
|
72
|
+
statementTex,
|
|
73
|
+
"=",
|
|
74
|
+
new addNode_1.AddNode(new substractNode_1.SubstractNode(new powerNode_1.SquareNode(aMonom), new multiplyNode_1.MultiplyNode((2).toTree(), new multiplyNode_1.MultiplyNode(aMonom, bPositive.toTree()))), new powerNode_1.SquareNode(bPositive.toTree())).toTex(),
|
|
75
|
+
],
|
|
76
|
+
["", "=", answer],
|
|
77
|
+
])}
|
|
78
|
+
`;
|
|
79
|
+
};
|
|
80
|
+
const getSecondIdentityQuestion = () => {
|
|
81
|
+
const affine = affine_1.AffineConstructor.random({
|
|
82
|
+
min: 1,
|
|
83
|
+
max: 11,
|
|
84
|
+
}, {
|
|
85
|
+
min: -10,
|
|
86
|
+
max: 0,
|
|
87
|
+
});
|
|
88
|
+
const identifiers = { a: affine.a, b: affine.b };
|
|
89
|
+
const question = {
|
|
90
|
+
instruction: getInstruction(identifiers),
|
|
91
|
+
startStatement: getStartStatement(identifiers),
|
|
92
|
+
answer: getAnswer(identifiers),
|
|
93
|
+
keys: ["x"],
|
|
94
|
+
answerFormat: "tex",
|
|
95
|
+
identifiers,
|
|
96
|
+
hint: getHint(identifiers),
|
|
97
|
+
correction: getCorrection(identifiers),
|
|
60
98
|
};
|
|
61
99
|
return question;
|
|
62
100
|
};
|
|
@@ -82,19 +120,26 @@ const getSecondIdentityPropositions = (n, { answer, a, b }) => {
|
|
|
82
120
|
return (0, shuffle_1.shuffle)(propositions);
|
|
83
121
|
};
|
|
84
122
|
exports.getSecondIdentityPropositions = getSecondIdentityPropositions;
|
|
85
|
-
const isSecondIdentityAnswerValid = (ans, { a, b }) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
123
|
+
const isSecondIdentityAnswerValid = (ans, { a, b, answer }) => {
|
|
124
|
+
try {
|
|
125
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
126
|
+
if (!parsed)
|
|
127
|
+
return false;
|
|
128
|
+
if (!(0, addNode_1.isAddNode)(parsed) && !(0, substractNode_1.isSubstractNode)(parsed))
|
|
129
|
+
return false;
|
|
130
|
+
return (parsed
|
|
131
|
+
.simplify({ forbidFactorize: true, towardsDistribute: true })
|
|
132
|
+
.toTex() === answer);
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
136
|
+
}
|
|
90
137
|
};
|
|
91
138
|
exports.isSecondIdentityAnswerValid = isSecondIdentityAnswerValid;
|
|
92
139
|
exports.secondIdentity = {
|
|
93
140
|
id: "idRmq2",
|
|
94
141
|
connector: "=",
|
|
95
142
|
label: "Identité remarquable $(a-b)^2$",
|
|
96
|
-
levels: ["3ème", "2nde"],
|
|
97
|
-
sections: ["Calcul littéral"],
|
|
98
143
|
isSingleStep: false,
|
|
99
144
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(exports.getSecondIdentityQuestion, nb),
|
|
100
145
|
getPropositions: exports.getSecondIdentityPropositions,
|
|
@@ -103,4 +148,9 @@ exports.secondIdentity = {
|
|
|
103
148
|
freeTimer: 60,
|
|
104
149
|
subject: "Mathématiques",
|
|
105
150
|
hasHintAndCorrection: true,
|
|
151
|
+
getInstruction,
|
|
152
|
+
getCorrection,
|
|
153
|
+
getHint,
|
|
154
|
+
getAnswer,
|
|
155
|
+
getStartStatement,
|
|
106
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleDistributivity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/simpleDistributivity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"simpleDistributivity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/simpleDistributivity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAalC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAqGF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAmBtD,CAAC"}
|
|
@@ -10,6 +10,8 @@ const addNode_1 = require("../../../../tree/nodes/operators/addNode");
|
|
|
10
10
|
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
11
11
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
12
12
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
13
|
+
const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
|
|
14
|
+
const polynomialParser_1 = require("../../../../tree/parsers/polynomialParser");
|
|
13
15
|
const buildStatement = (identifiers) => {
|
|
14
16
|
const { a, b, coeff } = identifiers;
|
|
15
17
|
const affine = new affine_1.Affine(a, b);
|
|
@@ -18,7 +20,11 @@ const buildStatement = (identifiers) => {
|
|
|
18
20
|
};
|
|
19
21
|
const getInstruction = (identifiers) => {
|
|
20
22
|
const statementTex = buildStatement(identifiers).toTex();
|
|
21
|
-
return `Développer et réduire :
|
|
23
|
+
return `Développer et réduire :
|
|
24
|
+
|
|
25
|
+
$$
|
|
26
|
+
${statementTex}
|
|
27
|
+
$$`;
|
|
22
28
|
};
|
|
23
29
|
const getAnswer = (identifiers) => {
|
|
24
30
|
const { a, b, coeff } = identifiers;
|
|
@@ -75,11 +81,16 @@ const getPropositions = (n, { answer, a, b, coeff }) => {
|
|
|
75
81
|
}
|
|
76
82
|
return (0, shuffle_1.shuffle)(propositions);
|
|
77
83
|
};
|
|
78
|
-
const isAnswerValid = (ans, { a, b, coeff }) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
const isAnswerValid = (ans, { answer, a, b, coeff }) => {
|
|
85
|
+
try {
|
|
86
|
+
const parsed = (0, polynomialParser_1.polynomialParser)(ans);
|
|
87
|
+
if (!parsed)
|
|
88
|
+
return false;
|
|
89
|
+
return parsed.simplify().toTex() === answer;
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
93
|
+
}
|
|
83
94
|
};
|
|
84
95
|
exports.simpleDistributivity = {
|
|
85
96
|
id: "simpleDistri",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thirdIdentity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/thirdIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"thirdIdentity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/distributivity/thirdIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAOR,YAAY,EAEZ,iBAAiB,EACjB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAiBlC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAoEF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,WAAW,CAkBnE,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,YAAY,CAAC,WAAW,CA2BlE,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,GAAG,CAAC,WAAW,CAgBvD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAiB/C,CAAC"}
|