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
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableReading = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const numberVEA_1 = require("../../../exercises/vea/numberVEA");
|
|
7
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
+
const random_1 = require("../../../utils/alea/random");
|
|
9
|
+
const handleVEAError_1 = require("../../../utils/errors/handleVEAError");
|
|
10
|
+
const dollarize_1 = require("../../../utils/latex/dollarize");
|
|
11
|
+
const mdTable_1 = require("../../../utils/markdown/mdTable");
|
|
12
|
+
const getPropositions = (n, { answer, values, caseAsked }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
15
|
+
while (propositions.length < n) {
|
|
16
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, random_1.random)(values.flat()).frenchify());
|
|
17
|
+
}
|
|
18
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
19
|
+
};
|
|
20
|
+
const getAnswer = (identifiers) => {
|
|
21
|
+
const { values, caseAsked } = identifiers;
|
|
22
|
+
const flatValues = values.flat();
|
|
23
|
+
return flatValues[caseAsked].frenchify();
|
|
24
|
+
};
|
|
25
|
+
const getInstruction = (identifiers) => {
|
|
26
|
+
const { values, caseAsked } = identifiers;
|
|
27
|
+
let population = caseAsked % 3 === 0
|
|
28
|
+
? "de la $6^e$ A"
|
|
29
|
+
: caseAsked % 3 === 1
|
|
30
|
+
? "de la $6^e$ B"
|
|
31
|
+
: "";
|
|
32
|
+
let caractere = caseAsked < 3
|
|
33
|
+
? "préfèrent le jeu Minecraft"
|
|
34
|
+
: caseAsked < 6
|
|
35
|
+
? "préfèrent le jeu The Legend of Zelda"
|
|
36
|
+
: "ont répondu au sondage";
|
|
37
|
+
return `Un sondage a été réalisé auprès des élèves de deux classes de $6^e$ pour connaître leur jeu vidéo préféré. Voici leurs réponses :
|
|
38
|
+
|
|
39
|
+
${(0, mdTable_1.mdTable)([
|
|
40
|
+
["", "$6^e$ A", "$6^e$ B", "Total"],
|
|
41
|
+
["Minecraft", ...values[0].map(dollarize_1.dollarize)],
|
|
42
|
+
["The Legend of Zelda", ...values[1].map(dollarize_1.dollarize)],
|
|
43
|
+
["Total", ...values[2].map(dollarize_1.dollarize)],
|
|
44
|
+
])}
|
|
45
|
+
|
|
46
|
+
Combien d'élèves ${population} ${caractere} ?
|
|
47
|
+
`;
|
|
48
|
+
};
|
|
49
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
50
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
51
|
+
const getKeys = (identifiers) => {
|
|
52
|
+
return [];
|
|
53
|
+
};
|
|
54
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
55
|
+
try {
|
|
56
|
+
return (0, numberVEA_1.numberVEA)(ans, answer);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const getTableReadingQuestion = (ops) => {
|
|
63
|
+
const caseAsked = (0, randint_1.randint)(0, 9);
|
|
64
|
+
const totalA = (0, randint_1.randint)(20, 30);
|
|
65
|
+
const totalB = (0, randint_1.randint)(20, 30, [totalA]);
|
|
66
|
+
const case0 = (0, randint_1.randint)(3, totalA - 5);
|
|
67
|
+
const case1 = (0, randint_1.randint)(3, totalB - 5, [case0]);
|
|
68
|
+
const case3 = totalA - case0;
|
|
69
|
+
const case4 = totalB - case1;
|
|
70
|
+
const values = [
|
|
71
|
+
[case0, case1, case0 + case1],
|
|
72
|
+
[case3, case4, case3 + case4],
|
|
73
|
+
[totalA, totalB, totalA + totalB],
|
|
74
|
+
];
|
|
75
|
+
const identifiers = {
|
|
76
|
+
caseAsked,
|
|
77
|
+
values,
|
|
78
|
+
};
|
|
79
|
+
const question = {
|
|
80
|
+
answer: getAnswer(identifiers),
|
|
81
|
+
instruction: getInstruction(identifiers),
|
|
82
|
+
keys: getKeys(identifiers),
|
|
83
|
+
answerFormat: "tex",
|
|
84
|
+
identifiers,
|
|
85
|
+
// hint: getHint(identifiers),
|
|
86
|
+
// correction: getCorrection(identifiers),
|
|
87
|
+
};
|
|
88
|
+
return question;
|
|
89
|
+
};
|
|
90
|
+
exports.tableReading = {
|
|
91
|
+
id: "tableReading",
|
|
92
|
+
connector: "=",
|
|
93
|
+
label: "Lire un tableau à double entrée",
|
|
94
|
+
isSingleStep: true,
|
|
95
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getTableReadingQuestion(opts), nb),
|
|
96
|
+
qcmTimer: 60,
|
|
97
|
+
freeTimer: 60,
|
|
98
|
+
getPropositions,
|
|
99
|
+
isAnswerValid,
|
|
100
|
+
subject: "Mathématiques",
|
|
101
|
+
getInstruction,
|
|
102
|
+
// getHint,
|
|
103
|
+
// getCorrection,
|
|
104
|
+
getAnswer,
|
|
105
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powerCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"powerCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoIF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAmB5D,CAAC"}
|
|
@@ -7,19 +7,73 @@ const affine_1 = require("../../../../math/polynomials/affine");
|
|
|
7
7
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
8
8
|
const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
|
|
9
9
|
const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
|
|
11
|
+
const latexParser_1 = require("../../../../tree/parsers/latexParser");
|
|
12
|
+
const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
|
|
13
|
+
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
14
|
+
const getInstruction = (identifiers) => {
|
|
15
|
+
const { affineA, affineB, power } = identifiers;
|
|
16
|
+
const affine = new affine_1.Affine(affineA, affineB);
|
|
14
17
|
const powerTree = power.toTree();
|
|
18
|
+
const affineTree = affine.toTree();
|
|
15
19
|
const fct = new powerNode_1.PowerNode(affineTree, powerTree);
|
|
20
|
+
return `Déterminer la fonction dérivée de la fonction $f$ définie par :
|
|
21
|
+
$$
|
|
22
|
+
f(x) = ${fct.toTex()}
|
|
23
|
+
$$`;
|
|
24
|
+
};
|
|
25
|
+
const getAnswer = (identifiers) => {
|
|
26
|
+
const { affineA, affineB, power } = identifiers;
|
|
27
|
+
const affine = new affine_1.Affine(affineA, affineB);
|
|
28
|
+
const affineTree = affine.toTree();
|
|
16
29
|
const deriv = new multiplyNode_1.MultiplyNode((power * affine.a).toTree(), new powerNode_1.PowerNode(affineTree, (power - 1).toTree()));
|
|
30
|
+
return deriv.toTex();
|
|
31
|
+
};
|
|
32
|
+
const getHint = (identifiers) => {
|
|
33
|
+
return `On rappelle la règle de dérivation suivante :
|
|
34
|
+
|
|
35
|
+
$$
|
|
36
|
+
\\left(u^n \\right)' = n \\times u' \\times u^{n-1}
|
|
37
|
+
$$
|
|
38
|
+
`;
|
|
39
|
+
};
|
|
40
|
+
const getCorrection = (identifiers) => {
|
|
41
|
+
const { affineA, affineB, power: pow } = identifiers;
|
|
42
|
+
const affine = new affine_1.Affine(affineA, affineB).toTree();
|
|
43
|
+
const affineTex = affine.toTex();
|
|
44
|
+
const answer = getAnswer(identifiers);
|
|
45
|
+
return `On sait que :
|
|
46
|
+
|
|
47
|
+
$$
|
|
48
|
+
\\left(u^n \\right)' = n \\times u' \\times u^{n-1}
|
|
49
|
+
$$
|
|
50
|
+
|
|
51
|
+
Ici, on a $n = ${pow}$, et $u(x) = ${affineTex}$, donc $u'(x) = ${affineA}$.
|
|
52
|
+
|
|
53
|
+
Ainsi,
|
|
54
|
+
|
|
55
|
+
${(0, alignTex_1.alignTex)([
|
|
56
|
+
[
|
|
57
|
+
"f'(x)",
|
|
58
|
+
"=",
|
|
59
|
+
(0, multiplyNode_1.multiply)(pow, (0, multiplyNode_1.multiply)(affineA, (0, powerNode_1.power)(affine, (0, substractNode_1.substract)(pow, 1)))).toTex(),
|
|
60
|
+
],
|
|
61
|
+
["", "=", answer],
|
|
62
|
+
])}
|
|
63
|
+
`;
|
|
64
|
+
};
|
|
65
|
+
const getPowerCompositionDerivationQuestion = () => {
|
|
66
|
+
const affine = affine_1.AffineConstructor.random(undefined, { excludes: [0] });
|
|
67
|
+
const power = (0, randint_1.randint)(3, 10);
|
|
68
|
+
const identifiers = { affineA: affine.a, affineB: affine.b, power };
|
|
17
69
|
const question = {
|
|
18
|
-
answer:
|
|
19
|
-
instruction:
|
|
70
|
+
answer: getAnswer(identifiers),
|
|
71
|
+
instruction: getInstruction(identifiers),
|
|
72
|
+
hint: getHint(identifiers),
|
|
73
|
+
correction: getCorrection(identifiers),
|
|
20
74
|
keys: ["x"],
|
|
21
75
|
answerFormat: "tex",
|
|
22
|
-
identifiers
|
|
76
|
+
identifiers,
|
|
23
77
|
};
|
|
24
78
|
return question;
|
|
25
79
|
};
|
|
@@ -39,10 +93,15 @@ const getPropositions = (n, { answer, affineA, affineB, power }) => {
|
|
|
39
93
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
40
94
|
};
|
|
41
95
|
const isAnswerValid = (ans, { answer, power, affineA, affineB }) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
96
|
+
try {
|
|
97
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
98
|
+
if (!parsed)
|
|
99
|
+
return false;
|
|
100
|
+
return parsed.simplify({ forbidFactorize: true }).toTex() === answer;
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
return (0, handleVEAError_1.handleVEAError)(err);
|
|
104
|
+
}
|
|
46
105
|
};
|
|
47
106
|
exports.powerCompositionDerivation = {
|
|
48
107
|
id: "powerCompositionDerivation",
|
|
@@ -57,4 +116,9 @@ exports.powerCompositionDerivation = {
|
|
|
57
116
|
getPropositions,
|
|
58
117
|
isAnswerValid,
|
|
59
118
|
subject: "Mathématiques",
|
|
119
|
+
getAnswer,
|
|
120
|
+
getInstruction,
|
|
121
|
+
getHint,
|
|
122
|
+
getCorrection,
|
|
123
|
+
hasHintAndCorrection: true,
|
|
60
124
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineExpressionFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"affineExpressionFromTwoImages.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionFromTwoImages.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA+IF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAgB/D,CAAC"}
|
|
@@ -96,7 +96,6 @@ const getPropositions = (n, { answer, xA, xB, yA, yB }) => {
|
|
|
96
96
|
};
|
|
97
97
|
const isAnswerValid = (ans, { xA, xB, yA, yB }) => {
|
|
98
98
|
try {
|
|
99
|
-
// const parsed = affineParser(ans);
|
|
100
99
|
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
101
100
|
if (!parsed)
|
|
102
101
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineExpressionReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"affineExpressionReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineExpressionReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAiBlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAkIF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAezD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diceBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/diceBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,
|
|
1
|
+
{"version":3,"file":"diceBasicProbas.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/diceBasicProbas.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAwIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAiBjD,CAAC"}
|
|
@@ -3,20 +3,66 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.diceBasicProbas = void 0;
|
|
4
4
|
const exercise_1 = require("../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const rationalVEA_1 = require("../../../exercises/vea/rationalVEA");
|
|
6
7
|
const rational_1 = require("../../../math/numbers/rationals/rational");
|
|
7
8
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
-
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
9
9
|
const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
|
|
10
10
|
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
11
11
|
const probaFlip_1 = require("../../../utils/alea/probaFlip");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const getHint = (identifiers) => {
|
|
13
|
+
const { isParityQuestion, isEvenQuestion, nbFaces, faceAsked } = identifiers;
|
|
14
|
+
if (isParityQuestion) {
|
|
15
|
+
const parity = isEvenQuestion ? "paire" : "impaire";
|
|
16
|
+
return `Compte le nombre de faces ${parity}s parmi les $${nbFaces}$ faces du dé. Sur un dé, la plus petite face est $1$.`;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return `Il y a une seule face $${faceAsked}$ parmi les $${nbFaces}$ faces du dé. De plus, chaque face a la même probabilité d'apparaître, car le dé est équilibré.`;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const getCorrection = (identifiers) => {
|
|
23
|
+
const { isParityQuestion, isEvenQuestion, nbFaces, faceAsked } = identifiers;
|
|
24
|
+
const answer = getAnswer(identifiers);
|
|
25
|
+
if (isParityQuestion) {
|
|
26
|
+
const parity = isEvenQuestion ? "paire" : "impaire";
|
|
27
|
+
const count = nbFaces % 2 === 0
|
|
28
|
+
? nbFaces / 2
|
|
29
|
+
: isEvenQuestion
|
|
30
|
+
? Math.floor(nbFaces / 2)
|
|
31
|
+
: Math.ceil(nbFaces / 2);
|
|
32
|
+
const faces = isEvenQuestion
|
|
33
|
+
? Array.from({ length: count }, (_, i) => 2 * (i + 1))
|
|
34
|
+
: Array.from({ length: count }, (_, i) => 2 * i + 1);
|
|
35
|
+
return `Il y a $${count}$ faces ${parity}s parmi les $${nbFaces}$ faces du dé : ce sont les faces $${faces.join(",")}$.
|
|
36
|
+
|
|
37
|
+
Puisque le dé est équilibré, chaque face du dé a autant de chances d'apparaître.
|
|
38
|
+
|
|
39
|
+
Ainsi, la probabilité d'obtenir une face ${parity} est :
|
|
40
|
+
|
|
41
|
+
$$
|
|
42
|
+
${(0, fractionNode_1.frac)(count, nbFaces).toSimplificationString()}
|
|
43
|
+
$$`;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return `Puisque le dé est équilibré, chaque face du dé a autant de chances d'apparaître. Il y a une seule face $${faceAsked}$ parmi les $${nbFaces}$ faces du dé.
|
|
47
|
+
|
|
48
|
+
Ainsi, la probabilité d'obtenir la face $${faceAsked}$ est :
|
|
49
|
+
|
|
50
|
+
$$
|
|
51
|
+
${answer}
|
|
52
|
+
$$`;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const getInstruction = (identifiers) => {
|
|
56
|
+
const { isParityQuestion, isEvenQuestion, nbFaces, faceAsked } = identifiers;
|
|
17
57
|
const target = isParityQuestion
|
|
18
58
|
? `un nombre ${isEvenQuestion ? "pair" : "impair"}`
|
|
19
59
|
: `la face $${faceAsked}$`;
|
|
60
|
+
return `On lance un dé équilibré à $${nbFaces}$ faces.
|
|
61
|
+
|
|
62
|
+
Quelle est la probabilité d'obtenir ${target} ?`;
|
|
63
|
+
};
|
|
64
|
+
const getAnswer = (identifiers) => {
|
|
65
|
+
const { isParityQuestion, isEvenQuestion, nbFaces, faceAsked } = identifiers;
|
|
20
66
|
const answer = isParityQuestion
|
|
21
67
|
? isEvenQuestion
|
|
22
68
|
? (0, fractionNode_1.frac)(Math.floor(nbFaces / 2), nbFaces)
|
|
@@ -26,12 +72,22 @@ const getDiceBasicProbasQuestion = () => {
|
|
|
26
72
|
.simplify()
|
|
27
73
|
.toTex()
|
|
28
74
|
: (0, fractionNode_1.frac)(1, nbFaces).toTex();
|
|
75
|
+
return answer;
|
|
76
|
+
};
|
|
77
|
+
const getDiceBasicProbasQuestion = () => {
|
|
78
|
+
const nbFaces = (0, randint_1.randint)(4, 10);
|
|
79
|
+
const isParityQuestion = (0, probaFlip_1.probaFlip)(0.3);
|
|
80
|
+
const isEvenQuestion = (0, coinFlip_1.coinFlip)();
|
|
81
|
+
const faceAsked = (0, randint_1.randint)(1, nbFaces + 1);
|
|
82
|
+
const identifiers = { isParityQuestion, isEvenQuestion, nbFaces, faceAsked };
|
|
29
83
|
const question = {
|
|
30
|
-
answer,
|
|
31
|
-
instruction:
|
|
84
|
+
answer: getAnswer(identifiers),
|
|
85
|
+
instruction: getInstruction(identifiers),
|
|
32
86
|
keys: [],
|
|
33
87
|
answerFormat: "tex",
|
|
34
|
-
identifiers
|
|
88
|
+
identifiers,
|
|
89
|
+
hint: getHint(identifiers),
|
|
90
|
+
correction: getCorrection(identifiers),
|
|
35
91
|
};
|
|
36
92
|
return question;
|
|
37
93
|
};
|
|
@@ -55,27 +111,23 @@ const getPropositions = (n, { answer, isParityQuestion, isEvenQuestion, nbFaces
|
|
|
55
111
|
}
|
|
56
112
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
57
113
|
};
|
|
58
|
-
const isAnswerValid = (ans, { isParityQuestion, isEvenQuestion, nbFaces }) => {
|
|
59
|
-
|
|
60
|
-
const answer = isParityQuestion
|
|
61
|
-
? isEvenQuestion
|
|
62
|
-
? new rational_1.Rational(Math.floor(nbFaces / 2), nbFaces).simplify().toTree(opts)
|
|
63
|
-
: new rational_1.Rational(Math.ceil(nbFaces / 2), nbFaces).simplify().toTree(opts)
|
|
64
|
-
: new fractionNode_1.FractionNode(new numberNode_1.NumberNode(1), new numberNode_1.NumberNode(nbFaces), opts);
|
|
65
|
-
const texs = answer.toAllValidTexs();
|
|
66
|
-
return texs.includes(ans);
|
|
114
|
+
const isAnswerValid = (ans, { answer, isParityQuestion, isEvenQuestion, nbFaces }) => {
|
|
115
|
+
return (0, rationalVEA_1.rationalVEA)(ans, answer, { decimalPrecision: 2 });
|
|
67
116
|
};
|
|
68
117
|
exports.diceBasicProbas = {
|
|
69
118
|
id: "diceBasicProbas",
|
|
70
119
|
connector: "=",
|
|
71
120
|
label: "Calcul de probabilité simple avec un dé",
|
|
72
|
-
levels: ["5ème", "4ème", "3ème", "2ndPro", "2nde", "CAP"],
|
|
73
121
|
isSingleStep: true,
|
|
74
|
-
sections: ["Probabilités"],
|
|
75
122
|
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getDiceBasicProbasQuestion, nb),
|
|
76
123
|
qcmTimer: 60,
|
|
77
124
|
freeTimer: 60,
|
|
78
125
|
getPropositions,
|
|
79
126
|
isAnswerValid,
|
|
80
127
|
subject: "Mathématiques",
|
|
128
|
+
getAnswer,
|
|
129
|
+
getHint,
|
|
130
|
+
getInstruction,
|
|
131
|
+
getCorrection,
|
|
132
|
+
hasHintAndCorrection: true,
|
|
81
133
|
};
|
|
@@ -27,7 +27,7 @@ const rationalVEA = (studentAns, answer, { allowNonIrreductible, decimalPrecisio
|
|
|
27
27
|
//! accepte bien les arrondis au centième par ex, mais va aussi accepter les arrondis au millième
|
|
28
28
|
//! je juge ca ok
|
|
29
29
|
return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
|
|
30
|
-
Math.pow(10, -decimalPrecision
|
|
30
|
+
Math.pow(10, -decimalPrecision));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
else if (allowNonIrreductible) {
|
package/lib/index.d.ts
CHANGED
|
@@ -382,9 +382,9 @@ declare const mathExercises: (Exercise<{
|
|
|
382
382
|
poly2: number[];
|
|
383
383
|
xValue: number;
|
|
384
384
|
}, {}> | Exercise<{
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
385
|
+
variable: string;
|
|
386
|
+
coeffs: number[][];
|
|
387
|
+
order: number[];
|
|
388
388
|
}, {}> | Exercise<{
|
|
389
389
|
firstTermIsAffine: boolean;
|
|
390
390
|
a: number;
|
|
@@ -1816,6 +1816,9 @@ declare const mathExercises: (Exercise<{
|
|
|
1816
1816
|
n: number;
|
|
1817
1817
|
isRepresentative: boolean;
|
|
1818
1818
|
wordingType: number;
|
|
1819
|
+
}, {}> | Exercise<{
|
|
1820
|
+
values: number[][];
|
|
1821
|
+
caseAsked: number;
|
|
1819
1822
|
}, {}>)[];
|
|
1820
1823
|
declare const pcExercises: (Exercise<{
|
|
1821
1824
|
numbers: 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,sBAAsB,CAAC;AAG1D,OAAO,yBAAyB,CAAC;AAEjC,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,sBAAsB,CAAC;AAG1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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -8,6 +8,7 @@ export type SimplifyOptions = {
|
|
|
8
8
|
towardsDistribute?: boolean;
|
|
9
9
|
decimalToFractions?: boolean;
|
|
10
10
|
forceIsolateMonomCoeffs?: boolean;
|
|
11
|
+
forbidAdditions?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export interface AlgebraicNode extends Node {
|
|
13
14
|
evaluate: (vars?: Record<string, number>) => number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algebraicNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/algebraicNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"algebraicNode.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/algebraicNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AACF,MAAM,WAAW,aAAc,SAAQ,IAAI;IACzC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC;IACpD,oBAAoB,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,aAAa,CAAC;IAC7E,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,aAAa,EAAE,CAAC;IAC3D,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,aAAa,CAAC;IACpD,MAAM,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;CACjD;AAED,eAAO,MAAM,eAAe,SAAU,IAAI,0BACA,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType, ToTexOptions } from "../node";
|
|
2
|
-
import { CommutativeOperatorNode, OperatorIds } from "./operatorNode";
|
|
2
|
+
import { CommutativeOperatorNode, DeepShuffleOpts, OperatorIds } from "./operatorNode";
|
|
3
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isAddNode(a: Node): a is AddNode;
|
|
5
5
|
export declare const add: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string) => AddNode;
|
|
@@ -12,6 +12,7 @@ export declare class AddNode implements CommutativeOperatorNode {
|
|
|
12
12
|
isNumeric: boolean;
|
|
13
13
|
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
|
|
14
14
|
shuffle: () => void;
|
|
15
|
+
deepShuffle: (opts?: DeepShuffleOpts) => AddNode;
|
|
15
16
|
toMathString(): string;
|
|
16
17
|
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
17
18
|
toAllTexs(): string[];
|
|
@@ -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,SAAS,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,WAAW,
|
|
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,SAAS,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,WAAW,EAIZ,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAYlE,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;IASpB,OAAO,aAGL;IACF,WAAW,UAAW,eAAe,aAUnC;IAEF,YAAY,IAAI,MAAM;IAItB,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAoCtD,SAAS,IAAI,MAAM,EAAE;IAIrB,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAK5C,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAerC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAsJ/C,aAAa;;;;;;;;;IAOb,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAUpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAMxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAMxD"}
|
|
@@ -32,6 +32,18 @@ class AddNode {
|
|
|
32
32
|
if ((0, coinFlip_1.coinFlip)())
|
|
33
33
|
[this.leftChild, this.rightChild] = [this.rightChild, this.leftChild];
|
|
34
34
|
};
|
|
35
|
+
this.deepShuffle = (opts) => {
|
|
36
|
+
const left = (0, operatorNode_1.isCommutativeOperatorNode)(this.leftChild)
|
|
37
|
+
? this.leftChild.deepShuffle(opts)
|
|
38
|
+
: this.leftChild;
|
|
39
|
+
const right = (0, operatorNode_1.isCommutativeOperatorNode)(this.rightChild)
|
|
40
|
+
? this.rightChild.deepShuffle(opts)
|
|
41
|
+
: this.rightChild;
|
|
42
|
+
if ((0, coinFlip_1.coinFlip)() && (!opts || opts?.nodeIdsToShuffle?.includes(this.id)))
|
|
43
|
+
return new AddNode(right, left, this.opts);
|
|
44
|
+
else
|
|
45
|
+
return new AddNode(left, right, this.opts);
|
|
46
|
+
};
|
|
35
47
|
this.id = operatorNode_1.OperatorIds.add;
|
|
36
48
|
this.leftChild = leftChild;
|
|
37
49
|
this.rightChild = rightChild;
|
|
@@ -131,13 +143,19 @@ class AddNode {
|
|
|
131
143
|
if (externals.length === 1)
|
|
132
144
|
return externals[0];
|
|
133
145
|
const simplifyExternalNodes = (a, b) => {
|
|
134
|
-
const fracSimplify =
|
|
146
|
+
const fracSimplify = opts?.forbidAdditions
|
|
147
|
+
? undefined
|
|
148
|
+
: addSimplifyFrac(a, b, opts);
|
|
135
149
|
if (fracSimplify)
|
|
136
150
|
return fracSimplify;
|
|
137
|
-
const nbSimplify =
|
|
151
|
+
const nbSimplify = opts?.forbidAdditions
|
|
152
|
+
? undefined
|
|
153
|
+
: addSimplifyNumbers(a, b, opts);
|
|
138
154
|
if (nbSimplify)
|
|
139
155
|
return nbSimplify;
|
|
140
|
-
const monomSimplify =
|
|
156
|
+
const monomSimplify = opts?.forbidAdditions
|
|
157
|
+
? undefined
|
|
158
|
+
: addSimplifyMonoms(a, b, opts);
|
|
141
159
|
if (monomSimplify)
|
|
142
160
|
return monomSimplify;
|
|
143
161
|
//TODO gérer le reste
|
|
@@ -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,EAAE,MAAM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AY,IAAI,MAAM;IAItB,aAAa,IAAI,uBAAuB;IAQxC,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA+BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,SAAS;IAUT,KAAK,IAAI,MAAM;IA2Bf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAmN/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAOxD,sBAAsB;IAQtB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAGxD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType, ToTexOptions } from "../node";
|
|
2
|
-
import { CommutativeOperatorNode, OperatorIds } from "./operatorNode";
|
|
2
|
+
import { CommutativeOperatorNode, DeepShuffleOpts, OperatorIds } from "./operatorNode";
|
|
3
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
4
|
export declare function isMultiplyNode(a: Node): a is MultiplyNode;
|
|
5
5
|
export declare const multiply: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string, opts?: NodeOptions) => MultiplyNode;
|
|
@@ -13,6 +13,7 @@ export declare class MultiplyNode implements CommutativeOperatorNode {
|
|
|
13
13
|
isNumeric: boolean;
|
|
14
14
|
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
|
|
15
15
|
shuffle: () => void;
|
|
16
|
+
deepShuffle: (opts?: DeepShuffleOpts) => MultiplyNode;
|
|
16
17
|
toReversed: () => MultiplyNode;
|
|
17
18
|
toMathString(): string;
|
|
18
19
|
toTex(options?: ToTexOptions): 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,SAAS,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,WAAW,
|
|
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,SAAS,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EACL,aAAa,EACb,eAAe,EAEhB,MAAM,kBAAkB,CAAC;AAU1B,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,QAAQ,MAChB,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,iBAOnB,CAAC;AACF,eAAO,MAAM,iBAAiB,QAAS,aAAa,EAAE,SAYrD,CAAC;AACF,qBAAa,YAAa,YAAW,uBAAuB;IAC1D,IAAI,CAAC,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,aAGL;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;IAyK/C,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"}
|
|
@@ -49,6 +49,18 @@ class MultiplyNode {
|
|
|
49
49
|
if ((0, coinFlip_1.coinFlip)())
|
|
50
50
|
[this.leftChild, this.rightChild] = [this.rightChild, this.leftChild];
|
|
51
51
|
};
|
|
52
|
+
this.deepShuffle = (opts) => {
|
|
53
|
+
const left = (0, operatorNode_1.isCommutativeOperatorNode)(this.leftChild)
|
|
54
|
+
? this.leftChild.deepShuffle(opts)
|
|
55
|
+
: this.leftChild;
|
|
56
|
+
const right = (0, operatorNode_1.isCommutativeOperatorNode)(this.rightChild)
|
|
57
|
+
? this.rightChild.deepShuffle(opts)
|
|
58
|
+
: this.rightChild;
|
|
59
|
+
if ((0, coinFlip_1.coinFlip)() && (!opts || opts?.nodeIdsToShuffle?.includes(this.id)))
|
|
60
|
+
return new MultiplyNode(right, left, this.opts);
|
|
61
|
+
else
|
|
62
|
+
return new MultiplyNode(left, right, this.opts);
|
|
63
|
+
};
|
|
52
64
|
this.toReversed = () => {
|
|
53
65
|
return new MultiplyNode(this.rightChild, this.leftChild, this.opts);
|
|
54
66
|
};
|
|
@@ -18,8 +18,13 @@ export interface OperatorNode extends AlgebraicNode {
|
|
|
18
18
|
rightChild: AlgebraicNode;
|
|
19
19
|
}
|
|
20
20
|
export declare function isOperatorNode(a: Node): a is OperatorNode;
|
|
21
|
+
export declare function isCommutativeOperatorNode(a: Node): a is CommutativeOperatorNode;
|
|
22
|
+
export type DeepShuffleOpts = {
|
|
23
|
+
nodeIdsToShuffle: OperatorIds[];
|
|
24
|
+
};
|
|
21
25
|
export interface CommutativeOperatorNode extends OperatorNode {
|
|
22
26
|
shuffle: () => void;
|
|
27
|
+
deepShuffle: (opts?: DeepShuffleOpts) => CommutativeOperatorNode;
|
|
23
28
|
toAllTexs: () => string[];
|
|
24
29
|
}
|
|
25
30
|
//# sourceMappingURL=operatorNode.d.ts.map
|
|
@@ -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,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"operatorNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/operatorNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAqB,MAAM,SAAS,CAAC;AAElD,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,IAAI,CAAC;IACpB,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,uBAAuB,CAAC;IACjE,SAAS,EAAE,MAAM,MAAM,EAAE,CAAC;CAC3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isOperatorNode = exports.OperatorIds = void 0;
|
|
3
|
+
exports.isCommutativeOperatorNode = exports.isOperatorNode = exports.OperatorIds = void 0;
|
|
4
4
|
const node_1 = require("../node");
|
|
5
5
|
var OperatorIds;
|
|
6
6
|
(function (OperatorIds) {
|
|
@@ -19,3 +19,7 @@ function isOperatorNode(a) {
|
|
|
19
19
|
return a.type === node_1.NodeType.operator;
|
|
20
20
|
}
|
|
21
21
|
exports.isOperatorNode = isOperatorNode;
|
|
22
|
+
function isCommutativeOperatorNode(a) {
|
|
23
|
+
return (isOperatorNode(a) && [OperatorIds.add, OperatorIds.multiply].includes(a.id));
|
|
24
|
+
}
|
|
25
|
+
exports.isCommutativeOperatorNode = isCommutativeOperatorNode;
|