math-exercises 2.2.40 → 2.2.41
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/derivation/derivative/sqrtCompositionDerivation.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/sqrtCompositionDerivation.js +0 -1
- package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromFirstTerms.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromFirstTerms.js +3 -1
- package/lib/exercises/math/trigonometry/arcLength.js +1 -1
- package/lib/exercises/math/trigonometry/mainAngleMeasure.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/mainAngleMeasure.js +25 -9
- package/lib/playground.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +18 -6
- package/lib/tree/parsers/latexParser.d.ts.map +1 -1
- package/lib/tree/parsers/latexParser.js +8 -1
- package/lib/tree/parsers/numberParser.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqrtCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/sqrtCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"sqrtCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/sqrtCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAmEF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
|
|
@@ -41,7 +41,6 @@ const isAnswerValid = (ans, { answer, affineA, affineB }) => {
|
|
|
41
41
|
try {
|
|
42
42
|
const parsed = (0, latexParser_1.parseLatex)(ans);
|
|
43
43
|
const simplified = parsed.simplify();
|
|
44
|
-
console.log(simplified.toTex());
|
|
45
44
|
return simplified.toTex() === answer;
|
|
46
45
|
}
|
|
47
46
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizeReasonFromFirstTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/recognizeReasonFromFirstTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"recognizeReasonFromFirstTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/recognizeReasonFromFirstTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAKlC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAqCF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAc/D,CAAC"}
|
|
@@ -4,6 +4,7 @@ exports.recognizeReasonFromFirstTerms = void 0;
|
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
6
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
7
|
+
const numberParser_1 = require("../../../../tree/parsers/numberParser");
|
|
7
8
|
const getRecognizeReasonFromFirstTermsQuestion = () => {
|
|
8
9
|
const firstTerm = (0, randint_1.randint)(1, 20);
|
|
9
10
|
const reason = (0, randint_1.randint)(-5, 6, [0]);
|
|
@@ -28,7 +29,8 @@ const getPropositions = (n, { answer }) => {
|
|
|
28
29
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
29
30
|
};
|
|
30
31
|
const isAnswerValid = (ans, { answer }) => {
|
|
31
|
-
|
|
32
|
+
const parsed = (0, numberParser_1.numberParser)(ans);
|
|
33
|
+
return parsed === answer;
|
|
32
34
|
};
|
|
33
35
|
exports.recognizeReasonFromFirstTerms = {
|
|
34
36
|
id: "recognizeReasonFromFirstTerms",
|
|
@@ -37,7 +37,7 @@ const getAnswer = (identifiers) => {
|
|
|
37
37
|
return getAnswerNode(identifiers).toTex();
|
|
38
38
|
};
|
|
39
39
|
const getInstruction = (identifiers) => {
|
|
40
|
-
return `Soit $\\mathcal C$ un cercle de centre $O$ et de rayon $${identifiers.radius}$. Soient $A$ et $B$ deux points sur ce cercle. L'angle au centre $\\widehat{
|
|
40
|
+
return `Soit $\\mathcal C$ un cercle de centre $O$ et de rayon $${identifiers.radius}$. Soient $A$ et $B$ deux points sur ce cercle. L'angle au centre $\\widehat{AOB}$ vaut $${identifiers.isThetaInDegree
|
|
41
41
|
? new degree_1.DegreeNode(identifiers.thetaInDegree).toTex()
|
|
42
42
|
: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.thetaInRadNodeIds).toTex() +
|
|
43
43
|
"\\ \\text{rad}"}$. Quelle est la longueur de l'arc de cercle $\\overset{\\Large \\frown}{AB}$ ?`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mainAngleMeasure.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/mainAngleMeasure.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"mainAngleMeasure.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/trigonometry/mainAngleMeasure.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AA+FF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAiBlD,CAAC"}
|
|
@@ -9,6 +9,7 @@ const nodeConstructor_1 = require("../../../tree/nodes/nodeConstructor");
|
|
|
9
9
|
const piNode_1 = require("../../../tree/nodes/numbers/piNode");
|
|
10
10
|
const addNode_1 = require("../../../tree/nodes/operators/addNode");
|
|
11
11
|
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
12
|
+
const latexParser_1 = require("../../../tree/parsers/latexParser");
|
|
12
13
|
const random_1 = require("../../../utils/alea/random");
|
|
13
14
|
const getPropositions = (n, { answer, degree }) => {
|
|
14
15
|
const propositions = [];
|
|
@@ -42,16 +43,30 @@ ${angle.toTex()}
|
|
|
42
43
|
$$
|
|
43
44
|
`;
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const getHint = (identifiers) => {
|
|
47
|
+
const angle = nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.nodeIds);
|
|
48
|
+
return `La mesure principale d'un angle en radian est sa valeur appartenant à l'intervalle $]-\\pi; \\pi]$. Il faut donc ajouter (ou retirer) $2\\pi$ à $${angle.toTex()}$ jusqu'à ce que le résultat soit dans cet intervalle.`;
|
|
49
|
+
};
|
|
50
|
+
const getCorrection = (identifiers) => {
|
|
51
|
+
return `a`;
|
|
52
|
+
};
|
|
49
53
|
const getKeys = (identifiers) => {
|
|
50
54
|
return ["pi"];
|
|
51
55
|
};
|
|
52
56
|
const isAnswerValid = (ans, { answer, degree }) => {
|
|
53
57
|
const value = remarkableValues_1.mainTrigoValues.find((e) => e.degree === degree);
|
|
54
|
-
|
|
58
|
+
try {
|
|
59
|
+
const parsed = (0, latexParser_1.parseLatex)(ans);
|
|
60
|
+
console.log("parsed", parsed);
|
|
61
|
+
const simplified = parsed.simplify().toTex();
|
|
62
|
+
console.log("simp", simplified);
|
|
63
|
+
return simplified === answer;
|
|
64
|
+
// return value.angle.toAllValidTexs().includes(ans);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
console.log(err);
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
55
70
|
};
|
|
56
71
|
const getMainAngleMeasureQuestion = () => {
|
|
57
72
|
const value = (0, random_1.random)(remarkableValues_1.mainTrigoValues);
|
|
@@ -68,8 +83,8 @@ const getMainAngleMeasureQuestion = () => {
|
|
|
68
83
|
keys: getKeys(identifiers),
|
|
69
84
|
answerFormat: "tex",
|
|
70
85
|
identifiers,
|
|
71
|
-
|
|
72
|
-
|
|
86
|
+
hint: getHint(identifiers),
|
|
87
|
+
correction: getCorrection(identifiers),
|
|
73
88
|
};
|
|
74
89
|
return question;
|
|
75
90
|
};
|
|
@@ -85,7 +100,8 @@ exports.mainAngleMeasure = {
|
|
|
85
100
|
getPropositions,
|
|
86
101
|
isAnswerValid,
|
|
87
102
|
subject: "Mathématiques",
|
|
88
|
-
|
|
89
|
-
|
|
103
|
+
getHint,
|
|
104
|
+
getCorrection,
|
|
90
105
|
getAnswer,
|
|
106
|
+
hasHintAndCorrection: true,
|
|
91
107
|
};
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,UAAU,YAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ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I,YAAY,CAEzD;AACD,qBAAa,YAAa,YAAW,YAAY;IAC/C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAItB,aAAa;;;;;;;;;IAQb,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA+BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,KAAK,IAAI,MAAM;IAcf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IA0J/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
|
|
@@ -107,6 +107,10 @@ class FractionNode {
|
|
|
107
107
|
oppositesCount++;
|
|
108
108
|
recursiveNums(node.child);
|
|
109
109
|
}
|
|
110
|
+
else if ((0, numberNode_1.isNumberNode)(node) && node.value < 0) {
|
|
111
|
+
oppositesCount++;
|
|
112
|
+
externalsNums.push(new numberNode_1.NumberNode(Math.abs(node.value)));
|
|
113
|
+
}
|
|
110
114
|
else {
|
|
111
115
|
externalsNums.push(node);
|
|
112
116
|
}
|
|
@@ -120,15 +124,20 @@ class FractionNode {
|
|
|
120
124
|
oppositesCount++;
|
|
121
125
|
recursiveNums(node.child);
|
|
122
126
|
}
|
|
127
|
+
else if ((0, numberNode_1.isNumberNode)(node) && node.value < 0) {
|
|
128
|
+
oppositesCount++;
|
|
129
|
+
externalsNums.push(new numberNode_1.NumberNode(Math.abs(node.value)));
|
|
130
|
+
}
|
|
123
131
|
else {
|
|
124
132
|
externalsDenums.push(node);
|
|
125
133
|
}
|
|
126
134
|
};
|
|
127
135
|
recursiveNums(copy.leftChild);
|
|
128
136
|
recursiveDenums(copy.rightChild);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
const shouldAddOppositeNode = oppositesCount % 2 === 1;
|
|
138
|
+
// if (oppositesCount % 2 === 1) {
|
|
139
|
+
// externalsNums.unshift(new NumberNode(-1));
|
|
140
|
+
// }
|
|
132
141
|
const simplifyExternalNodes = (num, denum) => {
|
|
133
142
|
if ((0, numberNode_1.isNumberNode)(num) && (0, numberNode_1.isNumberNode)(denum)) {
|
|
134
143
|
// console.log("num nb, denum nb", num.toTex(), denum.toTex());
|
|
@@ -193,17 +202,20 @@ class FractionNode {
|
|
|
193
202
|
? externalsNums[0]
|
|
194
203
|
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, externalsNums).simplify(opts);
|
|
195
204
|
if (externalsDenums.length === 0) {
|
|
196
|
-
return nums;
|
|
205
|
+
return shouldAddOppositeNode ? new oppositeNode_1.OppositeNode(nums).simplify() : nums;
|
|
197
206
|
}
|
|
198
207
|
const denums = externalsDenums.length === 1
|
|
199
208
|
? externalsDenums[0]
|
|
200
209
|
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, externalsDenums);
|
|
201
210
|
if (opts?.forceDistributeFractions) {
|
|
202
211
|
if ((0, addNode_1.isAddNode)(nums)) {
|
|
203
|
-
|
|
212
|
+
const res = new addNode_1.AddNode(new FractionNode(nums.leftChild, denums).simplify(opts), new FractionNode(nums.rightChild, denums).simplify(opts));
|
|
213
|
+
return shouldAddOppositeNode ? new oppositeNode_1.OppositeNode(res) : res;
|
|
204
214
|
}
|
|
205
215
|
}
|
|
206
|
-
return
|
|
216
|
+
return shouldAddOppositeNode
|
|
217
|
+
? new oppositeNode_1.OppositeNode(new FractionNode(nums, denums))
|
|
218
|
+
: new FractionNode(nums, denums);
|
|
207
219
|
}
|
|
208
220
|
equals(node) {
|
|
209
221
|
return (isFractionNode(node) &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA8CvD,eAAO,MAAM,QAAQ,UAAW,MAAM,aA4BrC,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,kBAavC,CAAC"}
|
|
@@ -4,13 +4,14 @@ exports.parseLatex = exports.tokenize = void 0;
|
|
|
4
4
|
const oppositeNode_1 = require("../nodes/functions/oppositeNode");
|
|
5
5
|
const sqrtNode_1 = require("../nodes/functions/sqrtNode");
|
|
6
6
|
const numberNode_1 = require("../nodes/numbers/numberNode");
|
|
7
|
+
const piNode_1 = require("../nodes/numbers/piNode");
|
|
7
8
|
const addNode_1 = require("../nodes/operators/addNode");
|
|
8
9
|
const fractionNode_1 = require("../nodes/operators/fractionNode");
|
|
9
10
|
const multiplyNode_1 = require("../nodes/operators/multiplyNode");
|
|
10
11
|
const powerNode_1 = require("../nodes/operators/powerNode");
|
|
11
12
|
const substractNode_1 = require("../nodes/operators/substractNode");
|
|
12
13
|
const variableNode_1 = require("../nodes/variables/variableNode");
|
|
13
|
-
//
|
|
14
|
+
//cmds that needs a child, like \exp{3}
|
|
14
15
|
const functions = [
|
|
15
16
|
"\\exp",
|
|
16
17
|
"\\sqrt",
|
|
@@ -21,6 +22,8 @@ const functions = [
|
|
|
21
22
|
"\\frac",
|
|
22
23
|
];
|
|
23
24
|
const operators = ["+", "-", "\\div", "\\times", "^"];
|
|
25
|
+
//cmds childless, like \\pi
|
|
26
|
+
const symbols = [{ tex: "\\pi", node: piNode_1.PiNode }];
|
|
24
27
|
const isDyck = (tokens) => {
|
|
25
28
|
const brackets = tokens.filter((el) => el === "(" || el === ")");
|
|
26
29
|
while (brackets.length) {
|
|
@@ -138,6 +141,10 @@ const buildTreeForSameDepthTokens = (tokens) => {
|
|
|
138
141
|
}
|
|
139
142
|
else if (token[0].match(/[a-z]/i))
|
|
140
143
|
tempTokens[i] = new variableNode_1.VariableNode(token);
|
|
144
|
+
else if (symbols.some((el) => el.tex === token)) {
|
|
145
|
+
const obj = symbols.find((el) => el.tex === token);
|
|
146
|
+
tempTokens[i] = obj.node;
|
|
147
|
+
}
|
|
141
148
|
//! les fonctions qui attendent un child ne sont pas encore parsées
|
|
142
149
|
else if (functions.includes(token)) {
|
|
143
150
|
tempTokens[i] = token;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.numberParser = void 0;
|
|
4
|
-
//
|
|
4
|
+
//returns false if ans is NaN (even in french form) and returns the frenchified form otherwise
|
|
5
5
|
const numberParser = (ans) => {
|
|
6
6
|
const nb = ans.unfrenchify();
|
|
7
7
|
if (isNaN(nb))
|