math-exercises 1.2.2 → 1.2.3
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/package.json +1 -1
- package/src/exercises/calcul/operationsPriorities.js +24 -6
- package/src/exercises/calcul/operationsPriorities.ts +24 -6
- package/src/exercises/calculLitteral/equation/equationType1Exercise.js +1 -1
- package/src/exercises/calculLitteral/equation/equationType1Exercise.ts +1 -1
- package/src/exercises/calculLitteral/equation/equationType2Exercise.js +1 -1
- package/src/exercises/calculLitteral/equation/equationType2Exercise.ts +1 -1
- package/src/index.ts +5 -0
- package/src/tree/latexParser/latexParse.js +1 -7
- package/src/tree/latexParser/latexParse.ts +1 -7
package/package.json
CHANGED
|
@@ -41,7 +41,10 @@ function getPriorityQuestions() {
|
|
|
41
41
|
new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new addNode_1.AddNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d))).shuffle()
|
|
42
42
|
: //a*b middle
|
|
43
43
|
new addNode_1.AddNode(new addNode_1.AddNode(new numberNode_1.NumberNode(c), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b))), new numberNode_1.NumberNode(d));
|
|
44
|
-
answer = a * b + c + d
|
|
44
|
+
answer = (a * b + c + d).toString();
|
|
45
|
+
console.log("type", type);
|
|
46
|
+
console.log("statement", statement);
|
|
47
|
+
console.log("answer", answer);
|
|
45
48
|
break;
|
|
46
49
|
case 2: // a/b ±c±d
|
|
47
50
|
_c = [1, 2, 3].map(function (el) { return (0, randint_1.randint)(-10, 11, [0]); }), b = _c[0], c = _c[1], d = _c[2];
|
|
@@ -51,33 +54,48 @@ function getPriorityQuestions() {
|
|
|
51
54
|
new addNode_1.AddNode(new divideNode_1.DivideNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new addNode_1.AddNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d))).shuffle()
|
|
52
55
|
: //a/b middle
|
|
53
56
|
new addNode_1.AddNode(new addNode_1.AddNode(new numberNode_1.NumberNode(c), new divideNode_1.DivideNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b))), new numberNode_1.NumberNode(d));
|
|
54
|
-
answer = a / b + c + d
|
|
57
|
+
answer = (a / b + c + d).toString();
|
|
58
|
+
console.log("type", type);
|
|
59
|
+
console.log("statement", statement);
|
|
60
|
+
console.log("answer", answer);
|
|
55
61
|
break;
|
|
56
62
|
case 3: // a*b ± c*d
|
|
57
63
|
_d = [1, 2, 3, 4].map(function (el) { return (0, randint_1.randint)(-10, 11); }), a = _d[0], b = _d[1], c = _d[2], d = _d[3];
|
|
58
64
|
statement = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d)));
|
|
59
|
-
answer = a * b + c * d
|
|
65
|
+
answer = (a * b + c * d).toString();
|
|
66
|
+
console.log("type", type);
|
|
67
|
+
console.log("statement", statement);
|
|
68
|
+
console.log("answer", answer);
|
|
60
69
|
break;
|
|
61
70
|
case 4: // a*b ± c/d
|
|
62
71
|
_e = [1, 2].map(function (el) { return (0, randint_1.randint)(-10, 11); }), a = _e[0], b = _e[1];
|
|
63
72
|
d = (0, randint_1.randint)(-10, 11, [0]);
|
|
64
73
|
c = d * (0, randint_1.randint)(0, 11);
|
|
65
74
|
statement = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new divideNode_1.DivideNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d))).shuffle();
|
|
66
|
-
answer = a * b + c / d
|
|
75
|
+
answer = (a * b + c / d).toString();
|
|
76
|
+
console.log("type", type);
|
|
77
|
+
console.log("statement", statement);
|
|
78
|
+
console.log("answer", answer);
|
|
67
79
|
break;
|
|
68
80
|
case 5: // a/b ± c/d
|
|
69
81
|
_f = [1, 2].map(function (el) { return (0, randint_1.randint)(-10, 11, [0]); }), b = _f[0], d = _f[1];
|
|
70
82
|
a = b * (0, randint_1.randint)(0, 11);
|
|
71
83
|
c = d * (0, randint_1.randint)(0, 11);
|
|
72
84
|
statement = new addNode_1.AddNode(new divideNode_1.DivideNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new divideNode_1.DivideNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d)));
|
|
73
|
-
answer = a / b + c / d
|
|
85
|
+
answer = (a / b + c / d).toString();
|
|
86
|
+
console.log("type", type);
|
|
87
|
+
console.log("statement", statement);
|
|
88
|
+
console.log("answer", answer);
|
|
74
89
|
break;
|
|
75
90
|
case 5: // a*b*c ± d
|
|
76
91
|
_g = [1, 2].map(function (el) { return (0, randint_1.randint)(-10, 11, [0]); }), b = _g[0], d = _g[1];
|
|
77
92
|
a = b * (0, randint_1.randint)(0, 11);
|
|
78
93
|
c = d * (0, randint_1.randint)(0, 11);
|
|
79
94
|
statement = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new numberNode_1.NumberNode(c)), new numberNode_1.NumberNode(d)).shuffle();
|
|
80
|
-
answer =
|
|
95
|
+
answer = a * b * c + d + "";
|
|
96
|
+
console.log("type", type);
|
|
97
|
+
console.log("statement", statement.toString());
|
|
98
|
+
console.log("answer", answer);
|
|
81
99
|
break;
|
|
82
100
|
}
|
|
83
101
|
var question = {
|
|
@@ -52,7 +52,10 @@ export function getPriorityQuestions(): Question {
|
|
|
52
52
|
new AddNode(new NumberNode(c), new MultiplyNode(new NumberNode(a), new NumberNode(b))),
|
|
53
53
|
new NumberNode(d)
|
|
54
54
|
);
|
|
55
|
-
answer = a * b + c + d
|
|
55
|
+
answer = (a * b + c + d).toString();
|
|
56
|
+
console.log("type", type);
|
|
57
|
+
console.log("statement", statement);
|
|
58
|
+
console.log("answer", answer);
|
|
56
59
|
break;
|
|
57
60
|
case 2: // a/b ±c±d
|
|
58
61
|
[b, c, d] = [1, 2, 3].map((el) => randint(-10, 11, [0]));
|
|
@@ -68,7 +71,10 @@ export function getPriorityQuestions(): Question {
|
|
|
68
71
|
new AddNode(new NumberNode(c), new DivideNode(new NumberNode(a), new NumberNode(b))),
|
|
69
72
|
new NumberNode(d)
|
|
70
73
|
);
|
|
71
|
-
answer = a / b + c + d
|
|
74
|
+
answer = (a / b + c + d).toString();
|
|
75
|
+
console.log("type", type);
|
|
76
|
+
console.log("statement", statement);
|
|
77
|
+
console.log("answer", answer);
|
|
72
78
|
break;
|
|
73
79
|
case 3: // a*b ± c*d
|
|
74
80
|
[a, b, c, d] = [1, 2, 3, 4].map((el) => randint(-10, 11));
|
|
@@ -76,7 +82,10 @@ export function getPriorityQuestions(): Question {
|
|
|
76
82
|
new MultiplyNode(new NumberNode(a), new NumberNode(b)),
|
|
77
83
|
new MultiplyNode(new NumberNode(c), new NumberNode(d))
|
|
78
84
|
);
|
|
79
|
-
answer = a * b + c * d
|
|
85
|
+
answer = (a * b + c * d).toString();
|
|
86
|
+
console.log("type", type);
|
|
87
|
+
console.log("statement", statement);
|
|
88
|
+
console.log("answer", answer);
|
|
80
89
|
break;
|
|
81
90
|
case 4: // a*b ± c/d
|
|
82
91
|
[a, b] = [1, 2].map((el) => randint(-10, 11));
|
|
@@ -86,7 +95,10 @@ export function getPriorityQuestions(): Question {
|
|
|
86
95
|
new MultiplyNode(new NumberNode(a), new NumberNode(b)),
|
|
87
96
|
new DivideNode(new NumberNode(c), new NumberNode(d))
|
|
88
97
|
).shuffle();
|
|
89
|
-
answer = a * b + c / d
|
|
98
|
+
answer = (a * b + c / d).toString();
|
|
99
|
+
console.log("type", type);
|
|
100
|
+
console.log("statement", statement);
|
|
101
|
+
console.log("answer", answer);
|
|
90
102
|
break;
|
|
91
103
|
case 5: // a/b ± c/d
|
|
92
104
|
[b, d] = [1, 2].map((el) => randint(-10, 11, [0]));
|
|
@@ -96,7 +108,10 @@ export function getPriorityQuestions(): Question {
|
|
|
96
108
|
new DivideNode(new NumberNode(a), new NumberNode(b)),
|
|
97
109
|
new DivideNode(new NumberNode(c), new NumberNode(d))
|
|
98
110
|
);
|
|
99
|
-
answer = a / b + c / d
|
|
111
|
+
answer = (a / b + c / d).toString();
|
|
112
|
+
console.log("type", type);
|
|
113
|
+
console.log("statement", statement);
|
|
114
|
+
console.log("answer", answer);
|
|
100
115
|
break;
|
|
101
116
|
case 5: // a*b*c ± d
|
|
102
117
|
[b, d] = [1, 2].map((el) => randint(-10, 11, [0]));
|
|
@@ -106,7 +121,10 @@ export function getPriorityQuestions(): Question {
|
|
|
106
121
|
new MultiplyNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new NumberNode(c)),
|
|
107
122
|
new NumberNode(d)
|
|
108
123
|
).shuffle();
|
|
109
|
-
answer =
|
|
124
|
+
answer = a * b * c + d + "";
|
|
125
|
+
console.log("type", type);
|
|
126
|
+
console.log("statement", statement.toString());
|
|
127
|
+
console.log("answer", answer);
|
|
110
128
|
break;
|
|
111
129
|
}
|
|
112
130
|
|
|
@@ -18,7 +18,7 @@ exports.equationType1Exercise = {
|
|
|
18
18
|
label: "Equations $x+a = b$",
|
|
19
19
|
levels: ["4", "3", "2"],
|
|
20
20
|
section: "Calcul littéral",
|
|
21
|
-
isSingleStep:
|
|
21
|
+
isSingleStep: true,
|
|
22
22
|
generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType1ExerciseQuestion, nb); }
|
|
23
23
|
};
|
|
24
24
|
function getEquationType1ExerciseQuestion() {
|
|
@@ -17,7 +17,7 @@ export const equationType1Exercise: Exercise = {
|
|
|
17
17
|
label: "Equations $x+a = b$",
|
|
18
18
|
levels: ["4", "3", "2"],
|
|
19
19
|
section: "Calcul littéral",
|
|
20
|
-
isSingleStep:
|
|
20
|
+
isSingleStep: true,
|
|
21
21
|
generator: (nb: number) => getDistinctQuestions(getEquationType1ExerciseQuestion, nb),
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -20,7 +20,7 @@ exports.equationType2Exercise = {
|
|
|
20
20
|
label: "Equations $ax=b$",
|
|
21
21
|
levels: ["4", "3", "2"],
|
|
22
22
|
section: "Calcul littéral",
|
|
23
|
-
isSingleStep:
|
|
23
|
+
isSingleStep: true,
|
|
24
24
|
generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType2ExerciseQuestion, nb); }
|
|
25
25
|
};
|
|
26
26
|
function getEquationType2ExerciseQuestion() {
|
|
@@ -20,7 +20,7 @@ export const equationType2Exercise: Exercise = {
|
|
|
20
20
|
label: "Equations $ax=b$",
|
|
21
21
|
levels: ["4", "3", "2"],
|
|
22
22
|
section: "Calcul littéral",
|
|
23
|
-
isSingleStep:
|
|
23
|
+
isSingleStep: true,
|
|
24
24
|
generator: (nb: number) => getDistinctQuestions(getEquationType2ExerciseQuestion, nb),
|
|
25
25
|
};
|
|
26
26
|
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { operationsPriorities } from "./exercises/calcul/operationsPriorities";
|
|
1
2
|
import { exercises } from "./exercises/exercises";
|
|
3
|
+
import { latexParse } from "./tree/latexParser/latexParse";
|
|
4
|
+
import { NumberNode } from "./tree/nodes/numbers/numberNode";
|
|
5
|
+
import { MultiplyNode } from "./tree/nodes/operators/multiplyNode";
|
|
2
6
|
|
|
3
7
|
// exercises.forEach((exo) => {
|
|
4
8
|
// console.log(exo.instruction, exo.generator(10));
|
|
5
9
|
// });
|
|
10
|
+
|
|
6
11
|
export { exercises };
|
|
@@ -62,13 +62,7 @@ function latexParse(node) {
|
|
|
62
62
|
}
|
|
63
63
|
if (needBrackets)
|
|
64
64
|
rightTex = "(".concat(rightTex, ")");
|
|
65
|
-
|
|
66
|
-
var showTimesSign = !isNaN(+rightTex[0]);
|
|
67
|
-
if (rightChild.type === node_1.NodeType.operator) {
|
|
68
|
-
var operatorRightChild = rightChild;
|
|
69
|
-
showTimesSign || (showTimesSign = [operatorNode_1.OperatorIds.fraction].includes(operatorRightChild.id));
|
|
70
|
-
}
|
|
71
|
-
return "".concat(leftTex).concat(showTimesSign ? "\\div " : "").concat(rightTex);
|
|
65
|
+
return "".concat(leftTex, " \\div ").concat(rightTex);
|
|
72
66
|
}
|
|
73
67
|
case operatorNode_1.OperatorIds.fraction: {
|
|
74
68
|
return "\\frac{".concat(leftTex, "}{").concat(rightTex, "}");
|
|
@@ -65,13 +65,7 @@ export function latexParse(node: Node): string {
|
|
|
65
65
|
}
|
|
66
66
|
if (needBrackets) rightTex = `(${rightTex})`;
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
let showTimesSign = !isNaN(+rightTex[0]);
|
|
70
|
-
if (rightChild.type === NodeType.operator) {
|
|
71
|
-
const operatorRightChild = rightChild as OperatorNode;
|
|
72
|
-
showTimesSign ||= [OperatorIds.fraction].includes(operatorRightChild.id);
|
|
73
|
-
}
|
|
74
|
-
return `${leftTex}${showTimesSign ? "\\div " : ""}${rightTex}`;
|
|
68
|
+
return `${leftTex} \\div ${rightTex}`;
|
|
75
69
|
}
|
|
76
70
|
|
|
77
71
|
case OperatorIds.fraction: {
|