math-exercises 2.2.66 → 2.2.67
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/fractionAndIntegerSum.d.ts +1 -0
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionAndIntegerSum.js +51 -37
- package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.js +3 -1
- package/lib/exercises/math/percent/applyPercent.d.ts.map +1 -1
- package/lib/exercises/math/percent/applyPercent.js +2 -4
- package/lib/exercises/math/probaStat/probabilityTree.d.ts +10 -7
- package/lib/exercises/math/probaStat/probabilityTree.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probabilityTree.js +194 -90
- package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +7 -3
- package/lib/exercises/vea/rationalVEA.d.ts +7 -1
- package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
- package/lib/exercises/vea/rationalVEA.js +28 -3
- package/lib/index.d.ts +10 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/math/complex/complex.d.ts +1 -1
- package/lib/math/numbers/rationals/rational.d.ts +1 -1
- package/lib/math/numbers/reals/extendedRingElement.d.ts +1 -1
- package/lib/math/polynomials/generalAffine.d.ts +1 -1
- package/lib/math/polynomials/generalTrinom.d.ts +1 -1
- package/lib/math/polynomials/trinom.d.ts +3 -3
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +2 -3
- package/lib/prototypesEnhancement.d.ts +3 -1
- package/lib/prototypesEnhancement.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.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/fractionNode.d.ts +8 -9
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +15 -0
- package/lib/tree/parsers/affineParser.d.ts +1 -2
- package/lib/tree/parsers/affineParser.d.ts.map +1 -1
- package/lib/tree/parsers/affineParser.js +16 -16
- package/lib/tree/parsers/latexParser.d.ts +1 -1
- package/lib/tree/parsers/monomParser.d.ts +9 -1
- package/lib/tree/parsers/monomParser.d.ts.map +1 -1
- package/lib/tree/parsers/monomParser.js +65 -2
- package/lib/tree/parsers/powerParser.d.ts +1 -1
- package/lib/tree/parsers/purifyLatex.d.ts +9 -0
- package/lib/tree/parsers/purifyLatex.d.ts.map +1 -0
- package/lib/tree/parsers/purifyLatex.js +17 -0
- package/lib/tree/parsers/rationalParser.d.ts +1 -1
- package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
- package/lib/tree/parsers/trinomParser.d.ts +2 -0
- package/lib/tree/parsers/trinomParser.d.ts.map +1 -0
- package/lib/tree/parsers/trinomParser.js +31 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fractionAndIntegerSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionAndIntegerSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"fractionAndIntegerSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionAndIntegerSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAgBlC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,CAAC;AA+FF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAcF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBhE,CAAC"}
|
|
@@ -4,35 +4,60 @@ exports.fractionAndIntegerSum = void 0;
|
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const allowNonIrreductibleFractions_1 = require("../../../../exercises/options/allowNonIrreductibleFractions");
|
|
6
6
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
7
|
+
const rationalVEA_1 = require("../../../../exercises/vea/rationalVEA");
|
|
7
8
|
const integer_1 = require("../../../../math/numbers/integer/integer");
|
|
8
9
|
const rational_1 = require("../../../../math/numbers/rationals/rational");
|
|
9
10
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
10
11
|
const addNode_1 = require("../../../../tree/nodes/operators/addNode");
|
|
11
|
-
const
|
|
12
|
+
const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
|
|
13
|
+
const coinFlip_1 = require("../../../../utils/alea/coinFlip");
|
|
12
14
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
15
|
+
const rebuildIdentifiers = (oldIdentifiers) => {
|
|
16
|
+
if (oldIdentifiers.isIntegerFirst !== undefined)
|
|
17
|
+
return oldIdentifiers;
|
|
18
|
+
return {
|
|
19
|
+
integer: oldIdentifiers.integer,
|
|
20
|
+
isIntegerFirst: (0, coinFlip_1.coinFlip)(),
|
|
21
|
+
rational: oldIdentifiers.rational,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const getStatementNode = (identifiers) => {
|
|
25
|
+
const ratio = (0, fractionNode_1.frac)(identifiers.rational[0], identifiers.rational[1]);
|
|
26
|
+
const statement = identifiers.isIntegerFirst
|
|
27
|
+
? (0, addNode_1.add)(identifiers.integer, ratio)
|
|
28
|
+
: (0, addNode_1.add)(ratio, identifiers.integer);
|
|
29
|
+
return statement;
|
|
30
|
+
};
|
|
31
|
+
const getInstruction = (identifiers, opts) => {
|
|
32
|
+
const statement = getStatementNode(identifiers);
|
|
33
|
+
return `Calculer ${opts?.allowNonIrreductible
|
|
34
|
+
? ""
|
|
35
|
+
: "et donner le résultat sous la forme la plus simplifiée possible"} :
|
|
36
|
+
|
|
37
|
+
$$
|
|
38
|
+
${statement.toTex()}
|
|
39
|
+
$$`;
|
|
40
|
+
};
|
|
41
|
+
const getAnswer = (identifiers, opts) => {
|
|
42
|
+
const answerTree = getStatementNode(identifiers);
|
|
43
|
+
return answerTree.simplify().toTex();
|
|
44
|
+
};
|
|
13
45
|
const getFractionAndIntegerSum = (opts) => {
|
|
14
46
|
const rational = rational_1.RationalConstructor.randomIrreductible();
|
|
15
|
-
const integer =
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
47
|
+
const integer = (0, randint_1.randint)(-10, 11, [0]);
|
|
48
|
+
const isIntegerFirst = (0, coinFlip_1.coinFlip)();
|
|
49
|
+
const identifiers = {
|
|
50
|
+
integer: integer,
|
|
51
|
+
rational: [rational.num, rational.denum],
|
|
52
|
+
isIntegerFirst,
|
|
53
|
+
};
|
|
20
54
|
const question = {
|
|
21
|
-
instruction:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
$$
|
|
26
|
-
${statementTree.toTex()}
|
|
27
|
-
$`,
|
|
28
|
-
startStatement: statementTree.toTex(),
|
|
29
|
-
answer,
|
|
55
|
+
instruction: getInstruction(identifiers, opts),
|
|
56
|
+
startStatement: getStatementNode(identifiers).toTex(),
|
|
57
|
+
answer: getAnswer(identifiers, opts),
|
|
30
58
|
keys: [],
|
|
31
59
|
answerFormat: "tex",
|
|
32
|
-
identifiers
|
|
33
|
-
integer: integer.value,
|
|
34
|
-
rational: [rational.num, rational.denum],
|
|
35
|
-
},
|
|
60
|
+
identifiers,
|
|
36
61
|
};
|
|
37
62
|
return question;
|
|
38
63
|
};
|
|
@@ -52,30 +77,16 @@ const getPropositions = (n, { answer, integer, rational }) => {
|
|
|
52
77
|
return (0, shuffle_1.shuffle)(propositions);
|
|
53
78
|
};
|
|
54
79
|
const options = [allowNonIrreductibleFractions_1.allowNonIrreductibleOption];
|
|
55
|
-
const isAnswerValid = (ans, { integer, rational }, opts) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.add(integerObj)
|
|
60
|
-
.toTree({ allowFractionToDecimal: true });
|
|
61
|
-
const texs = answerTree.toAllValidTexs();
|
|
62
|
-
if (opts?.allowNonIrreductible) {
|
|
63
|
-
const parsed = (0, rationalParser_1.rationalParser)(ans);
|
|
64
|
-
if (!parsed)
|
|
65
|
-
return false;
|
|
66
|
-
return texs.includes(parsed.simplify().toTex());
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return texs.includes(ans);
|
|
70
|
-
}
|
|
80
|
+
const isAnswerValid = (ans, { answer, integer, rational }, opts) => {
|
|
81
|
+
return (0, rationalVEA_1.rationalVEA)(ans, answer, {
|
|
82
|
+
allowNonIrreductible: !!opts?.allowNonIrreductible,
|
|
83
|
+
});
|
|
71
84
|
};
|
|
72
85
|
exports.fractionAndIntegerSum = {
|
|
73
86
|
id: "fractionAndIntegerSum",
|
|
74
87
|
connector: "=",
|
|
75
88
|
label: "Somme d'un entier et d'une fraction",
|
|
76
|
-
levels: ["4ème", "3ème", "2nde", "CAP", "2ndPro", "1rePro"],
|
|
77
89
|
isSingleStep: false,
|
|
78
|
-
sections: ["Fractions"],
|
|
79
90
|
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getFractionAndIntegerSum(opts), nb),
|
|
80
91
|
qcmTimer: 60,
|
|
81
92
|
freeTimer: 60,
|
|
@@ -83,4 +94,7 @@ exports.fractionAndIntegerSum = {
|
|
|
83
94
|
isAnswerValid,
|
|
84
95
|
subject: "Mathématiques",
|
|
85
96
|
options,
|
|
97
|
+
getAnswer,
|
|
98
|
+
getInstruction,
|
|
99
|
+
rebuildIdentifiers,
|
|
86
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distanceBetweenTwoPoints.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"distanceBetweenTwoPoints.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/distanceBetweenTwoPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAkHF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAc1D,CAAC"}
|
|
@@ -18,7 +18,9 @@ const getDistanceBetweenTwoPoints = () => {
|
|
|
18
18
|
.toTree()
|
|
19
19
|
.toTex();
|
|
20
20
|
const question = {
|
|
21
|
-
instruction: `
|
|
21
|
+
instruction: `Dans un repère orthonormé, soit deux points $${A.toTexWithCoords()}$ et $${B.toTexWithCoords()}$.
|
|
22
|
+
|
|
23
|
+
Calculer la distance $AB$.`,
|
|
22
24
|
startStatement: "AB",
|
|
23
25
|
answer,
|
|
24
26
|
keys: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyPercent.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/applyPercent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"applyPercent.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/applyPercent.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,QAAQ,EAQT,MAAM,gBAAgB,CAAC;AAGxB,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAmFF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAwB9C,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applyPercent = void 0;
|
|
4
|
+
const numberVEA_1 = require("../../../exercises/vea/numberVEA");
|
|
4
5
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
5
6
|
const round_1 = require("../../../math/utils/round");
|
|
6
|
-
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
7
7
|
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
8
8
|
const shuffle_1 = require("../../../utils/alea/shuffle");
|
|
9
9
|
const exercise_1 = require("../../exercise");
|
|
@@ -74,9 +74,7 @@ const getPropositions = (n, { answer }) => {
|
|
|
74
74
|
return (0, shuffle_1.shuffle)(propositions);
|
|
75
75
|
};
|
|
76
76
|
const isAnswerValid = (ans, { answer }) => {
|
|
77
|
-
|
|
78
|
-
const texs = answerTree.toAllValidTexs();
|
|
79
|
-
return texs.includes(ans);
|
|
77
|
+
return (0, numberVEA_1.numberVEA)(ans, answer);
|
|
80
78
|
};
|
|
81
79
|
exports.applyPercent = {
|
|
82
80
|
id: "applyPercent",
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { NodeIdentifiers } from "../../../tree/nodes/nodeConstructor";
|
|
1
2
|
import { Exercise } from "../../exercise";
|
|
2
3
|
type Identifiers = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
A: NodeIdentifiers;
|
|
5
|
+
B: NodeIdentifiers;
|
|
6
|
+
AC: NodeIdentifiers;
|
|
7
|
+
AD: NodeIdentifiers;
|
|
8
|
+
BC: NodeIdentifiers;
|
|
9
|
+
BD: NodeIdentifiers;
|
|
10
|
+
probaName: string;
|
|
10
11
|
};
|
|
11
12
|
type Options = {
|
|
12
13
|
allowApproximate: string;
|
|
14
|
+
eventTypes: string[];
|
|
15
|
+
probaType: string;
|
|
13
16
|
};
|
|
14
17
|
export declare const probabilityTree: Exercise<Identifiers, Options>;
|
|
15
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAY1C,OAAO,EACL,QAAQ,EAeT,MAAM,gBAAgB,CAAC;AAmCxB,KAAK,WAAW,GAAG;IAIjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;IACnB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4MF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA+CF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB1D,CAAC"}
|
|
@@ -1,72 +1,181 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.probabilityTree = void 0;
|
|
4
|
+
const rationalVEA_1 = require("../../../exercises/vea/rationalVEA");
|
|
4
5
|
const geogebraConstructor_1 = require("../../../geogebra/geogebraConstructor");
|
|
5
|
-
const
|
|
6
|
+
const rational_1 = require("../../../math/numbers/rationals/rational");
|
|
7
|
+
const randfloat_1 = require("../../../math/utils/random/randfloat");
|
|
6
8
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
7
9
|
const round_1 = require("../../../math/utils/round");
|
|
10
|
+
const nodeConstructor_1 = require("../../../tree/nodes/nodeConstructor");
|
|
11
|
+
const addNode_1 = require("../../../tree/nodes/operators/addNode");
|
|
8
12
|
const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
|
|
9
13
|
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
10
|
-
const
|
|
14
|
+
const substractNode_1 = require("../../../tree/nodes/operators/substractNode");
|
|
15
|
+
const random_1 = require("../../../utils/alea/random");
|
|
11
16
|
const shuffle_1 = require("../../../utils/alea/shuffle");
|
|
12
17
|
const exercise_1 = require("../../exercise");
|
|
13
18
|
const getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
switch (type) {
|
|
19
|
+
const rebuildIdentifiers = (oldIdentifiers) => {
|
|
20
|
+
if (oldIdentifiers.probaName)
|
|
21
|
+
return oldIdentifiers;
|
|
22
|
+
const ABTotal = oldIdentifiers.A + oldIdentifiers.B;
|
|
23
|
+
const ASubTotal = oldIdentifiers.AC + oldIdentifiers.AD;
|
|
24
|
+
const BSubTotal = oldIdentifiers.BC + oldIdentifiers.BD;
|
|
25
|
+
let probaName = "";
|
|
26
|
+
switch (oldIdentifiers.type) {
|
|
22
27
|
case 1:
|
|
23
|
-
|
|
28
|
+
probaName = "P(A\\cap C)";
|
|
29
|
+
break;
|
|
24
30
|
case 2:
|
|
25
|
-
|
|
31
|
+
probaName = "P(A\\cap D)";
|
|
32
|
+
break;
|
|
26
33
|
case 3:
|
|
27
|
-
|
|
34
|
+
probaName = "P(B\\cap C)";
|
|
35
|
+
break;
|
|
28
36
|
case 4:
|
|
37
|
+
probaName = "P(B\\cap D)";
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
probaName,
|
|
42
|
+
A: (0, fractionNode_1.frac)(oldIdentifiers.A, ABTotal).simplify().toIdentifiers(),
|
|
43
|
+
B: (0, fractionNode_1.frac)(oldIdentifiers.B, ABTotal).simplify().toIdentifiers(),
|
|
44
|
+
AC: (0, fractionNode_1.frac)(oldIdentifiers.AC, ASubTotal).simplify().toIdentifiers(),
|
|
45
|
+
AD: (0, fractionNode_1.frac)(oldIdentifiers.AD, ASubTotal).simplify().toIdentifiers(),
|
|
46
|
+
BC: (0, fractionNode_1.frac)(oldIdentifiers.BC, BSubTotal).simplify().toIdentifiers(),
|
|
47
|
+
BD: (0, fractionNode_1.frac)(oldIdentifiers.BD, BSubTotal).simplify().toIdentifiers(),
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const optionValues = [
|
|
51
|
+
"Probabilité d'intersection $P(A\\cap C)$",
|
|
52
|
+
"Probabilité totale $P(C)$",
|
|
53
|
+
"Probabilité conditionnelle $P_B(A)$",
|
|
54
|
+
"Probabilité 'simple' $P(A)$",
|
|
55
|
+
];
|
|
56
|
+
const defaultOptionValues = [
|
|
57
|
+
"Probabilité d'intersection $P(A\\cap C)$",
|
|
58
|
+
"Probabilité totale $P(C)$",
|
|
59
|
+
"Probabilité conditionnelle $P_B(A)$",
|
|
60
|
+
];
|
|
61
|
+
const buildAll = (identifiers) => {
|
|
62
|
+
return {
|
|
63
|
+
pA: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.A),
|
|
64
|
+
pAC: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.AC),
|
|
65
|
+
pAD: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.AD),
|
|
66
|
+
pB: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.B),
|
|
67
|
+
pBC: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.BC),
|
|
68
|
+
pBD: nodeConstructor_1.NodeConstructor.fromIdentifiers(identifiers.BD),
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const getAnswerNode = (identifiers) => {
|
|
72
|
+
const probas = buildAll(identifiers);
|
|
73
|
+
switch (identifiers.probaName) {
|
|
74
|
+
case "P(A)":
|
|
75
|
+
return probas.pA;
|
|
76
|
+
case "P(B)":
|
|
77
|
+
return probas.pB;
|
|
78
|
+
case "P(A\\cap C)":
|
|
79
|
+
return (0, multiplyNode_1.multiply)(probas.pA, probas.pAC).simplify();
|
|
80
|
+
case "P(A\\cap D)":
|
|
81
|
+
return (0, multiplyNode_1.multiply)(probas.pA, probas.pAD).simplify();
|
|
82
|
+
case "P(B\\cap C)":
|
|
83
|
+
return (0, multiplyNode_1.multiply)(probas.pB, probas.pBC).simplify();
|
|
84
|
+
case "P(B\\cap D)":
|
|
85
|
+
return (0, multiplyNode_1.multiply)(probas.pB, probas.pBD).simplify();
|
|
86
|
+
case "P_A(C)":
|
|
87
|
+
return probas.pAC;
|
|
88
|
+
case "P_A(D)":
|
|
89
|
+
return probas.pAD;
|
|
90
|
+
case "P_B(C)":
|
|
91
|
+
return probas.pBC;
|
|
92
|
+
case "P_B(D)":
|
|
93
|
+
return probas.pBD;
|
|
94
|
+
case "P(C)":
|
|
95
|
+
return (0, addNode_1.add)((0, multiplyNode_1.multiply)(probas.pA, probas.pAC), (0, multiplyNode_1.multiply)(probas.pB, probas.pBC)).simplify();
|
|
96
|
+
case "P(D)":
|
|
29
97
|
default:
|
|
30
|
-
return (0, multiplyNode_1.multiply)(pB,
|
|
98
|
+
return (0, addNode_1.add)((0, multiplyNode_1.multiply)(probas.pA, probas.pAD), (0, multiplyNode_1.multiply)(probas.pB, probas.pBD)).simplify();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const getAnswer = (identifiers) => {
|
|
102
|
+
return getAnswerNode(identifiers).toTex();
|
|
103
|
+
};
|
|
104
|
+
const getInstruction = (identifiers, options) => {
|
|
105
|
+
let instr = `On considère l'arbre de probabilités ci-dessous. Calculer :
|
|
106
|
+
|
|
107
|
+
$$
|
|
108
|
+
${identifiers.probaName}
|
|
109
|
+
$$`;
|
|
110
|
+
if (options?.allowApproximate) {
|
|
111
|
+
instr += `
|
|
112
|
+
|
|
113
|
+
Donner la valeur exacte ou une valeur arrondie au ${options.allowApproximate}.`;
|
|
114
|
+
}
|
|
115
|
+
return instr;
|
|
116
|
+
};
|
|
117
|
+
const getProbaAndOpposite = (decimal = false) => {
|
|
118
|
+
if (!decimal) {
|
|
119
|
+
const proba = rational_1.RationalConstructor.randomIrreductibleProba().toTree();
|
|
120
|
+
return [proba, (0, substractNode_1.substract)(1, proba).simplify()];
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const proba = (0, round_1.round)((0, randfloat_1.randfloat)(0.01, 1, 2), 2);
|
|
124
|
+
return [proba.toTree(), (0, round_1.round)(1 - proba, 2).toTree()];
|
|
31
125
|
}
|
|
32
126
|
};
|
|
33
127
|
const getProbabilityTree = (opts) => {
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
128
|
+
const isDecimal = opts?.probaType === "Décimales";
|
|
129
|
+
const [pA, pB] = getProbaAndOpposite(isDecimal);
|
|
130
|
+
const [pC_A, pD_A] = getProbaAndOpposite(isDecimal);
|
|
131
|
+
const [pC_B, pD_B] = getProbaAndOpposite(isDecimal);
|
|
132
|
+
const eventTypes = opts?.eventTypes?.length
|
|
133
|
+
? opts.eventTypes
|
|
134
|
+
: defaultOptionValues;
|
|
135
|
+
const type = (0, random_1.random)(eventTypes);
|
|
136
|
+
const index = optionValues.indexOf(type);
|
|
137
|
+
let probaName = "";
|
|
138
|
+
switch (index) {
|
|
139
|
+
case 0: //inter
|
|
140
|
+
probaName = (0, random_1.random)([
|
|
141
|
+
"P(A\\cap C)",
|
|
142
|
+
"P(A\\cap D)",
|
|
143
|
+
"P(B\\cap C)",
|
|
144
|
+
"P(B\\cap D)",
|
|
145
|
+
]);
|
|
49
146
|
break;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
instruction += `calculer $P(A \\cap D)$.`;
|
|
53
|
-
startStatement = `P(A \\cap D)`;
|
|
147
|
+
case 1: //totale
|
|
148
|
+
probaName = (0, random_1.random)(["P(C)", "P(D)"]);
|
|
54
149
|
break;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
instruction += `calculer $P(B \\cap C)$.`;
|
|
58
|
-
startStatement = `P(B \\cap C)`;
|
|
150
|
+
case 2: //conditionnal
|
|
151
|
+
probaName = (0, random_1.random)(["P_A(C)", "P_A(D)", "P_B(C)", "P_B(D)"]);
|
|
59
152
|
break;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
instruction += `calculer $P(B \\cap D)$.`;
|
|
63
|
-
startStatement = `P(B \\cap D)`;
|
|
153
|
+
case 3: //simple
|
|
154
|
+
probaName = (0, random_1.random)(["P(A)", "P(B)"]);
|
|
64
155
|
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (opts?.allowApproximate) {
|
|
68
|
-
instruction += ` Donner la valeur exacte ou une valeur arrondie au ${opts.allowApproximate}.`;
|
|
69
156
|
}
|
|
157
|
+
const identifiers = {
|
|
158
|
+
A: pA.toIdentifiers(),
|
|
159
|
+
B: pB.toIdentifiers(),
|
|
160
|
+
AC: pC_A.toIdentifiers(),
|
|
161
|
+
AD: pD_A.toIdentifiers(),
|
|
162
|
+
BC: pC_B.toIdentifiers(),
|
|
163
|
+
BD: pD_B.toIdentifiers(),
|
|
164
|
+
probaName,
|
|
165
|
+
};
|
|
166
|
+
const question = {
|
|
167
|
+
instruction: getInstruction(identifiers, opts),
|
|
168
|
+
startStatement: probaName,
|
|
169
|
+
answer: getAnswer(identifiers),
|
|
170
|
+
keys: [],
|
|
171
|
+
ggbOptions: getGGBOptions(identifiers, opts),
|
|
172
|
+
answerFormat: "tex",
|
|
173
|
+
identifiers,
|
|
174
|
+
};
|
|
175
|
+
return question;
|
|
176
|
+
};
|
|
177
|
+
const getGGBOptions = (identifiers, opts) => {
|
|
178
|
+
const probas = buildAll(identifiers);
|
|
70
179
|
let commands = [
|
|
71
180
|
"A = Point({2,2})",
|
|
72
181
|
"B = Point({2,-2})",
|
|
@@ -80,12 +189,12 @@ const getProbabilityTree = (opts) => {
|
|
|
80
189
|
"Segment(Point({0,0}),B)",
|
|
81
190
|
"Segment(B,BC)",
|
|
82
191
|
"Segment(B,BD)",
|
|
83
|
-
`Text("\\scriptsize ${
|
|
84
|
-
`Text("\\scriptsize ${
|
|
85
|
-
`Text("\\scriptsize ${
|
|
86
|
-
`Text("\\scriptsize ${
|
|
87
|
-
`Text("\\scriptsize ${
|
|
88
|
-
`Text("\\scriptsize ${
|
|
192
|
+
`Text("\\scriptsize ${probas.pA.toTex()}", (0.1, 2.2), true, true)`,
|
|
193
|
+
`Text("\\scriptsize ${probas.pAC.toTex()}", (2.8, 4), true, true)`,
|
|
194
|
+
`Text("\\scriptsize ${probas.pAD.toTex()}", (2.8, 1.6), true, true)`,
|
|
195
|
+
`Text("\\scriptsize ${probas.pB.toTex()}", (0.1, -0.8), true, true)`,
|
|
196
|
+
`Text("\\scriptsize ${probas.pBC.toTex()}", (2.8, -0.6), true, true)`,
|
|
197
|
+
`Text("\\scriptsize ${probas.pBD.toTex()}", (2.8, -2.5), true, true)`,
|
|
89
198
|
'Text("A", (1.85 , 2.5))',
|
|
90
199
|
'Text("B", (1.85 , -2.8))',
|
|
91
200
|
'Text("C", (5.5 , 2.85))',
|
|
@@ -98,44 +207,30 @@ const getProbabilityTree = (opts) => {
|
|
|
98
207
|
hideAxes: true,
|
|
99
208
|
hideGrid: true,
|
|
100
209
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
answer: answerTex,
|
|
105
|
-
keys: [],
|
|
106
|
-
ggbOptions: ggb.getOptions({
|
|
107
|
-
coords: [-2, 8, -5, 5],
|
|
108
|
-
}),
|
|
109
|
-
answerFormat: "tex",
|
|
110
|
-
identifiers: { A, AC, AD, B, BC, BD, type },
|
|
111
|
-
};
|
|
112
|
-
return question;
|
|
210
|
+
return ggb.getOptions({
|
|
211
|
+
coords: [-2, 8, -5, 5],
|
|
212
|
+
});
|
|
113
213
|
};
|
|
114
|
-
const getPropositions = (n, { answer,
|
|
214
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
115
215
|
const propositions = [];
|
|
116
216
|
(0, exercise_1.addValidProp)(propositions, answer);
|
|
117
|
-
const answerNode = getAnswerNode(
|
|
217
|
+
const answerNode = getAnswerNode(identifiers);
|
|
118
218
|
while (propositions.length < n) {
|
|
119
219
|
const wrongAnswer = (0, multiplyNode_1.multiply)(answerNode, (0, randint_1.randint)(2, 11)).simplify();
|
|
120
220
|
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer.toTex());
|
|
121
221
|
}
|
|
122
222
|
return (0, shuffle_1.shuffle)(propositions);
|
|
123
223
|
};
|
|
124
|
-
const isAnswerValid = (ans, { answer,
|
|
224
|
+
const isAnswerValid = (ans, { answer, ...identifiers }, opts) => {
|
|
125
225
|
try {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
(0, round_1.round)(getAnswerNode({ type, A, AC, AD, B, BC, BD }).evaluate(), rank + 1));
|
|
135
|
-
}
|
|
136
|
-
return answer === simplified.toTex();
|
|
137
|
-
// const answer = getAnswerNode({ type, A, AC, AD, B, BC, BD });
|
|
138
|
-
// const texs = answer.toTree({ allowFractionToDecimal: true }).toAllValidTexs();
|
|
226
|
+
const rank = opts?.allowApproximate
|
|
227
|
+
? ["dixième", "centième", "millième"].indexOf(opts.allowApproximate) + 1
|
|
228
|
+
: undefined;
|
|
229
|
+
return (0, rationalVEA_1.rationalVEA)(ans, answer, {
|
|
230
|
+
allowNonIrreductible: true,
|
|
231
|
+
allowDecimal: true,
|
|
232
|
+
decimalPrecision: rank,
|
|
233
|
+
});
|
|
139
234
|
}
|
|
140
235
|
catch (err) {
|
|
141
236
|
return false;
|
|
@@ -147,25 +242,31 @@ const options = [
|
|
|
147
242
|
label: "Autoriser les valeurs approchées au : ",
|
|
148
243
|
target: exercise_1.GeneratorOptionTarget.vea,
|
|
149
244
|
type: exercise_1.GeneratorOptionType.select,
|
|
150
|
-
defaultValue: "
|
|
245
|
+
defaultValue: "centième",
|
|
151
246
|
values: ["dixième", "centième", "millième"],
|
|
152
247
|
},
|
|
248
|
+
{
|
|
249
|
+
id: "eventTypes",
|
|
250
|
+
label: "Types de questions",
|
|
251
|
+
target: exercise_1.GeneratorOptionTarget.generation,
|
|
252
|
+
type: exercise_1.GeneratorOptionType.multiselect,
|
|
253
|
+
defaultValue: defaultOptionValues,
|
|
254
|
+
values: optionValues,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
id: "probaType",
|
|
258
|
+
label: "Format des probabilités",
|
|
259
|
+
target: exercise_1.GeneratorOptionTarget.generation,
|
|
260
|
+
type: exercise_1.GeneratorOptionType.select,
|
|
261
|
+
defaultValue: "Fractions",
|
|
262
|
+
values: ["Fractions", "Décimales"],
|
|
263
|
+
},
|
|
153
264
|
];
|
|
154
265
|
exports.probabilityTree = {
|
|
155
266
|
id: "probabilityTree",
|
|
156
267
|
connector: "=",
|
|
157
268
|
label: "Calculs de probabilités à l'aide d'un arbre pondéré",
|
|
158
|
-
levels: [
|
|
159
|
-
"2nde",
|
|
160
|
-
"1reESM",
|
|
161
|
-
"1reSpé",
|
|
162
|
-
"1reTech",
|
|
163
|
-
"1rePro",
|
|
164
|
-
"TermPro",
|
|
165
|
-
"TermTech",
|
|
166
|
-
],
|
|
167
269
|
isSingleStep: false,
|
|
168
|
-
sections: ["Probabilités"],
|
|
169
270
|
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getProbabilityTree(opts), nb),
|
|
170
271
|
qcmTimer: 60,
|
|
171
272
|
freeTimer: 60,
|
|
@@ -174,4 +275,7 @@ exports.probabilityTree = {
|
|
|
174
275
|
hasGeogebra: true,
|
|
175
276
|
subject: "Mathématiques",
|
|
176
277
|
options,
|
|
278
|
+
rebuildIdentifiers,
|
|
279
|
+
getInstruction,
|
|
280
|
+
getAnswer,
|
|
177
281
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spaceVectorNormCalculation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;
|
|
1
|
+
{"version":3,"file":"spaceVectorNormCalculation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+FF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAkB5D,CAAC"}
|
|
@@ -10,11 +10,11 @@ const addNode_1 = require("../../../../tree/nodes/operators/addNode");
|
|
|
10
10
|
const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
|
|
11
11
|
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
12
12
|
const getHint = (identifiers) => {
|
|
13
|
-
return "
|
|
13
|
+
return "Dans un repère dans l'espace orthonormé, la norme d'un vecteur est la racine carrée de la somme des carrés de ses coordonnées.";
|
|
14
14
|
};
|
|
15
15
|
const getCorrection = ({ x, y, z }) => {
|
|
16
16
|
const answer = getAnswer({ x, y, z });
|
|
17
|
-
return `
|
|
17
|
+
return `Dans un repère de l'espace orthonormé, la norme d'un vecteur est la racine carrée de la somme des carrés de ses coordonnées. Ici, on a donc :
|
|
18
18
|
|
|
19
19
|
${(0, alignTex_1.alignTex)([
|
|
20
20
|
[
|
|
@@ -35,7 +35,11 @@ const getAnswer = (identifiers) => {
|
|
|
35
35
|
};
|
|
36
36
|
const getInstruction = (identifiers) => {
|
|
37
37
|
const u = new spaceVector_1.SpaceVector("u", identifiers.x.toTree(), identifiers.y.toTree(), identifiers.z.toTree());
|
|
38
|
-
return `
|
|
38
|
+
return `On se place dans un repère de l'espace orthonormé. Calculer la norme du vecteur :
|
|
39
|
+
|
|
40
|
+
$$
|
|
41
|
+
${u.toTexWithCoords()}
|
|
42
|
+
$$`;
|
|
39
43
|
};
|
|
40
44
|
const getSpaceVectorNormCalculationQuestion = () => {
|
|
41
45
|
const u = spaceVector_1.SpaceVectorConstructor.random("u", false);
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
type Opts = {
|
|
2
|
+
allowNonIrreductible?: boolean;
|
|
3
|
+
allowDecimal?: boolean;
|
|
4
|
+
decimalPrecision?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const rationalVEA: (studentAns: string, answer: string, { allowNonIrreductible, decimalPrecision, allowDecimal }?: Opts) => boolean;
|
|
7
|
+
export {};
|
|
2
8
|
//# sourceMappingURL=rationalVEA.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rationalVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/rationalVEA.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rationalVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/rationalVEA.ts"],"names":[],"mappings":"AAKA,KAAK,IAAI,GAAG;IACV,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AACF,eAAO,MAAM,WAAW,eACV,MAAM,UACV,MAAM,6DAC4C,IAAI,YAqC/D,CAAC"}
|
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rationalVEA = void 0;
|
|
4
|
+
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
4
5
|
const latexParser_1 = require("../../tree/parsers/latexParser");
|
|
5
6
|
const rationalParser_1 = require("../../tree/parsers/rationalParser");
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const rationalVEA = (studentAns, answer, { allowNonIrreductible, decimalPrecision, allowDecimal } = {
|
|
8
|
+
allowNonIrreductible: true,
|
|
9
|
+
decimalPrecision: undefined,
|
|
10
|
+
allowDecimal: true,
|
|
11
|
+
}) => {
|
|
12
|
+
allowDecimal = allowDecimal ?? true;
|
|
13
|
+
allowNonIrreductible = allowNonIrreductible ?? true;
|
|
14
|
+
decimalPrecision = decimalPrecision ?? undefined;
|
|
8
15
|
const parsed = (0, rationalParser_1.rationalParser)(studentAns);
|
|
9
16
|
if (!parsed)
|
|
10
17
|
return false;
|
|
11
18
|
try {
|
|
12
19
|
const parsedAnswer = (0, latexParser_1.parseAlgebraic)(answer);
|
|
13
|
-
|
|
20
|
+
if ((0, numberNode_1.isNumberNode)(parsed)) {
|
|
21
|
+
if (!allowDecimal)
|
|
22
|
+
return false;
|
|
23
|
+
if (decimalPrecision === undefined)
|
|
24
|
+
return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001);
|
|
25
|
+
else {
|
|
26
|
+
//! accepte bien les arrondis au centième par ex, mais va aussi accepter les arrondis au millième
|
|
27
|
+
//! je juge ca ok
|
|
28
|
+
return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
|
|
29
|
+
Math.pow(10, -decimalPrecision - 1));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (allowNonIrreductible) {
|
|
33
|
+
return Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
//parsed est une fraction ou opposite(frac)
|
|
37
|
+
return parsed.equals(parsedAnswer);
|
|
38
|
+
}
|
|
14
39
|
}
|
|
15
40
|
catch (err) {
|
|
16
41
|
return false;
|
package/lib/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ declare const mathExercises: (Exercise<{
|
|
|
35
35
|
}, {
|
|
36
36
|
allowNonIrreductible?: boolean | undefined;
|
|
37
37
|
}> | Exercise<{
|
|
38
|
+
isIntegerFirst: boolean;
|
|
38
39
|
integer: number;
|
|
39
40
|
rational: [number, number];
|
|
40
41
|
}, {
|
|
@@ -1327,15 +1328,17 @@ declare const mathExercises: (Exercise<{
|
|
|
1327
1328
|
nbFaces: number;
|
|
1328
1329
|
faceAsked: number;
|
|
1329
1330
|
}, {}> | Exercise<{
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1331
|
+
A: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
1332
|
+
B: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
1333
|
+
AC: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
1334
|
+
AD: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
1335
|
+
BC: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
1336
|
+
BD: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
1337
|
+
probaName: string;
|
|
1337
1338
|
}, {
|
|
1338
1339
|
allowApproximate: string;
|
|
1340
|
+
eventTypes: string[];
|
|
1341
|
+
probaType: string;
|
|
1339
1342
|
}> | Exercise<{
|
|
1340
1343
|
randomValues: number[];
|
|
1341
1344
|
randomEffectives: 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;AAG1D,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare class Complex {
|
|
|
18
18
|
times(n: number): Complex;
|
|
19
19
|
opposite(): Complex;
|
|
20
20
|
conjugate(): Complex;
|
|
21
|
-
toArgumentTree(): NumberNode | import("../../tree/nodes/numbers/constantNode").ConstantNode |
|
|
21
|
+
toArgumentTree(): NumberNode | import("../../tree/nodes/numbers/constantNode").ConstantNode | OppositeNode | FractionNode | undefined;
|
|
22
22
|
toModuleTree(): import("../../tree/nodes/algebraicNode").AlgebraicNode;
|
|
23
23
|
toTree(): ComplexNode;
|
|
24
24
|
}
|
|
@@ -28,7 +28,7 @@ export declare class Rational implements Nombre {
|
|
|
28
28
|
reverse(shouldSimplify: boolean): Nombre;
|
|
29
29
|
divide(nb: Nombre): Nombre;
|
|
30
30
|
opposite(): Rational;
|
|
31
|
-
toTree(opts?: NodeOptions):
|
|
31
|
+
toTree(opts?: NodeOptions): OppositeNode | FractionNode;
|
|
32
32
|
isIrreductible(): boolean;
|
|
33
33
|
simplify(): Integer | Rational;
|
|
34
34
|
}
|
|
@@ -13,6 +13,6 @@ export declare class ExtendedRingElement {
|
|
|
13
13
|
b: number;
|
|
14
14
|
algebraicElement: Nombre;
|
|
15
15
|
constructor(a: number, b: number, algebraicElement: Nombre);
|
|
16
|
-
toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode |
|
|
16
|
+
toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode | SubstractNode | AddNode | OppositeNode | MultiplyNode;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=extendedRingElement.d.ts.map
|
|
@@ -5,6 +5,6 @@ export declare class GeneralAffine {
|
|
|
5
5
|
variable: string;
|
|
6
6
|
constructor(a: number | AlgebraicNode, b: number | AlgebraicNode, variable?: string);
|
|
7
7
|
getRoot(): AlgebraicNode;
|
|
8
|
-
toTree(): import("../../tree/nodes/operators/
|
|
8
|
+
toTree(): import("../../tree/nodes/operators/addNode").AddNode | import("../../tree/nodes/operators/multiplyNode").MultiplyNode;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=generalAffine.d.ts.map
|
|
@@ -51,7 +51,7 @@ export declare class GeneralTrinom {
|
|
|
51
51
|
constructor(a: AlgebraicNode | number, b: AlgebraicNode | number, c: AlgebraicNode | number, opts?: GeneralTrinomOptions);
|
|
52
52
|
getDelta(): AlgebraicNode;
|
|
53
53
|
getRoots(): AlgebraicNode[];
|
|
54
|
-
toTree(): import("../../tree/nodes/operators/
|
|
54
|
+
toTree(): import("../../tree/nodes/operators/addNode").AddNode | import("../../tree/nodes/operators/multiplyNode").MultiplyNode;
|
|
55
55
|
toTex(): string;
|
|
56
56
|
getCoeffs(): number[];
|
|
57
57
|
toIdentifiers(): GeneralTrinomIdentifiers;
|
|
@@ -65,11 +65,11 @@ export declare class Trinom extends Polynomial {
|
|
|
65
65
|
getRootsNode(): AlgebraicNode[];
|
|
66
66
|
getRootsEquationSolutionTex(): string;
|
|
67
67
|
getAlpha(): number;
|
|
68
|
-
getAlphaNode(): NumberNode |
|
|
68
|
+
getAlphaNode(): NumberNode | OppositeNode | FractionNode;
|
|
69
69
|
getBeta(): number;
|
|
70
|
-
getBetaNode(): NumberNode |
|
|
70
|
+
getBetaNode(): NumberNode | OppositeNode | FractionNode;
|
|
71
71
|
getFactorizedForm(): AlgebraicNode | MultiplyNode;
|
|
72
|
-
getCanonicalForm():
|
|
72
|
+
getCanonicalForm(): AddNode | MultiplyNode;
|
|
73
73
|
getSommet(): Point;
|
|
74
74
|
getCoords(): number[];
|
|
75
75
|
toPython(): string;
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAyCA,eAAO,MAAM,UAAU,YAEtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.playground = void 0;
|
|
4
4
|
const nodeConstructor_1 = require("./tree/nodes/nodeConstructor");
|
|
5
|
+
const affineParser_1 = require("./tree/parsers/affineParser");
|
|
5
6
|
const playground = () => {
|
|
6
|
-
|
|
7
|
-
// const parsed = parseLatex("x\\times +3");
|
|
8
|
-
// console.log(parsed.toTex());
|
|
7
|
+
console.log((0, affineParser_1.affineParser)("8"));
|
|
9
8
|
};
|
|
10
9
|
exports.playground = playground;
|
|
11
10
|
const logIdentifiers = () => {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AlgebraicNode } from "./tree/nodes/algebraicNode";
|
|
2
2
|
import { NodeOptions } from "./tree/nodes/node";
|
|
3
|
+
import { ConstantNode } from "./tree/nodes/numbers/constantNode";
|
|
4
|
+
import { NumberNode } from "./tree/nodes/numbers/numberNode";
|
|
3
5
|
declare global {
|
|
4
6
|
interface Number {
|
|
5
|
-
toTree: (opts?: NodeOptions) =>
|
|
7
|
+
toTree: (opts?: NodeOptions) => NumberNode | ConstantNode;
|
|
6
8
|
frenchify: () => string;
|
|
7
9
|
toScientific: (decimals?: number) => AlgebraicNode;
|
|
8
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prototypesEnhancement.d.ts","sourceRoot":"","sources":["../src/prototypesEnhancement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAQ,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"prototypesEnhancement.d.ts","sourceRoot":"","sources":["../src/prototypesEnhancement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAQ,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAKjE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI7D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,WAAW,KAAK,UAAU,GAAG,YAAY,CAAC;QAC1D,SAAS,EAAE,MAAM,MAAM,CAAC;QACxB,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;KACpD;IACD,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,aAAa,CAAC;QAC5B,WAAW,EAAE,MAAM,MAAM,CAAC;KAC3B;CACF;AAqBD,OAAO,EAAE,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare class AbsNode implements FunctionNode {
|
|
|
18
18
|
toTex(): string;
|
|
19
19
|
toEquivalentNodes(): AlgebraicNode[];
|
|
20
20
|
toAllValidTexs(): string[];
|
|
21
|
-
simplify(): AlgebraicNode | AbsNode;
|
|
21
|
+
simplify(): AlgebraicNode | import("../numbers/numberNode").NumberNode | import("../numbers/constantNode").ConstantNode | AbsNode;
|
|
22
22
|
evaluate(vars?: Record<string, number>): number;
|
|
23
23
|
equals(node: AlgebraicNode): boolean;
|
|
24
24
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): AbsNode;
|
|
@@ -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,EAGZ,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
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,EAGZ,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASlE,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;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;IAoQ/C,aAAa;;;;;;;;;IAOb,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAUpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;CAMzD"}
|
|
@@ -14,6 +14,7 @@ const numberNode_1 = require("../numbers/numberNode");
|
|
|
14
14
|
const multiplyNode_1 = require("./multiplyNode");
|
|
15
15
|
const fractionNode_1 = require("./fractionNode");
|
|
16
16
|
const colorize_1 = require("../../../utils/latex/colorize");
|
|
17
|
+
const round_1 = require("../../../math/utils/round");
|
|
17
18
|
function isAddNode(a) {
|
|
18
19
|
return (0, operatorNode_1.isOperatorNode)(a) && a.id === operatorNode_1.OperatorIds.add;
|
|
19
20
|
}
|
|
@@ -203,7 +204,7 @@ class AddNode {
|
|
|
203
204
|
return new fractionNode_1.FractionNode(new AddNode(new oppositeNode_1.OppositeNode(c), new multiplyNode_1.MultiplyNode(d, a)), d).simplify(opts);
|
|
204
205
|
}
|
|
205
206
|
if ((0, numberNode_1.isNumberNode)(a) && (0, numberNode_1.isNumberNode)(b)) {
|
|
206
|
-
return new numberNode_1.NumberNode(a.value + b.value);
|
|
207
|
+
return new numberNode_1.NumberNode((0, round_1.round)(a.value + b.value, 12));
|
|
207
208
|
}
|
|
208
209
|
if ((0, oppositeNode_1.isOppositeNode)(a) && (0, numberNode_1.isNumberNode)(a.child) && (0, numberNode_1.isNumberNode)(b)) {
|
|
209
210
|
return new numberNode_1.NumberNode(-a.child.value + b.value);
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
3
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
|
|
4
|
+
import { NodeIdentifiers } from "../nodeConstructor";
|
|
4
5
|
export declare function isFractionNode(a: Node): a is FractionNode;
|
|
5
6
|
export declare const frac: (a: AlgebraicNode | number | string, b: AlgebraicNode | number | string, opts?: NodeOptions) => FractionNode;
|
|
7
|
+
export type FractionNodeIdentifiers = {
|
|
8
|
+
id: NodeIds.fraction;
|
|
9
|
+
leftChild: NodeIdentifiers;
|
|
10
|
+
rightChild: NodeIdentifiers;
|
|
11
|
+
};
|
|
6
12
|
export declare class FractionNode implements OperatorNode {
|
|
7
13
|
opts?: NodeOptions;
|
|
8
14
|
/**
|
|
@@ -16,18 +22,11 @@ export declare class FractionNode implements OperatorNode {
|
|
|
16
22
|
isNumeric: boolean;
|
|
17
23
|
constructor(leftChild: AlgebraicNode, rightChild: AlgebraicNode, opts?: NodeOptions);
|
|
18
24
|
toMathString(): string;
|
|
19
|
-
toIdentifiers():
|
|
20
|
-
id: NodeIds;
|
|
21
|
-
leftChild: {
|
|
22
|
-
id: NodeIds;
|
|
23
|
-
} & Record<string, any>;
|
|
24
|
-
rightChild: {
|
|
25
|
-
id: NodeIds;
|
|
26
|
-
} & Record<string, any>;
|
|
27
|
-
};
|
|
25
|
+
toIdentifiers(): FractionNodeIdentifiers;
|
|
28
26
|
toInversed(): FractionNode;
|
|
29
27
|
toEquivalentNodes(opts?: NodeOptions): AlgebraicNode[];
|
|
30
28
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
29
|
+
isDecimal(): boolean;
|
|
31
30
|
toTex(): string;
|
|
32
31
|
evaluate(vars?: Record<string, number>): number;
|
|
33
32
|
simplify(opts?: SimplifyOptions): AlgebraicNode;
|
|
@@ -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,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,IAAI,MACZ,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,iBAOnB,CAAC;AAEF,qBAAa,YAAa,YAAW,YAAY;IAC/C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAiBpB,YAAY,IAAI,MAAM;IAItB,aAAa
|
|
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,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,IAAI,MACZ,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,iBAOnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC;AACF,qBAAa,YAAa,YAAW,YAAY;IAC/C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAiBpB,YAAY,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;IAsBf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAyJ/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAOxD,sBAAsB;CAQvB"}
|
|
@@ -77,6 +77,21 @@ class FractionNode {
|
|
|
77
77
|
toAllValidTexs(opts) {
|
|
78
78
|
return this.toEquivalentNodes(opts).map((node) => node.toTex());
|
|
79
79
|
}
|
|
80
|
+
isDecimal() {
|
|
81
|
+
if (!(0, numberNode_1.isNumberNode)(this.leftChild))
|
|
82
|
+
return false;
|
|
83
|
+
if (!(0, numberNode_1.isNumberNode)(this.rightChild))
|
|
84
|
+
return false;
|
|
85
|
+
const simp = this.simplify();
|
|
86
|
+
if ((0, numberNode_1.isNumberNode)(simp))
|
|
87
|
+
return true;
|
|
88
|
+
let denum = simp.leftChild.evaluate();
|
|
89
|
+
while (denum % 2 === 0)
|
|
90
|
+
denum = denum / 2;
|
|
91
|
+
while (denum % 5 === 0)
|
|
92
|
+
denum = denum / 5;
|
|
93
|
+
return denum === 1;
|
|
94
|
+
}
|
|
80
95
|
toTex() {
|
|
81
96
|
if (!this.opts?.allowMinusAnywhereInFraction &&
|
|
82
97
|
((0, oppositeNode_1.isOppositeNode)(this.leftChild) ||
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const affineParser: (ans: string, variable?: string) => false | import("../nodes/variables/variableNode").VariableNode | Affine | undefined;
|
|
1
|
+
export declare const affineParser: (ans: string, variable?: string) => false | import("../nodes/algebraicNode").AlgebraicNode | import("../nodes/operators/substractNode").SubstractNode | import("../nodes/operators/addNode").AddNode;
|
|
3
2
|
//# sourceMappingURL=affineParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"affineParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/affineParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"affineParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/affineParser.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,QAAS,MAAM,aAAY,MAAM,qKAqBzD,CAAC"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.affineParser = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const multiplyNode_1 = require("../nodes/operators/multiplyNode");
|
|
7
|
-
const variableNode_1 = require("../nodes/variables/variableNode");
|
|
4
|
+
const addNode_1 = require("../nodes/operators/addNode");
|
|
5
|
+
const substractNode_1 = require("../nodes/operators/substractNode");
|
|
8
6
|
const latexParser_1 = require("./latexParser");
|
|
7
|
+
const monomParser_1 = require("./monomParser");
|
|
9
8
|
const affineParser = (ans, variable = "x") => {
|
|
10
9
|
try {
|
|
10
|
+
const monom = (0, monomParser_1.monomParser)(ans, { variable, maxDegree: 1 });
|
|
11
|
+
if (monom)
|
|
12
|
+
return monom;
|
|
11
13
|
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
12
|
-
if ((0,
|
|
13
|
-
|
|
14
|
+
if ((0, addNode_1.isAddNode)(parsed) || (0, substractNode_1.isSubstractNode)(parsed)) {
|
|
15
|
+
const numericChild = parsed.leftChild.isNumeric
|
|
16
|
+
? "left"
|
|
17
|
+
: parsed.rightChild.isNumeric
|
|
18
|
+
? "right"
|
|
19
|
+
: undefined;
|
|
20
|
+
if (!numericChild)
|
|
14
21
|
return false;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//!won't handle Affines à coefficients non entiers
|
|
18
|
-
if ((0, multiplyNode_1.isMultiplyNode)(parsed)) {
|
|
19
|
-
if ((0, variableNode_1.isVariableNode)(parsed.rightChild) &&
|
|
20
|
-
parsed.rightChild.name === variable &&
|
|
21
|
-
(0, numberNode_1.isNumberNode)(parsed.leftChild)) {
|
|
22
|
-
return new affine_1.Affine(parsed.leftChild.value, 0, variable);
|
|
23
|
-
}
|
|
22
|
+
const varChild = numericChild === "left" ? parsed.rightChild : parsed.leftChild;
|
|
23
|
+
return (0, monomParser_1.isMonomNode)(varChild, { variable, maxDegree: 1 }) ? parsed : false;
|
|
24
24
|
}
|
|
25
|
+
return false;
|
|
25
26
|
}
|
|
26
27
|
catch (err) {
|
|
27
28
|
return false;
|
|
28
29
|
}
|
|
29
|
-
//"x" ou a*x ou a*x+b ou x+b
|
|
30
30
|
};
|
|
31
31
|
exports.affineParser = affineParser;
|
|
@@ -3,5 +3,5 @@ import { EqualNode } from "../nodes/equations/equalNode";
|
|
|
3
3
|
import { InequationNode } from "../nodes/inequations/inequationNode";
|
|
4
4
|
export declare const tokenize: (latex: string) => string[];
|
|
5
5
|
export declare const parseAlgebraic: (latex: string) => AlgebraicNode;
|
|
6
|
-
export declare const parseLatex: (latex: string) => AlgebraicNode |
|
|
6
|
+
export declare const parseLatex: (latex: string) => AlgebraicNode | EqualNode | InequationNode;
|
|
7
7
|
//# sourceMappingURL=latexParser.d.ts.map
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { AlgebraicNode } from "../nodes/algebraicNode";
|
|
2
|
+
type Opts = {
|
|
3
|
+
variable: string;
|
|
4
|
+
maxDegree?: number;
|
|
5
|
+
minDegree?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const monomParser: (str: string, { variable, maxDegree, minDegree }?: Opts) => false | AlgebraicNode;
|
|
8
|
+
export declare const isMonomNode: (node: AlgebraicNode, { variable, maxDegree, minDegree }?: Opts) => boolean;
|
|
9
|
+
export {};
|
|
2
10
|
//# sourceMappingURL=monomParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/monomParser.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"monomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/monomParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQvD,KAAK,IAAI,GAAG;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,WAAW,QACjB,MAAM,uCACyB,IAAI,0BAkBzC,CAAC;AAEF,eAAO,MAAM,WAAW,SAChB,aAAa,uCACiB,IAAI,YAsCzC,CAAC"}
|
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.monomParser = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.isMonomNode = exports.monomParser = void 0;
|
|
4
|
+
const fractionNode_1 = require("../nodes/operators/fractionNode");
|
|
5
|
+
const multiplyNode_1 = require("../nodes/operators/multiplyNode");
|
|
6
|
+
const powerNode_1 = require("../nodes/operators/powerNode");
|
|
7
|
+
const variableNode_1 = require("../nodes/variables/variableNode");
|
|
8
|
+
const latexParser_1 = require("./latexParser");
|
|
9
|
+
const monomParser = (str, { variable, maxDegree, minDegree } = {
|
|
10
|
+
variable: "x",
|
|
11
|
+
maxDegree: undefined,
|
|
12
|
+
minDegree: 0,
|
|
13
|
+
}) => {
|
|
14
|
+
try {
|
|
15
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(str);
|
|
16
|
+
return (0, exports.isMonomNode)(parsed, { variable, maxDegree, minDegree })
|
|
17
|
+
? parsed
|
|
18
|
+
: false;
|
|
19
|
+
if ((0, fractionNode_1.isFractionNode)(parsed)) {
|
|
20
|
+
//!unimplemented
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
else
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
5
30
|
exports.monomParser = monomParser;
|
|
31
|
+
const isMonomNode = (node, { variable, maxDegree, minDegree } = {
|
|
32
|
+
variable: "x",
|
|
33
|
+
maxDegree: undefined,
|
|
34
|
+
minDegree: 0,
|
|
35
|
+
}) => {
|
|
36
|
+
variable = variable ?? "x";
|
|
37
|
+
maxDegree = maxDegree ?? undefined;
|
|
38
|
+
minDegree = minDegree ?? 0;
|
|
39
|
+
if (node.isNumeric && minDegree === 0)
|
|
40
|
+
return true;
|
|
41
|
+
if ((0, variableNode_1.isVariableNode)(node) && node.name === variable && minDegree < 2)
|
|
42
|
+
return true;
|
|
43
|
+
if ((0, multiplyNode_1.isMultiplyNode)(node)) {
|
|
44
|
+
const numericChild = node.leftChild.isNumeric
|
|
45
|
+
? "left"
|
|
46
|
+
: node.rightChild.isNumeric
|
|
47
|
+
? "right"
|
|
48
|
+
: undefined;
|
|
49
|
+
if (!numericChild)
|
|
50
|
+
return false;
|
|
51
|
+
const varChild = numericChild === "left" ? node.rightChild : node.leftChild;
|
|
52
|
+
if ((0, variableNode_1.isVariableNode)(varChild) && varChild.name === "x" && minDegree < 2)
|
|
53
|
+
return true;
|
|
54
|
+
if ((0, powerNode_1.isPowerNode)(varChild) &&
|
|
55
|
+
(0, variableNode_1.isVariableNode)(varChild.leftChild) &&
|
|
56
|
+
varChild.leftChild.name === "x" &&
|
|
57
|
+
varChild.rightChild.isNumeric) {
|
|
58
|
+
const powerEv = varChild.rightChild.evaluate();
|
|
59
|
+
if (maxDegree && powerEv > maxDegree)
|
|
60
|
+
return false;
|
|
61
|
+
if (minDegree && powerEv < minDegree)
|
|
62
|
+
return false;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
};
|
|
68
|
+
exports.isMonomNode = isMonomNode;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const powerParser: (ans: string) => false | import("../nodes/operators/
|
|
1
|
+
export declare const powerParser: (ans: string) => false | import("../nodes/operators/powerNode").PowerNode | import("../nodes/operators/fractionNode").FractionNode;
|
|
2
2
|
//# sourceMappingURL=powerParser.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* supprime les éléments superflus sans aucun calcul maths
|
|
3
|
+
* ex : transforme (2) en 2
|
|
4
|
+
* ex : transforme (9)/3 en 9/3 mais pas en 3
|
|
5
|
+
* doit-il transformer 1*x en x ?
|
|
6
|
+
* @param str réponse élève
|
|
7
|
+
*/
|
|
8
|
+
export declare const purifyLatex: (str: string) => void;
|
|
9
|
+
//# sourceMappingURL=purifyLatex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purifyLatex.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/purifyLatex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAS,MAAM,SAKtC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.purifyLatex = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* supprime les éléments superflus sans aucun calcul maths
|
|
6
|
+
* ex : transforme (2) en 2
|
|
7
|
+
* ex : transforme (9)/3 en 9/3 mais pas en 3
|
|
8
|
+
* doit-il transformer 1*x en x ?
|
|
9
|
+
* @param str réponse élève
|
|
10
|
+
*/
|
|
11
|
+
const purifyLatex = (str) => {
|
|
12
|
+
//on peut supprimer des parenthèses si :
|
|
13
|
+
//* pas suivi/précédé d'une multiplication
|
|
14
|
+
//* pas arguments d'une fonction
|
|
15
|
+
//* .. ?
|
|
16
|
+
};
|
|
17
|
+
exports.purifyLatex = purifyLatex;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FractionNode } from "../nodes/operators/fractionNode";
|
|
2
|
-
export declare const rationalParser: (ans: string) => false | import("../nodes/
|
|
2
|
+
export declare const rationalParser: (ans: string) => false | import("../nodes/numbers/numberNode").NumberNode | import("../nodes/numbers/constantNode").ConstantNode | import("../nodes/functions/oppositeNode").OppositeNode | FractionNode | undefined;
|
|
3
3
|
//# sourceMappingURL=rationalParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rationalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/rationalParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAQ,MAAM,iCAAiC,CAAC;AAGrE,eAAO,MAAM,cAAc,QAAS,MAAM
|
|
1
|
+
{"version":3,"file":"rationalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/rationalParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAQ,MAAM,iCAAiC,CAAC;AAGrE,eAAO,MAAM,cAAc,QAAS,MAAM,wMA0BzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trinomParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/trinomParser.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,QAAS,MAAM,aAAY,MAAM,sBAyBzD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trinomParser = void 0;
|
|
4
|
+
const trinomParser = (ans, variable = "x") => {
|
|
5
|
+
try {
|
|
6
|
+
//! difficile !
|
|
7
|
+
//! peut etre que je fais fausse, il faut peut etre simplifier canoniquement et checker si ca ressemble à un trinome
|
|
8
|
+
//! mais ce qui m'embete dans cette approche c'est que la simplification va etre trop "gentille", on va accepter des trucs qu'on aurait pas du ...
|
|
9
|
+
// const monom = monomParser(ans, { variable, maxDegree: 2, minDegree: 2 });
|
|
10
|
+
// if (monom) return monom;
|
|
11
|
+
// const parsed = parseAlgebraic(ans);
|
|
12
|
+
// if (isAddNode(parsed) || isSubstractNode(parsed)) {
|
|
13
|
+
// const numericChild = parsed.leftChild.isNumeric
|
|
14
|
+
// ? "left"
|
|
15
|
+
// : parsed.rightChild.isNumeric
|
|
16
|
+
// ? "right"
|
|
17
|
+
// : undefined;
|
|
18
|
+
// //si numeric : alors ax^2 + b ou ax+b
|
|
19
|
+
// //sinon : ax^2 + bx + c car monom déjà exclu
|
|
20
|
+
// if (!numericChild) return false;
|
|
21
|
+
// const varChild =
|
|
22
|
+
// numericChild === "left" ? parsed.rightChild : parsed.leftChild;
|
|
23
|
+
// return isMonomNode(varChild, { variable, maxDegree: 1 }) ? parsed : false;
|
|
24
|
+
// }
|
|
25
|
+
// return false;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.trinomParser = trinomParser;
|