math-exercises 2.0.9 → 2.0.10
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/calcul/fractions/index.d.ts +1 -0
- package/lib/exercises/calcul/fractions/index.d.ts.map +1 -1
- package/lib/exercises/calcul/fractions/index.js +1 -0
- package/lib/exercises/calcul/fractions/periodicWritingToFraction.d.ts +9 -0
- package/lib/exercises/calcul/fractions/periodicWritingToFraction.d.ts.map +1 -0
- package/lib/exercises/calcul/fractions/periodicWritingToFraction.js +80 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.js +2 -1
- package/lib/exercises/functions/logarithm/index.d.ts +1 -0
- package/lib/exercises/functions/logarithm/index.d.ts.map +1 -1
- package/lib/exercises/functions/logarithm/index.js +1 -0
- package/lib/exercises/functions/logarithm/log10Simplifying.d.ts +11 -0
- package/lib/exercises/functions/logarithm/log10Simplifying.d.ts.map +1 -0
- package/lib/exercises/functions/logarithm/log10Simplifying.js +97 -0
- package/lib/exercises/functions/logarithm/logEquation.d.ts.map +1 -1
- package/lib/exercises/functions/logarithm/logEquation.js +0 -1
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.d.ts +3 -0
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +8 -0
- package/lib/math/numbers/integer/integer.d.ts +1 -1
- package/lib/math/numbers/nombre.d.ts +1 -1
- package/lib/math/polynomials/rationalFrac.d.ts +1 -1
- package/lib/server.js +1 -0
- package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +1 -1
- package/lib/tree/nodes/operators/addNode.js +2 -2
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +0 -2
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +0 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC"}
|
|
@@ -22,3 +22,4 @@ __exportStar(require("./fractionsDivision"), exports);
|
|
|
22
22
|
__exportStar(require("./fractionsProduct"), exports);
|
|
23
23
|
__exportStar(require("./fractionsSum"), exports);
|
|
24
24
|
__exportStar(require("./simplifyFraction"), exports);
|
|
25
|
+
__exportStar(require("./periodicWritingToFraction"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MathExercise } from "../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
num: number;
|
|
4
|
+
denum: number;
|
|
5
|
+
leadingPart: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const periodicWritingToFraction: MathExercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=periodicWritingToFraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"periodicWritingToFraction.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/fractions/periodicWritingToFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AA2EF,eAAO,MAAM,yBAAyB,EAAE,YAAY,CAAC,WAAW,CAa/D,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.periodicWritingToFraction = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const decimal_1 = require("../../../math/numbers/decimals/decimal");
|
|
7
|
+
const rational_1 = require("../../../math/numbers/rationals/rational");
|
|
8
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
9
|
+
/**
|
|
10
|
+
* méthode : x = 0,123123123
|
|
11
|
+
* 1000x = 123,123123
|
|
12
|
+
* 999x = 123
|
|
13
|
+
*/
|
|
14
|
+
const getPeriodicWritingToFractionQuestion = () => {
|
|
15
|
+
const periodicPartLength = (0, randint_1.randint)(1, 4);
|
|
16
|
+
const periodicPart = [];
|
|
17
|
+
for (let i = 0; i < periodicPartLength; i++) {
|
|
18
|
+
periodicPart.push((0, randint_1.randint)(periodicPartLength === 1 ? 1 : 0, 10, periodicPart));
|
|
19
|
+
}
|
|
20
|
+
const num = Number("0." + periodicPart.join("")) * 10 ** periodicPartLength;
|
|
21
|
+
let denumString = "";
|
|
22
|
+
for (let i = 0; i < periodicPartLength; i++) {
|
|
23
|
+
denumString += "9";
|
|
24
|
+
}
|
|
25
|
+
const denum = Number(denumString);
|
|
26
|
+
const leadingPart = decimal_1.DecimalConstructor.random(0, 10, (0, randint_1.randint)(0, 3));
|
|
27
|
+
let x = leadingPart.toTree().toTex();
|
|
28
|
+
if (!x.includes(","))
|
|
29
|
+
x += ",";
|
|
30
|
+
for (let i = 0; i < 4; i++) {
|
|
31
|
+
x += periodicPart.join("");
|
|
32
|
+
}
|
|
33
|
+
x += "\\ldots";
|
|
34
|
+
const answer = new rational_1.Rational(num, denum * 10 ** leadingPart.precision)
|
|
35
|
+
.add(leadingPart.toRational())
|
|
36
|
+
.toTree()
|
|
37
|
+
.toTex();
|
|
38
|
+
const question = {
|
|
39
|
+
answer,
|
|
40
|
+
instruction: `Ecrire sous forme de fraction : $${x}$`,
|
|
41
|
+
keys: [],
|
|
42
|
+
answerFormat: "tex",
|
|
43
|
+
identifiers: { num, denum, leadingPart: leadingPart.value },
|
|
44
|
+
};
|
|
45
|
+
return question;
|
|
46
|
+
};
|
|
47
|
+
const getPropositions = (n, { answer, num, denum, leadingPart }) => {
|
|
48
|
+
const propositions = [];
|
|
49
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
50
|
+
const leadingPartDec = new decimal_1.Decimal(leadingPart);
|
|
51
|
+
const increments = [-1, 1, 2];
|
|
52
|
+
for (const i of increments) {
|
|
53
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, new rational_1.Rational(num, denum * 10 ** (leadingPartDec.precision + i))
|
|
54
|
+
.add(leadingPartDec.toRational())
|
|
55
|
+
.toTree()
|
|
56
|
+
.toTex());
|
|
57
|
+
}
|
|
58
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
59
|
+
};
|
|
60
|
+
const isAnswerValid = (ans, { denum, leadingPart, num }) => {
|
|
61
|
+
const leadingPartDec = new decimal_1.Decimal(leadingPart);
|
|
62
|
+
const answer = new rational_1.Rational(num, denum * 10 ** leadingPartDec.precision)
|
|
63
|
+
.add(leadingPartDec.toRational())
|
|
64
|
+
.toTree();
|
|
65
|
+
const texs = answer.toAllValidTexs();
|
|
66
|
+
return texs.includes(ans);
|
|
67
|
+
};
|
|
68
|
+
exports.periodicWritingToFraction = {
|
|
69
|
+
id: "periodicWritingToFraction",
|
|
70
|
+
connector: "=",
|
|
71
|
+
label: "Passer de l'écriture décimale périodique à l'écriture fractionnaire",
|
|
72
|
+
levels: ["2nde"],
|
|
73
|
+
isSingleStep: true,
|
|
74
|
+
sections: ["Fractions"],
|
|
75
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getPeriodicWritingToFractionQuestion, nb),
|
|
76
|
+
qcmTimer: 60,
|
|
77
|
+
freeTimer: 60,
|
|
78
|
+
getPropositions,
|
|
79
|
+
isAnswerValid,
|
|
80
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factoIdRmq3.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/factorisation/factoIdRmq3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;
|
|
1
|
+
{"version":3,"file":"factoIdRmq3.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/factorisation/factoIdRmq3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AA8EF,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,WAAW,CAYjD,CAAC"}
|
|
@@ -11,7 +11,8 @@ const randint_1 = require("../../../math/utils/random/randint");
|
|
|
11
11
|
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
12
12
|
const getFactoType1Question = () => {
|
|
13
13
|
const interval = new intervals_1.Interval("[[-10; 10]]").difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)]));
|
|
14
|
-
const
|
|
14
|
+
const intervalPlus = new intervals_1.Interval("[[1; 10]]");
|
|
15
|
+
const affine = affine_1.AffineConstructor.random(intervalPlus, interval);
|
|
15
16
|
const affine2 = new affine_1.Affine(affine.a, -affine.b);
|
|
16
17
|
const statementTree = affine.multiply(affine2).toTree();
|
|
17
18
|
const answerTree = new multiplyNode_1.MultiplyNode(affine.toTree(), affine2.toTree());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/logarithm/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/logarithm/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -18,3 +18,4 @@ __exportStar(require("./logEquation"), exports);
|
|
|
18
18
|
__exportStar(require("./logSimplifiying"), exports);
|
|
19
19
|
__exportStar(require("./log10PowerSimplifying"), exports);
|
|
20
20
|
__exportStar(require("./logPowerEquation"), exports);
|
|
21
|
+
__exportStar(require("./log10Simplifying"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MathExercise } from "../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
nb: number;
|
|
4
|
+
powers: number[];
|
|
5
|
+
signs: number[];
|
|
6
|
+
isLog10: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const log10SumSimplifying: MathExercise<Identifiers>;
|
|
9
|
+
export declare const logSumSimplifying: MathExercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=log10Simplifying.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log10Simplifying.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/logarithm/log10Simplifying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAalC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAsFF,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,WAAW,CAgBzD,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,WAAW,CAgBvD,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logSumSimplifying = exports.log10SumSimplifying = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
7
|
+
const log10Node_1 = require("../../../tree/nodes/functions/log10Node");
|
|
8
|
+
const logNode_1 = require("../../../tree/nodes/functions/logNode");
|
|
9
|
+
const oppositeNode_1 = require("../../../tree/nodes/functions/oppositeNode");
|
|
10
|
+
const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
|
|
11
|
+
const addNode_1 = require("../../../tree/nodes/operators/addNode");
|
|
12
|
+
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
13
|
+
const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
|
|
14
|
+
const operatorComposition_1 = require("../../../tree/utilities/operatorComposition");
|
|
15
|
+
const random_1 = require("../../../utils/random");
|
|
16
|
+
const getLog10SumSimplifyingQuestion = (opts) => {
|
|
17
|
+
const nb = (0, randint_1.randint)(2, 10);
|
|
18
|
+
const nbTerms = (0, randint_1.randint)(2, 4);
|
|
19
|
+
const powers = [];
|
|
20
|
+
const signs = [];
|
|
21
|
+
for (let i = 0; i < nbTerms; i++) {
|
|
22
|
+
const power = (0, randint_1.randint)(powers.includes(1) ? 2 : 1, 6, powers);
|
|
23
|
+
powers.push(power);
|
|
24
|
+
signs.push((0, random_1.random)([-1, 1]));
|
|
25
|
+
}
|
|
26
|
+
const nbNode = new numberNode_1.NumberNode(nb);
|
|
27
|
+
const LNode = opts?.isLog10 ? log10Node_1.Log10Node : logNode_1.LogNode;
|
|
28
|
+
const logs = powers.map((power, index) => nb ** power < 100
|
|
29
|
+
? signs[index] > 0
|
|
30
|
+
? new LNode(new numberNode_1.NumberNode(nb ** power))
|
|
31
|
+
: new oppositeNode_1.OppositeNode(new LNode(new numberNode_1.NumberNode(nb ** power)))
|
|
32
|
+
: signs[index] > 0
|
|
33
|
+
? new LNode(new powerNode_1.PowerNode(nbNode, new numberNode_1.NumberNode(power)))
|
|
34
|
+
: new oppositeNode_1.OppositeNode(new LNode(new powerNode_1.PowerNode(nbNode, new numberNode_1.NumberNode(power)))));
|
|
35
|
+
const statement = (0, operatorComposition_1.operatorComposition)(addNode_1.AddNode, logs);
|
|
36
|
+
const answer = statement.simplify();
|
|
37
|
+
const question = {
|
|
38
|
+
answer: answer.toTex(),
|
|
39
|
+
instruction: `Simplifier le plus possible l'expression suivante : $${statement.toTex()}$`,
|
|
40
|
+
keys: [opts?.isLog10 ? "log" : "ln"],
|
|
41
|
+
answerFormat: "tex",
|
|
42
|
+
identifiers: { nb, powers, signs, isLog10: opts?.isLog10 ?? false },
|
|
43
|
+
};
|
|
44
|
+
return question;
|
|
45
|
+
};
|
|
46
|
+
const getPropositions = (n, { answer, nb, isLog10 }) => {
|
|
47
|
+
const propositions = [];
|
|
48
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
49
|
+
const LNode = isLog10 ? log10Node_1.Log10Node : logNode_1.LogNode;
|
|
50
|
+
while (propositions.length < n) {
|
|
51
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode((0, randint_1.randint)(1, 10)), new LNode(new numberNode_1.NumberNode(nb)))
|
|
52
|
+
.simplify()
|
|
53
|
+
.toTex());
|
|
54
|
+
}
|
|
55
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
56
|
+
};
|
|
57
|
+
const isAnswerValid = (ans, { nb, powers, signs, isLog10 }) => {
|
|
58
|
+
const nbNode = new numberNode_1.NumberNode(nb);
|
|
59
|
+
const LNode = isLog10 ? log10Node_1.Log10Node : logNode_1.LogNode;
|
|
60
|
+
const logs = powers.map((power, index) => nb ** power < 100
|
|
61
|
+
? signs[index] > 0
|
|
62
|
+
? new LNode(new numberNode_1.NumberNode(nb ** power))
|
|
63
|
+
: new oppositeNode_1.OppositeNode(new LNode(new numberNode_1.NumberNode(nb ** power)))
|
|
64
|
+
: signs[index] > 0
|
|
65
|
+
? new LNode(new powerNode_1.PowerNode(nbNode, new numberNode_1.NumberNode(power)))
|
|
66
|
+
: new oppositeNode_1.OppositeNode(new LNode(new powerNode_1.PowerNode(nbNode, new numberNode_1.NumberNode(power)))));
|
|
67
|
+
const statement = (0, operatorComposition_1.operatorComposition)(addNode_1.AddNode, logs);
|
|
68
|
+
const answer = statement.simplify();
|
|
69
|
+
const texs = answer.toAllValidTexs();
|
|
70
|
+
return texs.includes(ans);
|
|
71
|
+
};
|
|
72
|
+
exports.log10SumSimplifying = {
|
|
73
|
+
id: "log10SumSimplifying",
|
|
74
|
+
connector: "=",
|
|
75
|
+
label: "Simplifer une somme de logarithmes décimaux",
|
|
76
|
+
levels: ["TermTech"],
|
|
77
|
+
isSingleStep: true,
|
|
78
|
+
sections: ["Logarithme décimal"],
|
|
79
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getLog10SumSimplifyingQuestion({ isLog10: true }), nb),
|
|
80
|
+
qcmTimer: 60,
|
|
81
|
+
freeTimer: 60,
|
|
82
|
+
getPropositions,
|
|
83
|
+
isAnswerValid,
|
|
84
|
+
};
|
|
85
|
+
exports.logSumSimplifying = {
|
|
86
|
+
id: "logSumSimplifying",
|
|
87
|
+
connector: "=",
|
|
88
|
+
label: "Simplifer une somme de logarithmes népériens",
|
|
89
|
+
levels: ["TermSpé", "MathComp"],
|
|
90
|
+
isSingleStep: true,
|
|
91
|
+
sections: ["Logarithme népérien"],
|
|
92
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getLog10SumSimplifyingQuestion({ isLog10: false }), nb),
|
|
93
|
+
qcmTimer: 60,
|
|
94
|
+
freeTimer: 60,
|
|
95
|
+
getPropositions,
|
|
96
|
+
isAnswerValid,
|
|
97
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logEquation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/logarithm/logEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAclC,cAAc;AACd,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;
|
|
1
|
+
{"version":3,"file":"logEquation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/logarithm/logEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAclC,cAAc;AACd,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoEF,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,WAAW,CAYjD,CAAC"}
|
|
@@ -56,7 +56,6 @@ const isAnswerValid = (ans, { a, k }) => {
|
|
|
56
56
|
new expNode_1.ExpNode(new rational_1.Rational(k, a).simplify().toTree({ allowFractionToDecimal: true })),
|
|
57
57
|
]));
|
|
58
58
|
const texs = answer.toAllValidTexs();
|
|
59
|
-
console.log(texs);
|
|
60
59
|
return texs.includes(ans);
|
|
61
60
|
};
|
|
62
61
|
exports.logEquation = {
|
package/lib/index.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ declare const mathExercises: (import("./exercises/exercise").MathExercise<{
|
|
|
35
35
|
}> | import("./exercises/exercise").MathExercise<{
|
|
36
36
|
num: number;
|
|
37
37
|
denum: number;
|
|
38
|
+
}> | import("./exercises/exercise").MathExercise<{
|
|
39
|
+
num: number;
|
|
40
|
+
denum: number;
|
|
41
|
+
leadingPart: number;
|
|
38
42
|
}> | import("./exercises/exercise").MathExercise<{
|
|
39
43
|
numbers: number[];
|
|
40
44
|
}> | import("./exercises/exercise").MathExercise<{
|
|
@@ -425,6 +429,11 @@ declare const mathExercises: (import("./exercises/exercise").MathExercise<{
|
|
|
425
429
|
c: number;
|
|
426
430
|
k: number;
|
|
427
431
|
isLog10: boolean;
|
|
432
|
+
}> | import("./exercises/exercise").MathExercise<{
|
|
433
|
+
nb: number;
|
|
434
|
+
powers: number[];
|
|
435
|
+
signs: number[];
|
|
436
|
+
isLog10: boolean;
|
|
428
437
|
}> | import("./exercises/exercise").MathExercise<{
|
|
429
438
|
coin: boolean;
|
|
430
439
|
radius: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA2B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NumberNode } from "../../../tree/nodes/numbers/numberNode";
|
|
2
2
|
import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode";
|
|
3
|
+
import { Integer } from "../integer/integer";
|
|
3
4
|
import { Nombre, NumberType } from "../nombre";
|
|
5
|
+
import { Rational } from "../rationals/rational";
|
|
4
6
|
export declare abstract class DecimalConstructor {
|
|
5
7
|
static randomFracPart(precision: number, leadingZeros?: number): string;
|
|
6
8
|
static random(min: number, max: number, precision?: number): Decimal;
|
|
@@ -24,6 +26,7 @@ export declare class Decimal implements Nombre {
|
|
|
24
26
|
multiplyByPowerOfTen(power: number): Decimal;
|
|
25
27
|
toScientificPart(): NumberNode;
|
|
26
28
|
toScientificNotation(): NumberNode | MultiplyNode;
|
|
29
|
+
toRational(): Rational | Integer;
|
|
27
30
|
toTree(): NumberNode;
|
|
28
31
|
}
|
|
29
32
|
//# sourceMappingURL=decimal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAW1E,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAK/D,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;CAMrD;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,aAAsB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;gBACR,KAAK,EAAE,MAAM;IASzB;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAsEhC,oBAAoB,CAAC,KAAK,EAAE,MAAM;IA4BlC,gBAAgB;IAgBhB,oBAAoB;IAmBpB,UAAU;IAMV,MAAM;CAGP"}
|
|
@@ -7,6 +7,7 @@ const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
|
7
7
|
const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
|
|
8
8
|
const integer_1 = require("../integer/integer");
|
|
9
9
|
const nombre_1 = require("../nombre");
|
|
10
|
+
const rational_1 = require("../rationals/rational");
|
|
10
11
|
class DecimalConstructor {
|
|
11
12
|
static randomFracPart(precision, leadingZeros = 0) {
|
|
12
13
|
let decimals = "";
|
|
@@ -27,6 +28,8 @@ class DecimalConstructor {
|
|
|
27
28
|
return DecimalConstructor.fromParts(int, decimals);
|
|
28
29
|
}
|
|
29
30
|
static fromParts(intPart, decimalPart) {
|
|
31
|
+
if (decimalPart.length === 0)
|
|
32
|
+
return new Decimal(Number("" + intPart));
|
|
30
33
|
return new Decimal(Number("" + intPart + "." + decimalPart));
|
|
31
34
|
}
|
|
32
35
|
//returns X.YYYY where X € [0, 9] and first Y is not zero if X is zero
|
|
@@ -127,6 +130,8 @@ class Decimal {
|
|
|
127
130
|
return DecimalConstructor.fromParts(newIntPart, newFracPart);
|
|
128
131
|
}
|
|
129
132
|
multiplyByPowerOfTen(power) {
|
|
133
|
+
if (power === 0)
|
|
134
|
+
return this;
|
|
130
135
|
let newIntPart = "", newFracPart = "";
|
|
131
136
|
if (power > -1) {
|
|
132
137
|
newIntPart = this.intPart + "";
|
|
@@ -180,6 +185,9 @@ class Decimal {
|
|
|
180
185
|
return new multiplyNode_1.MultiplyNode(decNode, new numberNode_1.NumberNode(10));
|
|
181
186
|
return new multiplyNode_1.MultiplyNode(decNode, new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(power)));
|
|
182
187
|
}
|
|
188
|
+
toRational() {
|
|
189
|
+
return new rational_1.Rational(this.multiplyByPowerOfTen(this.precision).value, 10 ** this.precision).simplify();
|
|
190
|
+
}
|
|
183
191
|
toTree() {
|
|
184
192
|
return new numberNode_1.NumberNode(this.value);
|
|
185
193
|
}
|
|
@@ -16,6 +16,6 @@ export declare class Integer implements Nombre {
|
|
|
16
16
|
divide(nb: Nombre): Nombre;
|
|
17
17
|
multiply(nb: Nombre): Rational | Integer;
|
|
18
18
|
opposite(): Integer;
|
|
19
|
-
add(nb: Nombre):
|
|
19
|
+
add(nb: Nombre): Integer | Nombre;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=integer.d.ts.map
|
|
@@ -14,6 +14,6 @@ export interface Nombre {
|
|
|
14
14
|
toTree: (opts?: NodeOptions) => AlgebraicNode;
|
|
15
15
|
}
|
|
16
16
|
export declare abstract class NombreConstructor {
|
|
17
|
-
static random(): import("./
|
|
17
|
+
static random(): import("./rationals/rational").Rational | Integer | import("./decimals/decimal").Decimal | import("./reals/real").Real;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=nombre.d.ts.map
|
|
@@ -7,6 +7,6 @@ export declare class RationalFrac {
|
|
|
7
7
|
denum: Polynomial;
|
|
8
8
|
constructor(num: Polynomial, denum: Polynomial);
|
|
9
9
|
toTree(): FractionNode;
|
|
10
|
-
simplify():
|
|
10
|
+
simplify(): Rational | Integer | RationalFrac;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=rationalFrac.d.ts.map
|
package/lib/server.js
CHANGED
|
@@ -42,6 +42,7 @@ const runServer = () => {
|
|
|
42
42
|
const app = (0, express_1.default)();
|
|
43
43
|
app.use((0, cors_1.default)());
|
|
44
44
|
console.log(exercises.length + " exercices");
|
|
45
|
+
console.log(exercises.filter((exo) => exo.isSingleStep).length);
|
|
45
46
|
app.get("/", (req, res) => {
|
|
46
47
|
res.json(allExercises);
|
|
47
48
|
});
|
|
@@ -19,7 +19,7 @@ export declare class OppositeNode implements FunctionNode {
|
|
|
19
19
|
*/
|
|
20
20
|
toAllValidTexs(opts?: NodeOptions): string[];
|
|
21
21
|
evaluate(vars: Record<string, number>): number;
|
|
22
|
-
simplify():
|
|
22
|
+
simplify(): OppositeNode;
|
|
23
23
|
equals(node: AlgebraicNode): boolean;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=oppositeNode.d.ts.map
|
|
@@ -207,12 +207,12 @@ class AddNode {
|
|
|
207
207
|
? new numberNode_1.NumberNode(1)
|
|
208
208
|
: aSubExternals.length === 1
|
|
209
209
|
? aSubExternals[0]
|
|
210
|
-
: (0, operatorComposition_1.operatorComposition)(
|
|
210
|
+
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, aSubExternals);
|
|
211
211
|
const bNode = bSubExternals.length === 0
|
|
212
212
|
? new numberNode_1.NumberNode(1)
|
|
213
213
|
: bSubExternals.length === 1
|
|
214
214
|
? bSubExternals[0]
|
|
215
|
-
: (0, operatorComposition_1.operatorComposition)(
|
|
215
|
+
: (0, operatorComposition_1.operatorComposition)(multiplyNode_1.MultiplyNode, bSubExternals);
|
|
216
216
|
const addNode = new AddNode(aNode, bNode);
|
|
217
217
|
return new multiplyNode_1.MultiplyNode(addNode, factorsNode).simplify();
|
|
218
218
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK3E,OAAO,EAAE,aAAa,EAAE,MAAM,kB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IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAItB,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA2BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,KAAK,IAAI,MAAM;IAaf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,IAAI,aAAa;IA2EzB,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
|
|
@@ -102,7 +102,6 @@ class FractionNode {
|
|
|
102
102
|
const simplifyExternalNodes = (num, denum) => {
|
|
103
103
|
if ((0, numberNode_1.isNumberNode)(num) && (0, numberNode_1.isNumberNode)(denum)) {
|
|
104
104
|
const frac = new rational_1.Rational(num.value, denum.value);
|
|
105
|
-
console.log(frac.isIrreductible());
|
|
106
105
|
if (frac.isIrreductible())
|
|
107
106
|
return null;
|
|
108
107
|
return frac.simplify().toTree();
|
|
@@ -113,7 +112,6 @@ class FractionNode {
|
|
|
113
112
|
return new numberNode_1.NumberNode(1);
|
|
114
113
|
return null;
|
|
115
114
|
};
|
|
116
|
-
console.log(externalsNums, externalsDenums);
|
|
117
115
|
const simplifyIteration = () => {
|
|
118
116
|
for (let i = 0; i < externalsNums.length; i++) {
|
|
119
117
|
const num = externalsNums[i];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,uBAAuB,EACvB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EAAE,aAAa,E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;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,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAkDf,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAwFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAQ5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIrC,IAAI;IAGJ,QAAQ,IAAI,aAAa;IAoGzB,MAAM,CAAC,IAAI,EAAE,aAAa;CAU3B"}
|
|
@@ -262,7 +262,6 @@ class MultiplyNode {
|
|
|
262
262
|
return new fractionNode_1.FractionNode(numNode, denumNode).simplify();
|
|
263
263
|
}
|
|
264
264
|
(0, exports.sortMultiplyNodes)(externals);
|
|
265
|
-
console.log(externals.map((n) => n.toTex()));
|
|
266
265
|
const simplifyExternalNodes = (a, b) => {
|
|
267
266
|
if ((0, numberNode_1.isNumberNode)(a) && (0, numberNode_1.isNumberNode)(b)) {
|
|
268
267
|
return new numberNode_1.NumberNode(a.value * b.value);
|