math-exercises 3.0.50 → 3.0.51
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/fractions/fractionsOperations.js +2 -2
- package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +1 -1
- package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.js +1 -1
- package/lib/exercises/math/calcul/operations/expressionNature.js +6 -12
- package/lib/exercises/math/calcul/operations/operationsPriorities.d.ts.map +1 -1
- package/lib/exercises/math/calcul/operations/operationsPriorities.js +5 -6
- package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.js +1 -2
- package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.d.ts.map +1 -1
- package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.js +1 -2
- package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.d.ts.map +1 -1
- package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.js +1 -2
- package/lib/exercises/math/calculLitteral/isolate/isolateVariable.js +100 -36
- package/lib/exercises/math/functions/exponential/expSimplifiying.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponential/expSimplifiying.js +1 -2
- package/lib/exercises/math/probaStat/basicStats/calculateFrequency.d.ts +4 -1
- package/lib/exercises/math/probaStat/basicStats/calculateFrequency.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicStats/calculateFrequency.js +43 -18
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +4 -0
- package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.js +23 -16
- package/lib/tree/nodes/hasVariableNode.d.ts +1 -1
- package/lib/tree/nodes/hasVariableNode.d.ts.map +1 -1
- package/lib/tree/nodes/hasVariableNode.js +4 -4
- package/lib/tree/nodes/operators/addNode.d.ts +1 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +2 -1
- package/lib/tree/nodes/operators/divideNode.d.ts +1 -1
- package/lib/tree/nodes/operators/divideNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/divideNode.js +1 -2
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +2 -1
- package/lib/tree/nodes/operators/operatorNode.d.ts +1 -1
- package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.d.ts +2 -1
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +4 -3
- package/package.json +1 -1
|
@@ -47,12 +47,12 @@ const getFractionsOperationsQuestion = (ops) => {
|
|
|
47
47
|
RationalConstructor.randomIrreductible().toTree(),
|
|
48
48
|
RationalConstructor.randomIrreductible().toTree(),
|
|
49
49
|
];
|
|
50
|
-
|
|
50
|
+
let statement = firstOp(secondOp(rationals[0], rationals[1]), rationals[2]);
|
|
51
51
|
//éviter division par une soustraction qui donne 0
|
|
52
52
|
if (firstOpIndex !== 3 ||
|
|
53
53
|
secondOpIndex !== 1 ||
|
|
54
54
|
rationals[0].evaluate() - rationals[1].evaluate() !== 0) {
|
|
55
|
-
statement.shuffle();
|
|
55
|
+
statement = statement.shuffle();
|
|
56
56
|
}
|
|
57
57
|
const ids = statement.toIdentifiers();
|
|
58
58
|
const identifiers = {
|
|
@@ -27,7 +27,7 @@ const getMentalAddAndSub = () => {
|
|
|
27
27
|
let statementTree = new AddNode(allNumbersNodes[0], allNumbersNodes[1]);
|
|
28
28
|
for (let i = 2; i < nbrOperations; i++)
|
|
29
29
|
statementTree = new AddNode(statementTree, allNumbersNodes[i]);
|
|
30
|
-
statementTree.shuffle();
|
|
30
|
+
statementTree = statementTree.shuffle();
|
|
31
31
|
const statement = statementTree.toTex();
|
|
32
32
|
const answer = (round(sum, 2) + "").replace(".", ",");
|
|
33
33
|
const question = {
|
|
@@ -36,7 +36,7 @@ const getMentalMultiplications = () => {
|
|
|
36
36
|
statementTree = new MultiplyNode(allNumbersNodes[0], new MultiplyNode(allNumbersNodes[1], allNumbersNodes[2]));
|
|
37
37
|
answer = numbers[0] * numbers[1] * numbers[2];
|
|
38
38
|
}
|
|
39
|
-
statementTree.shuffle();
|
|
39
|
+
statementTree = statementTree.shuffle();
|
|
40
40
|
const statementTex = statementTree.toTex();
|
|
41
41
|
const answerTex = round(answer, 2).frenchify();
|
|
42
42
|
const question = {
|
|
@@ -24,8 +24,7 @@ const getExpressionNatureQuestion = () => {
|
|
|
24
24
|
switch (subType) {
|
|
25
25
|
case 1:
|
|
26
26
|
//ab+c
|
|
27
|
-
node = new AddNode(new MultiplyNode(a, b), c);
|
|
28
|
-
node.shuffle();
|
|
27
|
+
node = new AddNode(new MultiplyNode(a, b), c).shuffle();
|
|
29
28
|
break;
|
|
30
29
|
case 2:
|
|
31
30
|
//ab + cd
|
|
@@ -33,13 +32,11 @@ const getExpressionNatureQuestion = () => {
|
|
|
33
32
|
break;
|
|
34
33
|
case 3:
|
|
35
34
|
//a/b + c
|
|
36
|
-
node = new AddNode(new DivideNode(a, b), c);
|
|
37
|
-
node.shuffle();
|
|
35
|
+
node = new AddNode(new DivideNode(a, b), c).shuffle();
|
|
38
36
|
break;
|
|
39
37
|
case 4:
|
|
40
38
|
//ab + c/d
|
|
41
|
-
node = new AddNode(new MultiplyNode(a, b), new DivideNode(c, d));
|
|
42
|
-
node.shuffle();
|
|
39
|
+
node = new AddNode(new MultiplyNode(a, b), new DivideNode(c, d)).shuffle();
|
|
43
40
|
break;
|
|
44
41
|
case 5:
|
|
45
42
|
//a/b + c/d
|
|
@@ -84,13 +81,11 @@ const getExpressionNatureQuestion = () => {
|
|
|
84
81
|
switch (subType) {
|
|
85
82
|
case 1:
|
|
86
83
|
//(a+b)*c
|
|
87
|
-
node = new MultiplyNode(new AddNode(a, b), c);
|
|
88
|
-
node.shuffle();
|
|
84
|
+
node = new MultiplyNode(new AddNode(a, b), c).shuffle();
|
|
89
85
|
break;
|
|
90
86
|
case 2:
|
|
91
87
|
//(a-b)*c
|
|
92
|
-
node = new MultiplyNode(new SubstractNode(a, b), c);
|
|
93
|
-
node.shuffle();
|
|
88
|
+
node = new MultiplyNode(new SubstractNode(a, b), c).shuffle();
|
|
94
89
|
break;
|
|
95
90
|
case 3:
|
|
96
91
|
//(a+b)(c+d)
|
|
@@ -98,8 +93,7 @@ const getExpressionNatureQuestion = () => {
|
|
|
98
93
|
break;
|
|
99
94
|
case 4:
|
|
100
95
|
//(a+b)(c-d)
|
|
101
|
-
node = new MultiplyNode(new AddNode(a, b), new SubstractNode(c, d));
|
|
102
|
-
node.shuffle();
|
|
96
|
+
node = new MultiplyNode(new AddNode(a, b), new SubstractNode(c, d)).shuffle();
|
|
103
97
|
break;
|
|
104
98
|
case 5:
|
|
105
99
|
//(a-b)(c-d)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operationsPriorities.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPriorities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"operationsPriorities.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPriorities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvB,CAAC;AAkJF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAatD,CAAC"}
|
|
@@ -29,7 +29,7 @@ const getPriorityQuestions = () => {
|
|
|
29
29
|
new AddNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new AddNode(new NumberNode(c), new NumberNode(d)))
|
|
30
30
|
: //a*b middle
|
|
31
31
|
new AddNode(new AddNode(new NumberNode(c), new MultiplyNode(new NumberNode(a), new NumberNode(b))), new NumberNode(d));
|
|
32
|
-
statement.shuffle();
|
|
32
|
+
statement = statement.shuffle();
|
|
33
33
|
startStatement = statement.toTex();
|
|
34
34
|
answer = (a * b + c + d).toString();
|
|
35
35
|
break;
|
|
@@ -41,7 +41,7 @@ const getPriorityQuestions = () => {
|
|
|
41
41
|
new AddNode(new DivideNode(new NumberNode(a), new NumberNode(b)), new AddNode(new NumberNode(c), new NumberNode(d)))
|
|
42
42
|
: //a/b middle
|
|
43
43
|
new AddNode(new AddNode(new NumberNode(c), new DivideNode(new NumberNode(a), new NumberNode(b))), new NumberNode(d));
|
|
44
|
-
statement.shuffle();
|
|
44
|
+
statement = statement.shuffle();
|
|
45
45
|
startStatement = statement.toTex();
|
|
46
46
|
answer = (a / b + c + d).toString();
|
|
47
47
|
break;
|
|
@@ -56,7 +56,7 @@ const getPriorityQuestions = () => {
|
|
|
56
56
|
d = randint(-10, 11, [0]);
|
|
57
57
|
c = d * randint(0, 11);
|
|
58
58
|
statement = new AddNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new DivideNode(new NumberNode(c), new NumberNode(d)));
|
|
59
|
-
statement.shuffle();
|
|
59
|
+
statement = statement.shuffle();
|
|
60
60
|
startStatement = statement.toTex();
|
|
61
61
|
answer = (a * b + c / d).toString();
|
|
62
62
|
break;
|
|
@@ -71,7 +71,7 @@ const getPriorityQuestions = () => {
|
|
|
71
71
|
case 6: // a*b*c ± d
|
|
72
72
|
[a, b, c, d] = [1, 2, 3, 4].map((el) => randint(-10, 11, [0]));
|
|
73
73
|
statement = new AddNode(new MultiplyNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new NumberNode(c)), new NumberNode(d));
|
|
74
|
-
statement.shuffle();
|
|
74
|
+
statement = statement.shuffle();
|
|
75
75
|
startStatement = statement.toTex();
|
|
76
76
|
answer = (a * b * c + d).toString();
|
|
77
77
|
break;
|
|
@@ -79,8 +79,7 @@ const getPriorityQuestions = () => {
|
|
|
79
79
|
b = randint(2, 10);
|
|
80
80
|
a = b * randint(2, 10);
|
|
81
81
|
c = randint(2, 10);
|
|
82
|
-
statement = new MultiplyNode(new DivideNode(a.toTree(), b.toTree()), c.toTree());
|
|
83
|
-
statement.shuffle();
|
|
82
|
+
statement = new MultiplyNode(new DivideNode(a.toTree(), b.toTree()), c.toTree()).shuffle();
|
|
84
83
|
answer = ((a / b) * c).frenchify();
|
|
85
84
|
startStatement = statement.toTex();
|
|
86
85
|
break;
|
|
@@ -15,8 +15,7 @@ const getOperationsPrioritiesParenthesisQuestion = () => {
|
|
|
15
15
|
case 1: //a*(b+-c)
|
|
16
16
|
a = randint(-10, 11, [0, 1, -1]);
|
|
17
17
|
[b, c] = [1, 2].map((el) => randint(-10, 11, [0]));
|
|
18
|
-
statement = new MultiplyNode(a.toTree(), new AddNode(b.toTree(), c.toTree()), { forceTimesSign: true });
|
|
19
|
-
statement.shuffle();
|
|
18
|
+
statement = new MultiplyNode(a.toTree(), new AddNode(b.toTree(), c.toTree()), { forceTimesSign: true }).shuffle();
|
|
20
19
|
answer = (a * (b + c)).frenchify();
|
|
21
20
|
break;
|
|
22
21
|
case 2: //a/(b+-c) ou (b+-c)/a
|
package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operationsPrioritiesParenthesisNoRelatives.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;
|
|
1
|
+
{"version":3,"file":"operationsPrioritiesParenthesisNoRelatives.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesParenthesisNoRelatives.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAmIF,eAAO,MAAM,0CAA0C,EAAE,QAAQ,CAAC,WAAW,CAkB1E,CAAC"}
|
|
@@ -16,8 +16,7 @@ const getOperationsPrioritiesParenthesisNoRelativesQuestion = () => {
|
|
|
16
16
|
a = randint(2, 11);
|
|
17
17
|
b = randint(1, 11);
|
|
18
18
|
c = randint(-b, 11, [0]);
|
|
19
|
-
statement = new MultiplyNode(a.toTree(), new AddNode(b.toTree(), c.toTree()));
|
|
20
|
-
statement.shuffle();
|
|
19
|
+
statement = new MultiplyNode(a.toTree(), new AddNode(b.toTree(), c.toTree())).shuffle();
|
|
21
20
|
answer = (a * (b + c)).frenchify();
|
|
22
21
|
break;
|
|
23
22
|
case 2: //a/(b+-c) ou (b+-c)/a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operationsPrioritiesWithoutRelative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;
|
|
1
|
+
{"version":3,"file":"operationsPrioritiesWithoutRelative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgSF,eAAO,MAAM,mCAAmC,EAAE,QAAQ,CAAC,WAAW,CAcrE,CAAC"}
|
|
@@ -162,8 +162,7 @@ const getOperationsPrioritiesWithoutRelative = () => {
|
|
|
162
162
|
b = randint(2, 10);
|
|
163
163
|
a = b * randint(2, 10);
|
|
164
164
|
c = randint(2, 10);
|
|
165
|
-
statement = new MultiplyNode(new DivideNode(a.toTree(), b.toTree()), c.toTree());
|
|
166
|
-
statement.shuffle();
|
|
165
|
+
statement = new MultiplyNode(new DivideNode(a.toTree(), b.toTree()), c.toTree()).shuffle();
|
|
167
166
|
answer = ((a / b) * c).frenchify();
|
|
168
167
|
startStatement = statement.toTex();
|
|
169
168
|
break;
|
|
@@ -13,71 +13,135 @@
|
|
|
13
13
|
// GetInstruction,
|
|
14
14
|
// GetKeys,
|
|
15
15
|
// GetQuestionFromIdentifiers,
|
|
16
|
-
// } from
|
|
17
|
-
// import { getDistinctQuestions } from
|
|
16
|
+
// } from "../../../../exercises/exercise.js";
|
|
17
|
+
// import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
18
|
+
// import { GeneralAffine } from "../../../../math/polynomials/generalAffine.js";
|
|
19
|
+
// import { randint } from "../../../../math/utils/random/randint.js";
|
|
20
|
+
// import { AlgebraicNode } from "../../../../tree/nodes/algebraicNode.js";
|
|
21
|
+
// import {
|
|
22
|
+
// EqualNode,
|
|
23
|
+
// EqualNodeConstructor,
|
|
24
|
+
// EqualNodeIdentifiers,
|
|
25
|
+
// } from "../../../../tree/nodes/equations/equalNode.js";
|
|
26
|
+
// import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
27
|
+
// import { reifyAlgebraic } from "../../../../tree/nodes/nodeConstructor.js";
|
|
28
|
+
// import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
29
|
+
// import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
30
|
+
// import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
18
31
|
// import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
19
32
|
export {};
|
|
20
33
|
// type Identifiers = {
|
|
34
|
+
// eqNodeIds: EqualNodeIdentifiers;
|
|
35
|
+
// type: number;
|
|
21
36
|
// };
|
|
22
37
|
// //1. x+a = b (plus ou moins, droite ou gauche)
|
|
23
38
|
// //2. ax + b = c (plus ou moins, droite ou gauche)
|
|
24
|
-
// //3. a/x = b
|
|
39
|
+
// //3. a/x = b , a +b/x =c, x num ou denum
|
|
25
40
|
// //4. ax / b = c
|
|
41
|
+
// //5. x(a+b)=c
|
|
42
|
+
// //6. x*a*b = c ou xa = bc
|
|
43
|
+
// //7. x+a / b =c/ d (x+a) place aléatire , pm
|
|
44
|
+
// //8. (x+a)/b = c
|
|
26
45
|
// const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
|
|
27
46
|
// const propositions: Proposition[] = [];
|
|
28
47
|
// addValidProp(propositions, answer);
|
|
29
48
|
// while (propositions.length < n) {
|
|
30
|
-
// throw Error("QCM not implemented")
|
|
49
|
+
// throw Error("QCM not implemented");
|
|
31
50
|
// }
|
|
32
51
|
// return shuffleProps(propositions, n);
|
|
33
52
|
// };
|
|
34
|
-
// const getAnswer
|
|
35
|
-
// }
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
// }
|
|
40
|
-
// const
|
|
41
|
-
// }
|
|
42
|
-
//
|
|
43
|
-
// return
|
|
44
|
-
//
|
|
45
|
-
//
|
|
53
|
+
// const getAnswer: GetAnswer<Identifiers> = (identifiers) => {
|
|
54
|
+
// const { type, eqNodeIds } = identifiers;
|
|
55
|
+
// const eq = EqualNodeConstructor.fromIdentifiers(eqNodeIds);
|
|
56
|
+
// // return "";
|
|
57
|
+
// return eq.isolate("x").toTex();
|
|
58
|
+
// };
|
|
59
|
+
// const getInstruction: GetInstruction<Identifiers> = (identifiers) => {
|
|
60
|
+
// const { type, eqNodeIds } = identifiers;
|
|
61
|
+
// const eq = reifyAlgebraic(eqNodeIds);
|
|
62
|
+
// return `Isoler $x$ dans l'égalité suivante :
|
|
63
|
+
// $$
|
|
64
|
+
// ${eq.toTex()}
|
|
65
|
+
// $$`;
|
|
66
|
+
// };
|
|
67
|
+
// // const getHint : GetHint<Identifiers> = (identifiers)=>{
|
|
68
|
+
// // }
|
|
69
|
+
// // const getCorrection : GetCorrection<Identifiers> = (identifiers)=>{
|
|
70
|
+
// // }
|
|
71
|
+
// const getKeys: GetKeys<Identifiers> = (identifiers) => {
|
|
72
|
+
// return ["x", "a", "b", "c", "d"];
|
|
73
|
+
// };
|
|
74
|
+
// const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {
|
|
46
75
|
// try {
|
|
47
|
-
// throw Error("VEA not implemented")
|
|
48
|
-
// } catch(err){
|
|
49
|
-
// return handleVEAError(err)
|
|
76
|
+
// throw Error("VEA not implemented");
|
|
77
|
+
// } catch (err) {
|
|
78
|
+
// return handleVEAError(err);
|
|
50
79
|
// }
|
|
51
|
-
// }
|
|
52
|
-
// const getIsolateVariableQuestion: QuestionGenerator<Identifiers>
|
|
53
|
-
//
|
|
80
|
+
// };
|
|
81
|
+
// const getIsolateVariableQuestion: QuestionGenerator<Identifiers> = (ops) => {
|
|
82
|
+
// //1. x+a = b (plus ou moins, droite ou gauche)
|
|
83
|
+
// //2. ax + b = c (plus ou moins, droite ou gauche)
|
|
84
|
+
// //3. a/x = b , a +b/x =c, x num ou denum
|
|
85
|
+
// //4. ax / b = c
|
|
86
|
+
// //5. x(a+b)=c
|
|
87
|
+
// //6. x*a*b = c ou xa = bc
|
|
88
|
+
// //7. x+a / b =c/ d (x+a) place aléatire , pm
|
|
89
|
+
// //8. (x+a)/b = c
|
|
90
|
+
// const type = randint(0, 8);
|
|
91
|
+
// const x = "x".toTree();
|
|
92
|
+
// const a = "a".toTree();
|
|
93
|
+
// const b = "b".toTree();
|
|
94
|
+
// const c = "c".toTree();
|
|
95
|
+
// const d = "d".toTree();
|
|
96
|
+
// const signify = (x: AlgebraicNode) => (coinFlip() ? x : opposite(x));
|
|
97
|
+
// let eqNode: EqualNode;
|
|
98
|
+
// switch (type) {
|
|
99
|
+
// case 1:
|
|
100
|
+
// let n = add(signify(x), signify(a)).shuffle();
|
|
101
|
+
// eqNode = new EqualNode(n, b).shuffle();
|
|
102
|
+
// break;
|
|
103
|
+
// case 2:
|
|
104
|
+
// default:
|
|
105
|
+
// eqNode = new EqualNode(
|
|
106
|
+
// add(multiply(signify(a), x), signify(b)).shuffle(),
|
|
107
|
+
// signify(c),
|
|
108
|
+
// ).shuffle();
|
|
109
|
+
// break;
|
|
110
|
+
// }
|
|
111
|
+
// const identifiers: Identifiers = {
|
|
112
|
+
// type,
|
|
113
|
+
// eqNodeIds: eqNode.toIdentifiers(),
|
|
114
|
+
// };
|
|
54
115
|
// return getQuestionFromIdentifiers(identifiers);
|
|
55
|
-
// }
|
|
56
|
-
// const getQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers> = (
|
|
116
|
+
// };
|
|
117
|
+
// const getQuestionFromIdentifiers: GetQuestionFromIdentifiers<Identifiers> = (
|
|
118
|
+
// identifiers,
|
|
119
|
+
// ) => {
|
|
57
120
|
// return {
|
|
58
121
|
// answer: getAnswer(identifiers),
|
|
59
122
|
// instruction: getInstruction(identifiers),
|
|
60
123
|
// keys: getKeys(identifiers),
|
|
61
|
-
// answerFormat:
|
|
124
|
+
// answerFormat: "tex",
|
|
62
125
|
// identifiers,
|
|
63
|
-
// hint: getHint(identifiers),
|
|
64
|
-
// correction: getCorrection(identifiers)
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
126
|
+
// // hint: getHint(identifiers),
|
|
127
|
+
// // correction: getCorrection(identifiers)
|
|
128
|
+
// };
|
|
129
|
+
// };
|
|
67
130
|
// export const isolateVariable: Exercise<Identifiers> = {
|
|
68
|
-
// id:
|
|
69
|
-
// connector: "",
|
|
70
|
-
// label:
|
|
131
|
+
// id: "isolateVariable",
|
|
132
|
+
// connector: "\\iff",
|
|
133
|
+
// label: "Isoler une variable",
|
|
71
134
|
// isSingleStep: true,
|
|
72
|
-
// generator: (nb, opts) =>
|
|
135
|
+
// generator: (nb, opts) =>
|
|
136
|
+
// getDistinctQuestions(() => getIsolateVariableQuestion(opts), nb),
|
|
73
137
|
// qcmTimer: 60,
|
|
74
138
|
// freeTimer: 60,
|
|
75
139
|
// getPropositions,
|
|
76
140
|
// isAnswerValid,
|
|
77
141
|
// subject: "Mathématiques",
|
|
78
142
|
// getInstruction,
|
|
79
|
-
// getHint,
|
|
80
|
-
// getCorrection,
|
|
143
|
+
// // getHint,
|
|
144
|
+
// // getCorrection,
|
|
81
145
|
// getAnswer,
|
|
82
|
-
// getQuestionFromIdentifiers
|
|
146
|
+
// getQuestionFromIdentifiers,
|
|
83
147
|
// };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"expSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/exponential/expSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAkIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
|
|
@@ -26,8 +26,7 @@ const getExpSimplifiying = () => {
|
|
|
26
26
|
//e^u * e^v
|
|
27
27
|
u = new Polynomial([randint(-9, 10), randint(-9, 10, [0])]);
|
|
28
28
|
v = new Polynomial([randint(-9, 10), randint(-9, 10, [0])]);
|
|
29
|
-
expression = new MultiplyNode(new ExpNode(u.toTree()), new ExpNode(v.toTree()));
|
|
30
|
-
expression.shuffle();
|
|
29
|
+
expression = new MultiplyNode(new ExpNode(u.toTree()), new ExpNode(v.toTree())).shuffle();
|
|
31
30
|
answer = new ExpNode(u.add(v).toTree()).toTex();
|
|
32
31
|
break;
|
|
33
32
|
case 3:
|
|
@@ -5,6 +5,9 @@ type Identifiers = {
|
|
|
5
5
|
k: number;
|
|
6
6
|
nbEssais: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type Options = {
|
|
9
|
+
useFractions?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const calculateFrequency: Exercise<Identifiers, Options>;
|
|
9
12
|
export {};
|
|
10
13
|
//# sourceMappingURL=calculateFrequency.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicStats/calculateFrequency.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"calculateFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicStats/calculateFrequency.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AA2IF,KAAK,OAAO,GAAG;IACb,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAUF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkB7D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionType, GeneratorOptionTarget, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
|
|
4
4
|
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
@@ -8,22 +8,33 @@ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
|
8
8
|
import { random } from "../../../../utils/alea/random.js";
|
|
9
9
|
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
10
10
|
import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
|
|
11
|
-
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
11
|
+
const getPropositions = (n, { answer, ...identifiers }, opts) => {
|
|
12
12
|
const propositions = [];
|
|
13
13
|
const { k, nbEssais } = identifiers;
|
|
14
|
+
const useFrac = opts?.useFractions;
|
|
14
15
|
addValidProp(propositions, answer);
|
|
15
16
|
tryToAddWrongProp(propositions, k + "");
|
|
16
|
-
|
|
17
|
+
if (useFrac)
|
|
18
|
+
tryToAddWrongProp(propositions, frac(k, 100).toTex());
|
|
19
|
+
else
|
|
20
|
+
tryToAddWrongProp(propositions, round(k / 100, 2).frenchify());
|
|
17
21
|
while (propositions.length < n) {
|
|
18
|
-
|
|
22
|
+
if (useFrac)
|
|
23
|
+
tryToAddWrongProp(propositions, frac(randint(5, 100), randint(5, 100)).toTex());
|
|
24
|
+
else
|
|
25
|
+
tryToAddWrongProp(propositions, round(RationalConstructor.randomIrreductible().toTree().evaluate(), 2).frenchify());
|
|
19
26
|
}
|
|
20
27
|
return shuffleProps(propositions, n);
|
|
21
28
|
};
|
|
22
|
-
const getAnswer = (identifiers) => {
|
|
29
|
+
const getAnswer = (identifiers, opts) => {
|
|
30
|
+
const useFrac = opts?.useFractions;
|
|
23
31
|
const { k, nbEssais } = identifiers;
|
|
24
|
-
|
|
32
|
+
if (useFrac)
|
|
33
|
+
return frac(k, nbEssais).toTex();
|
|
34
|
+
else
|
|
35
|
+
return round(k / nbEssais, 2).frenchify();
|
|
25
36
|
};
|
|
26
|
-
const getInstruction = (identifiers) => {
|
|
37
|
+
const getInstruction = (identifiers, opts) => {
|
|
27
38
|
const { type, k, nbEssais, caracType } = identifiers;
|
|
28
39
|
let instruction = ";";
|
|
29
40
|
switch (type) {
|
|
@@ -42,22 +53,23 @@ const getInstruction = (identifiers) => {
|
|
|
42
53
|
Quelle est la fréquence d'apparition de ${caracType} ? Arrondir au centième près.`;
|
|
43
54
|
return instruction;
|
|
44
55
|
};
|
|
45
|
-
const getHint = (identifiers) => {
|
|
56
|
+
const getHint = (identifiers, opts) => {
|
|
46
57
|
const { type, k, nbEssais, caracType } = identifiers;
|
|
47
58
|
return `La fréquence est le nombre de fois qu'on a obtenu ${caracType} divisé par le nombre total d'essais.`;
|
|
48
59
|
};
|
|
49
|
-
const getCorrection = (identifiers) => {
|
|
60
|
+
const getCorrection = (identifiers, opts) => {
|
|
50
61
|
const { type, k, nbEssais, caracType } = identifiers;
|
|
62
|
+
const useFrac = opts?.useFractions;
|
|
51
63
|
return `On a obtenu $${k}$ fois ${caracType} sur les $${nbEssais}$ lancers. La fréquence d'apparition de ${caracType} est donc :
|
|
52
64
|
|
|
53
65
|
$$
|
|
54
|
-
${frac(k, nbEssais).toTex()} ${approxOrEqual(k / nbEssais, 2).join("")}
|
|
66
|
+
${frac(k, nbEssais).toTex()} ${useFrac ? "" : approxOrEqual(k / nbEssais, 2).join("")}
|
|
55
67
|
$$`;
|
|
56
68
|
};
|
|
57
|
-
const getKeys = (identifiers) => {
|
|
69
|
+
const getKeys = (identifiers, opts) => {
|
|
58
70
|
return [];
|
|
59
71
|
};
|
|
60
|
-
const isAnswerValid = (ans, { answer, k, nbEssais }) => {
|
|
72
|
+
const isAnswerValid = (ans, { answer, k, nbEssais }, opts) => {
|
|
61
73
|
try {
|
|
62
74
|
return rationalVEA(ans, frac(k, nbEssais).simplify().toTex(), {
|
|
63
75
|
decimalPrecision: 2,
|
|
@@ -67,7 +79,7 @@ const isAnswerValid = (ans, { answer, k, nbEssais }) => {
|
|
|
67
79
|
return handleVEAError(err);
|
|
68
80
|
}
|
|
69
81
|
};
|
|
70
|
-
const getCalculateFrequencyQuestion = (
|
|
82
|
+
const getCalculateFrequencyQuestion = (opts) => {
|
|
71
83
|
const type = randint(0, 4);
|
|
72
84
|
const nbEssais = 5 * randint(10, 100);
|
|
73
85
|
const k = randint(1, nbEssais);
|
|
@@ -79,17 +91,29 @@ const getCalculateFrequencyQuestion = (ops) => {
|
|
|
79
91
|
? `la face $${randint(1, 13)}$`
|
|
80
92
|
: `la somme $${randint(1, 13)}$`;
|
|
81
93
|
const identifiers = { type, k, nbEssais, caracType };
|
|
94
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
95
|
+
};
|
|
96
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
82
97
|
const question = {
|
|
83
|
-
answer: getAnswer(identifiers),
|
|
84
|
-
instruction: getInstruction(identifiers),
|
|
85
|
-
keys: getKeys(identifiers),
|
|
98
|
+
answer: getAnswer(identifiers, opts),
|
|
99
|
+
instruction: getInstruction(identifiers, opts),
|
|
100
|
+
keys: getKeys(identifiers, opts),
|
|
86
101
|
answerFormat: "tex",
|
|
87
102
|
identifiers,
|
|
88
|
-
hint: getHint(identifiers),
|
|
89
|
-
correction: getCorrection(identifiers),
|
|
103
|
+
hint: getHint(identifiers, opts),
|
|
104
|
+
correction: getCorrection(identifiers, opts),
|
|
90
105
|
};
|
|
91
106
|
return question;
|
|
92
107
|
};
|
|
108
|
+
const options = [
|
|
109
|
+
{
|
|
110
|
+
id: "useFractions",
|
|
111
|
+
label: "Réponse sous forme de fraction",
|
|
112
|
+
target: GeneratorOptionTarget.answer,
|
|
113
|
+
type: GeneratorOptionType.checkbox,
|
|
114
|
+
defaultValue: false,
|
|
115
|
+
},
|
|
116
|
+
];
|
|
93
117
|
export const calculateFrequency = {
|
|
94
118
|
id: "calculateFrequency",
|
|
95
119
|
connector: "=",
|
|
@@ -106,4 +130,5 @@ export const calculateFrequency = {
|
|
|
106
130
|
getCorrection,
|
|
107
131
|
getAnswer,
|
|
108
132
|
hasHintAndCorrection: true,
|
|
133
|
+
options,
|
|
109
134
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1659,7 +1659,9 @@ declare const mathExercises: (Exercise<{
|
|
|
1659
1659
|
caracType: string;
|
|
1660
1660
|
k: number;
|
|
1661
1661
|
nbEssais: number;
|
|
1662
|
-
}, {
|
|
1662
|
+
}, {
|
|
1663
|
+
useFractions?: boolean;
|
|
1664
|
+
}> | Exercise<{
|
|
1663
1665
|
firstValue: number;
|
|
1664
1666
|
askedRank: number;
|
|
1665
1667
|
reason: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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c,EAAE,CAAC"}
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,UAAU,YAStB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { EqualNode } from "./tree/nodes/equations/equalNode.js";
|
|
2
|
+
import { add } from "./tree/nodes/operators/addNode.js";
|
|
3
|
+
import { multiply } from "./tree/nodes/operators/multiplyNode.js";
|
|
2
4
|
import { parseAlgebraic } from "./tree/parsers/latexParser.js";
|
|
3
5
|
export const playground = () => {
|
|
4
6
|
// console.log(x.equals(x.simplify()));
|
|
5
7
|
const eq = new EqualNode(parseAlgebraic("\\frac{3x+2}{4}"), parseAlgebraic("3x"));
|
|
8
|
+
console.log(eq.isolate("x").toTex());
|
|
6
9
|
// console.log(parseAlgebraic("\\left|x^2\\right|").toTex());
|
|
10
|
+
console.log(add(multiply(3, "x"), multiply(4, "x")).simplify().toTex());
|
|
7
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"equalNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/equations/equalNode.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,eAAe,EAEhB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAEL,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAQ/B,eAAO,MAAM,KAAK,MACb,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,cAOnC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GA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ACb,aAAa,KACb,aAAa,KACb,aAAa,sBA2DjB,CAAC"}
|
|
@@ -95,17 +95,23 @@ export class EqualNode {
|
|
|
95
95
|
const simpOpts = {
|
|
96
96
|
towardsDistribute: true,
|
|
97
97
|
forbidFactorize: true,
|
|
98
|
+
forceDistributeFractions: false,
|
|
98
99
|
};
|
|
99
100
|
let left = substract(this.leftChild, this.rightChild).simplify(simpOpts);
|
|
100
101
|
// let simp = new EqualNode(left, right);
|
|
102
|
+
let i = 0;
|
|
101
103
|
const recur = () => {
|
|
104
|
+
i++;
|
|
105
|
+
if (i > 100)
|
|
106
|
+
throw new Error("too many iterations in isolate");
|
|
107
|
+
console.log(left.toTex(), ".......", right.toTex());
|
|
102
108
|
if (isVariableNode(left) && left.name === varName) {
|
|
103
109
|
return;
|
|
104
110
|
}
|
|
105
111
|
else if (isAddNode(left)) {
|
|
106
112
|
// const xIsLeft = ??
|
|
107
113
|
// if xIsLeft, right = right-node.right, left = left-node.right
|
|
108
|
-
const xIsLeft = hasVariableNode(left.leftChild);
|
|
114
|
+
const xIsLeft = hasVariableNode(left.leftChild, varName);
|
|
109
115
|
if (xIsLeft) {
|
|
110
116
|
right = substract(right, left.rightChild).simplify(simpOpts);
|
|
111
117
|
left = substract(left, left.rightChild).simplify(simpOpts);
|
|
@@ -116,7 +122,7 @@ export class EqualNode {
|
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
else if (isSubstractNode(left)) {
|
|
119
|
-
const xIsLeft = hasVariableNode(left.leftChild);
|
|
125
|
+
const xIsLeft = hasVariableNode(left.leftChild, varName);
|
|
120
126
|
if (xIsLeft) {
|
|
121
127
|
right = add(right, left.rightChild).simplify(simpOpts);
|
|
122
128
|
left = add(left, left.rightChild).simplify(simpOpts);
|
|
@@ -127,39 +133,40 @@ export class EqualNode {
|
|
|
127
133
|
}
|
|
128
134
|
}
|
|
129
135
|
else if (isMultiplyNode(left)) {
|
|
130
|
-
const xIsLeft = hasVariableNode(left.leftChild);
|
|
136
|
+
const xIsLeft = hasVariableNode(left.leftChild, varName);
|
|
131
137
|
if (xIsLeft) {
|
|
132
|
-
right = frac(right, left.rightChild).simplify(
|
|
133
|
-
left = frac(left, left.rightChild).simplify(
|
|
138
|
+
right = frac(right, left.rightChild).simplify();
|
|
139
|
+
left = frac(left, left.rightChild).simplify();
|
|
134
140
|
}
|
|
135
141
|
else {
|
|
136
|
-
right = frac(right, left.leftChild).simplify(
|
|
137
|
-
left = frac(left, left.leftChild).simplify(
|
|
142
|
+
right = frac(right, left.leftChild).simplify();
|
|
143
|
+
left = frac(left, left.leftChild).simplify();
|
|
138
144
|
}
|
|
139
145
|
}
|
|
140
146
|
else if (isFractionNode(left)) {
|
|
141
|
-
console.log(left.leftChild);
|
|
142
|
-
const xIsLeft = hasVariableNode(left.leftChild);
|
|
147
|
+
// console.log(left.leftChild);
|
|
148
|
+
const xIsLeft = hasVariableNode(left.leftChild, varName);
|
|
143
149
|
if (xIsLeft) {
|
|
144
|
-
right = multiply(right, left.rightChild).simplify(
|
|
145
|
-
left = multiply(left, left.rightChild).simplify(
|
|
150
|
+
right = multiply(right, left.rightChild).simplify();
|
|
151
|
+
left = multiply(left, left.rightChild).simplify();
|
|
146
152
|
}
|
|
147
153
|
else {
|
|
148
154
|
if (right.equals((0).toTree())) {
|
|
149
155
|
//A/f(x) = 0 --> f(x) = 0
|
|
150
|
-
left = left.rightChild.simplify(
|
|
156
|
+
left = left.rightChild.simplify();
|
|
151
157
|
}
|
|
152
158
|
else {
|
|
153
|
-
right = frac(1, right).simplify(
|
|
154
|
-
left = frac(1, left).simplify(
|
|
159
|
+
right = frac(1, right).simplify();
|
|
160
|
+
left = frac(1, left).simplify();
|
|
155
161
|
}
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
else if (isOppositeNode(left)) {
|
|
159
|
-
left = opposite(left).simplify(
|
|
160
|
-
right = opposite(right).simplify(
|
|
165
|
+
left = opposite(left).simplify();
|
|
166
|
+
right = opposite(right).simplify();
|
|
161
167
|
}
|
|
162
168
|
else {
|
|
169
|
+
console.log(left);
|
|
163
170
|
throw new Error("Isolation only implemented for basic operations yet");
|
|
164
171
|
}
|
|
165
172
|
recur();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasVariableNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/hasVariableNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,eAAO,MAAM,eAAe,MAAO,IAAI,KAAG,
|
|
1
|
+
{"version":3,"file":"hasVariableNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/hasVariableNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,eAAO,MAAM,eAAe,MAAO,IAAI,SAAS,MAAM,KAAG,OAQxD,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isFunctionNode } from "./functions/functionNode.js";
|
|
2
2
|
import { isOperatorNode } from "./operators/operatorNode.js";
|
|
3
3
|
import { isVariableNode } from "./variables/variableNode.js";
|
|
4
|
-
export const hasVariableNode = (n) => {
|
|
5
|
-
if (isVariableNode(n))
|
|
4
|
+
export const hasVariableNode = (n, name) => {
|
|
5
|
+
if (isVariableNode(n) && (!name || n.name === name))
|
|
6
6
|
return true;
|
|
7
7
|
if (isOperatorNode(n))
|
|
8
|
-
return hasVariableNode(n.leftChild) || hasVariableNode(n.rightChild);
|
|
8
|
+
return (hasVariableNode(n.leftChild, name) || hasVariableNode(n.rightChild, name));
|
|
9
9
|
if (isFunctionNode(n))
|
|
10
|
-
return hasVariableNode(n.child);
|
|
10
|
+
return hasVariableNode(n.child, name);
|
|
11
11
|
return false;
|
|
12
12
|
};
|
|
@@ -11,7 +11,7 @@ export declare class AddNode implements CommutativeOperatorNode {
|
|
|
11
11
|
opts?: NodeOptions;
|
|
12
12
|
isNumeric: boolean;
|
|
13
13
|
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
|
|
14
|
-
shuffle: () =>
|
|
14
|
+
shuffle: () => AddNode;
|
|
15
15
|
deepShuffle: (opts?: DeepShuffleOpts) => AddNode;
|
|
16
16
|
toMathString(): string;
|
|
17
17
|
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,WAAW,EAIZ,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAcrE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AAED,eAAO,MAAM,GAAG,MACX,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,YAOnC,CAAC;AAEF,qBAAa,OAAQ,YAAW,uBAAuB;IACrD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,OAAO,
|
|
1
|
+
{"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,M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AC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAMvD,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;CAK3C"}
|
|
@@ -38,7 +38,8 @@ export class AddNode {
|
|
|
38
38
|
}
|
|
39
39
|
shuffle = () => {
|
|
40
40
|
if (coinFlip())
|
|
41
|
-
|
|
41
|
+
return this;
|
|
42
|
+
return new AddNode(this.rightChild, this.leftChild, this.opts);
|
|
42
43
|
};
|
|
43
44
|
deepShuffle = (opts) => {
|
|
44
45
|
const left = isCommutativeOperatorNode(this.leftChild)
|
|
@@ -33,6 +33,6 @@ export declare class DivideNode implements OperatorNode {
|
|
|
33
33
|
equals(node: AlgebraicNode): boolean;
|
|
34
34
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): DivideNode;
|
|
35
35
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
36
|
-
shuffle: () =>
|
|
36
|
+
shuffle: () => this;
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=divideNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"divideNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/divideNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,UAAU,CAErD;AAED,eAAO,MAAM,MAAM,MACd,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,eAOnB,CAAC;AA4BF,qBAAa,UAAW,YAAW,YAAY;IAC7C,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,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AAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;gBAES,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa;IAQ/D,YAAY,IAAI,MAAM;IAGtB,kBAAkB;IAIlB,aAAa;;;;;;;;;IAQb,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAYpC,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,IAAI,MAAM;IAGf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ;IAGR,MAAM,CAAC,IAAI,EAAE,aAAa;IAO1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAGvD,OAAO,aAEL;CACH"}
|
|
@@ -12,7 +12,7 @@ export declare class MultiplyNode implements CommutativeOperatorNode {
|
|
|
12
12
|
type: NodeType;
|
|
13
13
|
isNumeric: boolean;
|
|
14
14
|
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
|
|
15
|
-
shuffle: () =>
|
|
15
|
+
shuffle: () => MultiplyNode;
|
|
16
16
|
deepShuffle: (opts?: DeepShuffleOpts) => MultiplyNode;
|
|
17
17
|
toReversed: () => MultiplyNode;
|
|
18
18
|
toMathString(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EACL,aAAa,EACb,eAAe,EAEhB,MAA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AAC,EAAE,WAAW,CAAC;IACnB,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,OAAO,qBAGL;IAEF,WAAW,UAAW,eAAe,kBAUnC;IAEF,UAAU,qBAER;IACF,YAAY,IAAI,MAAM;IAItB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAgFrC,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAyFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,aAAa;;;;;;;;;IAYb,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAItC,IAAI;IAGJ,cAAc;IACd,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAsL/C,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe;IAM1C,MAAM,CAAC,IAAI,EAAE,aAAa;IAU1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAQxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAMxD"}
|
|
@@ -54,7 +54,8 @@ export class MultiplyNode {
|
|
|
54
54
|
}
|
|
55
55
|
shuffle = () => {
|
|
56
56
|
if (coinFlip())
|
|
57
|
-
|
|
57
|
+
return this;
|
|
58
|
+
return new MultiplyNode(this.rightChild, this.leftChild, this.opts);
|
|
58
59
|
};
|
|
59
60
|
deepShuffle = (opts) => {
|
|
60
61
|
const left = isCommutativeOperatorNode(this.leftChild)
|
|
@@ -23,7 +23,7 @@ export type DeepShuffleOpts = {
|
|
|
23
23
|
nodeIdsToShuffle: OperatorIds[];
|
|
24
24
|
};
|
|
25
25
|
export interface CommutativeOperatorNode extends OperatorNode {
|
|
26
|
-
shuffle: () =>
|
|
26
|
+
shuffle: () => CommutativeOperatorNode;
|
|
27
27
|
deepShuffle: (opts?: DeepShuffleOpts) => CommutativeOperatorNode;
|
|
28
28
|
toAllTexs: () => string[];
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operatorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/operatorNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAqB,MAAM,YAAY,CAAC;AAErD,oBAAY,WAAW;IACrB,GAAG,IAAA;IACH,SAAS,IAAA;IACT,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,MAAM,IAAA;IACN,KAAK,IAAA;IACL,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,mBAAmB,IAAA;IACnB,MAAM,IAAA;CACP;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;CAC3B;AACD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,wBAAgB,yBAAyB,CACvC,CAAC,EAAE,IAAI,GACN,CAAC,IAAI,uBAAuB,CAI9B;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,gBAAgB,EAAE,WAAW,EAAE,CAAC;CACjC,CAAC;AACF,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"operatorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/operatorNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAqB,MAAM,YAAY,CAAC;AAErD,oBAAY,WAAW;IACrB,GAAG,IAAA;IACH,SAAS,IAAA;IACT,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,MAAM,IAAA;IACN,KAAK,IAAA;IACL,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,mBAAmB,IAAA;IACnB,MAAM,IAAA;CACP;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;CAC3B;AACD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,wBAAgB,yBAAyB,CACvC,CAAC,EAAE,IAAI,GACN,CAAC,IAAI,uBAAuB,CAI9B;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,gBAAgB,EAAE,WAAW,EAAE,CAAC;CACjC,CAAC;AACF,MAAM,WAAW,uBAAwB,SAAQ,YAAY;IAC3D,OAAO,EAAE,MAAM,uBAAuB,CAAC;IACvC,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,uBAAuB,CAAC;IACjE,SAAS,EAAE,MAAM,MAAM,EAAE,CAAC;CAC3B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType, ToTexOptions } from "../node.js";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode.js";
|
|
3
|
+
import { AddNode } from "./addNode.js";
|
|
3
4
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
4
5
|
export declare function isSubstractNode(a: Node): a is SubstractNode;
|
|
5
6
|
export declare const substract: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string) => SubstractNode;
|
|
@@ -30,6 +31,6 @@ export declare class SubstractNode implements OperatorNode {
|
|
|
30
31
|
equals(node: AlgebraicNode): boolean;
|
|
31
32
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): SubstractNode;
|
|
32
33
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
33
|
-
shuffle: () =>
|
|
34
|
+
shuffle: () => this | AddNode;
|
|
34
35
|
}
|
|
35
36
|
//# sourceMappingURL=substractNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"substractNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/substractNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAO,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGrE,wBAAgB,eAAe,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,aAAa,CAE3D;AAED,eAAO,MAAM,SAAS,MACjB,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,kBAOnC,CAAC;AAEF,qBAAa,aAAc,YAAW,YAAY;IAChD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IASpB,YAAY,IAAI,MAAM;IAGtB,aAAa;;;;;;;;;IAOb,iBAAiB,IAAI,aAAa,EAAE;IAapC,cAAc,IAAI,MAAM,EAAE;IAG1B,kBAAkB;IAIlB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAoBrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAM/B,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAMvD,OAAO,uBAGL;CACH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// import { subtract } from "mathjs";
|
|
2
2
|
import { NodeIds, NodeType } from "../node.js";
|
|
3
3
|
import { OperatorIds, isOperatorNode } from "./operatorNode.js";
|
|
4
|
-
import { OppositeNode } from "../functions/oppositeNode.js";
|
|
5
|
-
import { AddNode } from "./addNode.js";
|
|
4
|
+
import { opposite, OppositeNode } from "../functions/oppositeNode.js";
|
|
5
|
+
import { add, AddNode } from "./addNode.js";
|
|
6
6
|
import { coinFlip } from "../../../utils/alea/coinFlip.js";
|
|
7
7
|
import { colorize } from "../../../utils/latex/colorize.js";
|
|
8
8
|
export function isSubstractNode(a) {
|
|
@@ -94,6 +94,7 @@ export class SubstractNode {
|
|
|
94
94
|
}
|
|
95
95
|
shuffle = () => {
|
|
96
96
|
if (coinFlip())
|
|
97
|
-
|
|
97
|
+
return this;
|
|
98
|
+
return add(opposite(this.rightChild), this.leftChild);
|
|
98
99
|
};
|
|
99
100
|
}
|