math-exercises 1.3.11 → 1.3.13
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/README.md +73 -73
- package/lib/exercises/calcul/addAndSub.d.ts +6 -6
- package/lib/exercises/calcul/addAndSub.js +39 -39
- package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.d.ts +3 -3
- package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.js +35 -35
- package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.d.ts +3 -3
- package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.js +32 -32
- package/lib/exercises/calcul/fractions/fractionAndIntegerSum.d.ts +3 -3
- package/lib/exercises/calcul/fractions/fractionAndIntegerSum.js +32 -32
- package/lib/exercises/calcul/fractions/fractionsDivision.d.ts +3 -3
- package/lib/exercises/calcul/fractions/fractionsDivision.js +29 -29
- package/lib/exercises/calcul/fractions/fractionsProduct.d.ts +3 -3
- package/lib/exercises/calcul/fractions/fractionsProduct.js +28 -28
- package/lib/exercises/calcul/fractions/fractionsSum.d.ts +3 -3
- package/lib/exercises/calcul/fractions/fractionsSum.js +28 -28
- package/lib/exercises/calcul/fractions/simplifyFraction.d.ts +3 -3
- package/lib/exercises/calcul/fractions/simplifyFraction.js +24 -24
- package/lib/exercises/calcul/operations/operationsPriorities.d.ts +10 -10
- package/lib/exercises/calcul/operations/operationsPriorities.js +98 -98
- package/lib/exercises/calcul/operations/operationsPrioritiesWithoutRelative.js +111 -111
- package/lib/exercises/calcul/operationsPriorities.js +88 -88
- package/lib/exercises/calcul/rounding/rounding.d.ts +19 -19
- package/lib/exercises/calcul/rounding/rounding.js +85 -85
- package/lib/exercises/calculLitteral/distributivity/allIdentities.d.ts +3 -3
- package/lib/exercises/calculLitteral/distributivity/allIdentities.js +27 -27
- package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.d.ts +3 -3
- package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.js +30 -30
- package/lib/exercises/calculLitteral/distributivity/firstIdentity.d.ts +3 -3
- package/lib/exercises/calculLitteral/distributivity/firstIdentity.js +31 -31
- package/lib/exercises/calculLitteral/distributivity/secondIdentity.d.ts +3 -3
- package/lib/exercises/calculLitteral/distributivity/secondIdentity.js +32 -32
- package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.d.ts +3 -3
- package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.js +32 -32
- package/lib/exercises/calculLitteral/distributivity/thirdIdentity.d.ts +3 -3
- package/lib/exercises/calculLitteral/distributivity/thirdIdentity.js +31 -31
- package/lib/exercises/calculLitteral/equation/equationType1Exercise.d.ts +6 -6
- package/lib/exercises/calculLitteral/equation/equationType1Exercise.js +37 -37
- package/lib/exercises/calculLitteral/equation/equationType2Exercise.d.ts +6 -6
- package/lib/exercises/calculLitteral/equation/equationType2Exercise.js +40 -40
- package/lib/exercises/calculLitteral/equation/equationType3Exercise.d.ts +6 -6
- package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +41 -41
- package/lib/exercises/calculLitteral/equation/equationType4Exercise.d.ts +6 -6
- package/lib/exercises/calculLitteral/equation/equationType4Exercise.js +43 -43
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq1.d.ts +4 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq1.js +32 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq2.d.ts +4 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq2.js +33 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.d.ts +4 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -0
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq3.js +32 -0
- package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.d.ts +6 -6
- package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.js +38 -38
- package/lib/exercises/derivation/derivative/affineDerivative.d.ts +4 -0
- package/lib/exercises/derivation/derivative/affineDerivative.d.ts.map +1 -0
- package/lib/exercises/derivation/derivative/affineDerivative.js +27 -0
- package/lib/exercises/derivation/derivative/secondDegreeDerivative.d.ts +1 -0
- package/lib/exercises/derivation/derivative/secondDegreeDerivative.d.ts.map +1 -0
- package/lib/exercises/derivation/derivative/secondDegreeDerivative.js +28 -0
- package/lib/exercises/derivation/derivative/thridDegreeDerivative.d.ts +1 -0
- package/lib/exercises/derivation/derivative/thridDegreeDerivative.d.ts.map +1 -0
- package/lib/exercises/derivation/derivative/thridDegreeDerivative.js +1 -0
- package/lib/exercises/exercise.d.ts +16 -16
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/exercise.js +7 -7
- package/lib/exercises/exercises.d.ts +1 -1
- package/lib/exercises/exercises.d.ts.map +1 -1
- package/lib/exercises/exercises.js +113 -107
- package/lib/exercises/geometry/cartesian/midpoint.d.ts +3 -3
- package/lib/exercises/geometry/cartesian/midpoint.js +29 -29
- package/lib/exercises/geometry/vectors/scalarProductViaCoords.d.ts +3 -3
- package/lib/exercises/geometry/vectors/scalarProductViaCoords.js +28 -28
- package/lib/exercises/geometry/vectors/scalarProductViaNorms.js +27 -27
- package/lib/exercises/powers/powersDivision.d.ts +7 -7
- package/lib/exercises/powers/powersDivision.js +44 -44
- package/lib/exercises/powers/powersOfTenToDecimal.d.ts +6 -6
- package/lib/exercises/powers/powersOfTenToDecimal.js +32 -32
- package/lib/exercises/powers/powersPower.d.ts +7 -7
- package/lib/exercises/powers/powersPower.js +43 -43
- package/lib/exercises/powers/powersProduct.d.ts +7 -7
- package/lib/exercises/powers/powersProduct.js +44 -44
- package/lib/exercises/powers/scientificToDecimal.d.ts +6 -6
- package/lib/exercises/powers/scientificToDecimal.js +37 -37
- package/lib/exercises/sequences/geometric/geometricExplicitFormulaUsage.d.ts +3 -3
- package/lib/exercises/sequences/geometric/geometricExplicitFormulaUsage.js +34 -34
- package/lib/exercises/sequences/geometric/geometricFindExplicitFormula.d.ts +3 -3
- package/lib/exercises/sequences/geometric/geometricFindExplicitFormula.js +33 -33
- package/lib/exercises/sequences/geometric/geometricFindReason.d.ts +3 -3
- package/lib/exercises/sequences/geometric/geometricFindReason.js +29 -29
- package/lib/exercises/sequences/geometric/geometricReasonUsage.d.ts +3 -3
- package/lib/exercises/sequences/geometric/geometricReasonUsage.js +28 -28
- package/lib/exercises/sequences/geometric/geometricRecurrenceFormulaUsage.d.ts +7 -7
- package/lib/exercises/sequences/geometric/geometricRecurrenceFormulaUsage.js +28 -28
- package/lib/exercises/squareRoots/simpifySquareRoot.d.ts +3 -3
- package/lib/exercises/squareRoots/simpifySquareRoot.js +27 -27
- package/lib/exercises/trigonometry/mainRemarkableValues.d.ts +3 -3
- package/lib/exercises/trigonometry/mainRemarkableValues.js +28 -28
- package/lib/exercises/trigonometry/remarkableValues.d.ts +3 -3
- package/lib/exercises/trigonometry/remarkableValues.js +28 -28
- package/lib/exercises/utils/getDistinctQuestions.d.ts +2 -2
- package/lib/exercises/utils/getDistinctQuestions.js +15 -15
- package/lib/geometry/point.js +27 -27
- package/lib/geometry/vector.js +31 -31
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +39 -6
- package/lib/math/geometry/point.d.ts +12 -12
- package/lib/math/geometry/point.js +27 -27
- package/lib/math/geometry/vector.d.ts +15 -15
- package/lib/math/geometry/vector.js +31 -31
- package/lib/math/numbers/decimals/decimal.d.ts +24 -24
- package/lib/math/numbers/decimals/decimal.js +140 -140
- package/lib/math/numbers/epsilon.d.ts +1 -1
- package/lib/math/numbers/epsilon.js +10 -10
- package/lib/math/numbers/integer/integer.d.ts +14 -14
- package/lib/math/numbers/integer/integer.js +68 -68
- package/lib/math/numbers/integer/power.d.ts +13 -13
- package/lib/math/numbers/integer/power.js +52 -52
- package/lib/math/numbers/nombre.d.ts +13 -13
- package/lib/math/numbers/nombre.js +10 -10
- package/lib/math/numbers/rationals/rational.d.ts +25 -25
- package/lib/math/numbers/rationals/rational.js +113 -113
- package/lib/math/numbers/reals/real.d.ts +9 -9
- package/lib/math/numbers/reals/real.js +16 -16
- package/lib/math/numbers/reals/squareRoot.d.ts +18 -18
- package/lib/math/numbers/reals/squareRoot.js +63 -63
- package/lib/math/polynomials/affine.d.ts +15 -15
- package/lib/math/polynomials/affine.js +42 -42
- package/lib/math/polynomials/polynomial.d.ts +25 -24
- package/lib/math/polynomials/polynomial.d.ts.map +1 -1
- package/lib/math/polynomials/polynomial.js +129 -125
- package/lib/math/sequences/arithmeticSequence.js +1 -1
- package/lib/math/sequences/geometricSequence.d.ts +3 -3
- package/lib/math/sequences/geometricSequence.js +8 -8
- package/lib/math/sequences/sequence.d.ts +22 -22
- package/lib/math/sequences/sequence.js +21 -21
- package/lib/math/sets/discreteSet.d.ts +10 -10
- package/lib/math/sets/discreteSet.js +28 -28
- package/lib/math/sets/emptySet.js +6 -6
- package/lib/math/sets/intervals/intervals.d.ts +26 -26
- package/lib/math/sets/intervals/intervals.js +104 -104
- package/lib/math/sets/mathSet.d.ts +7 -7
- package/lib/math/sets/mathSet.js +10 -10
- package/lib/math/sets/mathSetInterface.d.ts +5 -5
- package/lib/math/sets/mathSetInterface.js +2 -2
- package/lib/math/trigonometry/remarkableValue.d.ts +10 -10
- package/lib/math/trigonometry/remarkableValue.js +29 -29
- package/lib/math/trigonometry/remarkableValues.d.ts +2 -2
- package/lib/math/trigonometry/remarkableValues.js +51 -51
- package/lib/math/utils/arithmetic/coprimesOf.d.ts +1 -1
- package/lib/math/utils/arithmetic/coprimesOf.js +13 -13
- package/lib/math/utils/arithmetic/dividersOf.d.ts +1 -1
- package/lib/math/utils/arithmetic/dividersOf.js +12 -12
- package/lib/math/utils/arithmetic/gcd.d.ts +1 -1
- package/lib/math/utils/arithmetic/gcd.js +7 -7
- package/lib/math/utils/arithmetic/isSquare.d.ts +1 -1
- package/lib/math/utils/arithmetic/isSquare.js +7 -7
- package/lib/math/utils/arithmetic/lcd.d.ts +1 -1
- package/lib/math/utils/arithmetic/lcd.js +12 -12
- package/lib/math/utils/arithmetic/nonCoprimesOf.d.ts +1 -1
- package/lib/math/utils/arithmetic/nonCoprimesOf.js +13 -13
- package/lib/math/utils/arithmetic/nonDividersOf.d.ts +1 -1
- package/lib/math/utils/arithmetic/nonDividersOf.js +14 -14
- package/lib/math/utils/arithmetic/primeFactors.d.ts +5 -5
- package/lib/math/utils/arithmetic/primeFactors.js +22 -22
- package/lib/math/utils/decimals/decimalPartLengthOf.d.ts +1 -1
- package/lib/math/utils/decimals/decimalPartLengthOf.js +14 -14
- package/lib/math/utils/random/randTupleInt.d.ts +13 -13
- package/lib/math/utils/random/randTupleInt.js +30 -30
- package/lib/math/utils/random/randint.d.ts +4 -4
- package/lib/math/utils/random/randint.js +18 -18
- package/lib/math/utils/round.d.ts +1 -1
- package/lib/math/utils/round.js +8 -8
- package/lib/mathutils/arithmetic/coprimesOf.js +13 -13
- package/lib/mathutils/arithmetic/dividersOf.js +12 -12
- package/lib/mathutils/arithmetic/gcd.js +7 -7
- package/lib/mathutils/arithmetic/isSquare.js +7 -7
- package/lib/mathutils/arithmetic/lcd.js +12 -12
- package/lib/mathutils/arithmetic/nonCoprimesOf.js +13 -13
- package/lib/mathutils/arithmetic/nonDividersOf.js +14 -14
- package/lib/mathutils/arithmetic/primeFactors.js +22 -22
- package/lib/mathutils/decimals/decimalPartLengthOf.js +14 -14
- package/lib/mathutils/random/randTupleInt.js +30 -30
- package/lib/mathutils/random/randint.js +18 -18
- package/lib/mathutils/round.js +8 -8
- package/lib/numbers/decimals/decimal.js +140 -140
- package/lib/numbers/epsilon.js +10 -10
- package/lib/numbers/integer/integer.js +68 -68
- package/lib/numbers/integer/power.js +52 -52
- package/lib/numbers/nombre.js +10 -10
- package/lib/numbers/rationals/rational.js +113 -113
- package/lib/numbers/reals/real.js +16 -16
- package/lib/numbers/reals/squareRoot.js +63 -63
- package/lib/polynomials/affine.js +42 -42
- package/lib/polynomials/polynomial.js +125 -125
- package/lib/server.d.ts +2 -0
- package/lib/server.d.ts.map +1 -0
- package/lib/server.js +33 -0
- package/lib/sets/discreteSet.js +28 -28
- package/lib/sets/emptySet.js +6 -6
- package/lib/sets/intervals/intervals.js +108 -104
- package/lib/sets/intervals/union.js +1 -1
- package/lib/sets/mathSet.js +10 -10
- package/lib/sets/mathSetInterface.js +2 -2
- package/lib/tree/nodes/functions/cosNode.d.ts +9 -9
- package/lib/tree/nodes/functions/cosNode.js +21 -21
- package/lib/tree/nodes/functions/functionNode.d.ts +14 -14
- package/lib/tree/nodes/functions/functionNode.js +20 -20
- package/lib/tree/nodes/functions/oppositeNode.d.ts +7 -7
- package/lib/tree/nodes/functions/oppositeNode.js +26 -26
- package/lib/tree/nodes/functions/sinNode.js +1 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts +8 -8
- package/lib/tree/nodes/functions/sqrtNode.js +18 -18
- package/lib/tree/nodes/node.d.ts +12 -12
- package/lib/tree/nodes/node.js +11 -11
- package/lib/tree/nodes/numbers/constantNode.d.ts +9 -9
- package/lib/tree/nodes/numbers/constantNode.js +18 -18
- package/lib/tree/nodes/numbers/numberNode.d.ts +10 -10
- package/lib/tree/nodes/numbers/numberNode.js +19 -19
- package/lib/tree/nodes/numbers/piNode.d.ts +2 -2
- package/lib/tree/nodes/numbers/piNode.js +5 -5
- package/lib/tree/nodes/operators/addNode.d.ts +7 -7
- package/lib/tree/nodes/operators/addNode.js +19 -19
- package/lib/tree/nodes/operators/divideNode.d.ts +11 -11
- package/lib/tree/nodes/operators/divideNode.js +34 -34
- package/lib/tree/nodes/operators/equalNode.d.ts +7 -7
- package/lib/tree/nodes/operators/equalNode.js +16 -16
- package/lib/tree/nodes/operators/fractionNode.d.ts +11 -11
- package/lib/tree/nodes/operators/fractionNode.js +20 -20
- package/lib/tree/nodes/operators/multiplyNode.d.ts +7 -7
- package/lib/tree/nodes/operators/multiplyNode.js +43 -43
- package/lib/tree/nodes/operators/operatorNode.d.ts +21 -21
- package/lib/tree/nodes/operators/operatorNode.js +35 -35
- package/lib/tree/nodes/operators/powerNode.d.ts +7 -7
- package/lib/tree/nodes/operators/powerNode.js +33 -33
- package/lib/tree/nodes/operators/substractNode.d.ts +7 -7
- package/lib/tree/nodes/operators/substractNode.js +24 -24
- package/lib/tree/nodes/variables/variableNode.d.ts +8 -8
- package/lib/tree/nodes/variables/variableNode.js +19 -19
- package/lib/tree/parsers/derivateParser.js +62 -62
- package/lib/tree/parsers/latexParser.js +110 -110
- package/lib/tree/parsers/simplify.d.ts +2 -2
- package/lib/tree/parsers/simplify.js +52 -52
- package/lib/utils/arrayEqual.d.ts +1 -1
- package/lib/utils/arrayEqual.js +13 -13
- package/lib/utils/coin.js +7 -7
- package/lib/utils/coinFlip.d.ts +1 -1
- package/lib/utils/coinFlip.js +7 -7
- package/lib/utils/random.d.ts +1 -1
- package/lib/utils/random.js +7 -7
- package/lib/utils/shuffle.d.ts +1 -1
- package/lib/utils/shuffle.js +15 -15
- package/package.json +50 -45
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq.d.ts +0 -7
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq.d.ts.map +0 -1
- package/lib/exercises/calculLitteral/factorisation/factoIdRmq.js +0 -38
- package/lib/trigonometry/remarkableValue.js +0 -29
- package/lib/trigonometry/remarkableValues.js +0 -51
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { FunctionNode, FunctionsIds } from "../nodes/functions/functionNode";
|
|
3
|
-
// import { Node, NodeType } from "../nodes/node";
|
|
4
|
-
// import { OperatorIds, OperatorNode } from "../nodes/operators/operatorNode";
|
|
5
|
-
// export function latexParser(node: Node): string {
|
|
6
|
-
// if (!node) {
|
|
7
|
-
// console.log("parsing a null node ???");
|
|
8
|
-
// return "";
|
|
9
|
-
// }
|
|
10
|
-
// switch (node.type) {
|
|
11
|
-
// case NodeType.variable:
|
|
12
|
-
// return node.tex;
|
|
13
|
-
// case NodeType.number:
|
|
14
|
-
// return node.tex;
|
|
15
|
-
// case NodeType.operator:
|
|
16
|
-
// const operatorNode = node as OperatorNode;
|
|
17
|
-
// let rightTex = latexParser(operatorNode.rightChild);
|
|
18
|
-
// let leftTex = latexParser(operatorNode.leftChild);
|
|
19
|
-
// const { leftChild, rightChild } = operatorNode;
|
|
20
|
-
// switch (operatorNode.id) {
|
|
21
|
-
// case OperatorIds.add:
|
|
22
|
-
// return `${leftTex} ${rightTex[0] === "-" ? "" : "+ "}${rightTex}`;
|
|
23
|
-
// case OperatorIds.substract: {
|
|
24
|
-
// const needBrackets =
|
|
25
|
-
// (rightChild.type === NodeType.operator &&
|
|
26
|
-
// [OperatorIds.add, OperatorIds.substract].includes((rightChild as OperatorNode).id)) ||
|
|
27
|
-
// rightTex[0] === "-";
|
|
28
|
-
// if (needBrackets) rightTex = `(${rightTex})`;
|
|
29
|
-
// return `${leftTex} - ${rightTex}`;
|
|
30
|
-
// }
|
|
31
|
-
// case OperatorIds.multiply: {
|
|
32
|
-
// if (leftChild.type === NodeType.operator) {
|
|
33
|
-
// if ([OperatorIds.add, OperatorIds.substract, OperatorIds.divide].includes((leftChild as OperatorNode).id))
|
|
34
|
-
// leftTex = `(${leftTex})`;
|
|
35
|
-
// }
|
|
36
|
-
// let needBrackets = rightTex[0] === "-";
|
|
37
|
-
// if (rightChild.type === NodeType.operator) {
|
|
38
|
-
// const operatorRightChild = rightChild as OperatorNode;
|
|
39
|
-
// needBrackets ||= [OperatorIds.add, OperatorIds.substract].includes(operatorRightChild.id);
|
|
40
|
-
// }
|
|
41
|
-
// if (needBrackets) rightTex = `(${rightTex})`;
|
|
42
|
-
// // permet de gérer le cas 3*2^x
|
|
43
|
-
// let showTimesSign = !isNaN(+rightTex[0]) || rightChild.type === NodeType.number;
|
|
44
|
-
// if (rightChild.type === NodeType.operator) {
|
|
45
|
-
// const operatorRightChild = rightChild as OperatorNode;
|
|
46
|
-
// showTimesSign ||= [OperatorIds.fraction].includes(operatorRightChild.id);
|
|
47
|
-
// }
|
|
48
|
-
// return `${leftTex}${showTimesSign ? "\\times " : ""}${rightTex}`;
|
|
49
|
-
// }
|
|
50
|
-
// case OperatorIds.divide: {
|
|
51
|
-
// if (leftChild.type === NodeType.operator) {
|
|
52
|
-
// if ([OperatorIds.add, OperatorIds.substract, OperatorIds.multiply].includes((leftChild as OperatorNode).id))
|
|
53
|
-
// leftTex = `(${leftTex})`;
|
|
54
|
-
// }
|
|
55
|
-
// let needBrackets = rightTex[0] === "-";
|
|
56
|
-
// if (rightChild.type === NodeType.operator) {
|
|
57
|
-
// const operatorRightChild = rightChild as OperatorNode;
|
|
58
|
-
// needBrackets ||= [OperatorIds.add, OperatorIds.substract].includes(operatorRightChild.id);
|
|
59
|
-
// }
|
|
60
|
-
// if (needBrackets) rightTex = `(${rightTex})`;
|
|
61
|
-
// return `${leftTex} \\div ${rightTex}`;
|
|
62
|
-
// }
|
|
63
|
-
// case OperatorIds.fraction: {
|
|
64
|
-
// return `\\frac{${leftTex}}{${rightTex}}`;
|
|
65
|
-
// }
|
|
66
|
-
// case OperatorIds.power: {
|
|
67
|
-
// let needBrackets = leftTex[0] === "-";
|
|
68
|
-
// if (leftChild.type === NodeType.operator) {
|
|
69
|
-
// const childOperator = leftChild as OperatorNode;
|
|
70
|
-
// needBrackets ||= [
|
|
71
|
-
// OperatorIds.add,
|
|
72
|
-
// OperatorIds.substract,
|
|
73
|
-
// OperatorIds.multiply,
|
|
74
|
-
// OperatorIds.divide,
|
|
75
|
-
// OperatorIds.fraction,
|
|
76
|
-
// OperatorIds.power,
|
|
77
|
-
// ].includes(childOperator.id);
|
|
78
|
-
// }
|
|
79
|
-
// if (needBrackets) leftTex = `(${leftTex})`;
|
|
80
|
-
// return `${leftTex}^{${rightTex}}`;
|
|
81
|
-
// }
|
|
82
|
-
// case OperatorIds.equal: {
|
|
83
|
-
// return `${leftTex} = ${rightTex}`;
|
|
84
|
-
// }
|
|
85
|
-
// default:
|
|
86
|
-
// return node.tex;
|
|
87
|
-
// }
|
|
88
|
-
// case NodeType.function: {
|
|
89
|
-
// const functionNode = node as FunctionNode;
|
|
90
|
-
// const child = functionNode.child;
|
|
91
|
-
// let childTex = latexParser(functionNode.child);
|
|
92
|
-
// switch (functionNode.id) {
|
|
93
|
-
// case FunctionsIds.sqrt: {
|
|
94
|
-
// return `\\sqrt{${childTex}}`;
|
|
95
|
-
// }
|
|
96
|
-
// case FunctionsIds.opposite: {
|
|
97
|
-
// let needBrackets = childTex[0] === "-";
|
|
98
|
-
// if (child.type === NodeType.operator) {
|
|
99
|
-
// const operatorChild = child as OperatorNode;
|
|
100
|
-
// needBrackets ||= [OperatorIds.add, OperatorIds.substract].includes(operatorChild.id);
|
|
101
|
-
// }
|
|
102
|
-
// if (needBrackets) childTex = `(${childTex})`;
|
|
103
|
-
// return `-${childTex}`;
|
|
104
|
-
// }
|
|
105
|
-
// }
|
|
106
|
-
// }
|
|
107
|
-
// default:
|
|
108
|
-
// return "";
|
|
109
|
-
// }
|
|
110
|
-
// }
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { FunctionNode, FunctionsIds } from "../nodes/functions/functionNode";
|
|
3
|
+
// import { Node, NodeType } from "../nodes/node";
|
|
4
|
+
// import { OperatorIds, OperatorNode } from "../nodes/operators/operatorNode";
|
|
5
|
+
// export function latexParser(node: Node): string {
|
|
6
|
+
// if (!node) {
|
|
7
|
+
// console.log("parsing a null node ???");
|
|
8
|
+
// return "";
|
|
9
|
+
// }
|
|
10
|
+
// switch (node.type) {
|
|
11
|
+
// case NodeType.variable:
|
|
12
|
+
// return node.tex;
|
|
13
|
+
// case NodeType.number:
|
|
14
|
+
// return node.tex;
|
|
15
|
+
// case NodeType.operator:
|
|
16
|
+
// const operatorNode = node as OperatorNode;
|
|
17
|
+
// let rightTex = latexParser(operatorNode.rightChild);
|
|
18
|
+
// let leftTex = latexParser(operatorNode.leftChild);
|
|
19
|
+
// const { leftChild, rightChild } = operatorNode;
|
|
20
|
+
// switch (operatorNode.id) {
|
|
21
|
+
// case OperatorIds.add:
|
|
22
|
+
// return `${leftTex} ${rightTex[0] === "-" ? "" : "+ "}${rightTex}`;
|
|
23
|
+
// case OperatorIds.substract: {
|
|
24
|
+
// const needBrackets =
|
|
25
|
+
// (rightChild.type === NodeType.operator &&
|
|
26
|
+
// [OperatorIds.add, OperatorIds.substract].includes((rightChild as OperatorNode).id)) ||
|
|
27
|
+
// rightTex[0] === "-";
|
|
28
|
+
// if (needBrackets) rightTex = `(${rightTex})`;
|
|
29
|
+
// return `${leftTex} - ${rightTex}`;
|
|
30
|
+
// }
|
|
31
|
+
// case OperatorIds.multiply: {
|
|
32
|
+
// if (leftChild.type === NodeType.operator) {
|
|
33
|
+
// if ([OperatorIds.add, OperatorIds.substract, OperatorIds.divide].includes((leftChild as OperatorNode).id))
|
|
34
|
+
// leftTex = `(${leftTex})`;
|
|
35
|
+
// }
|
|
36
|
+
// let needBrackets = rightTex[0] === "-";
|
|
37
|
+
// if (rightChild.type === NodeType.operator) {
|
|
38
|
+
// const operatorRightChild = rightChild as OperatorNode;
|
|
39
|
+
// needBrackets ||= [OperatorIds.add, OperatorIds.substract].includes(operatorRightChild.id);
|
|
40
|
+
// }
|
|
41
|
+
// if (needBrackets) rightTex = `(${rightTex})`;
|
|
42
|
+
// // permet de gérer le cas 3*2^x
|
|
43
|
+
// let showTimesSign = !isNaN(+rightTex[0]) || rightChild.type === NodeType.number;
|
|
44
|
+
// if (rightChild.type === NodeType.operator) {
|
|
45
|
+
// const operatorRightChild = rightChild as OperatorNode;
|
|
46
|
+
// showTimesSign ||= [OperatorIds.fraction].includes(operatorRightChild.id);
|
|
47
|
+
// }
|
|
48
|
+
// return `${leftTex}${showTimesSign ? "\\times " : ""}${rightTex}`;
|
|
49
|
+
// }
|
|
50
|
+
// case OperatorIds.divide: {
|
|
51
|
+
// if (leftChild.type === NodeType.operator) {
|
|
52
|
+
// if ([OperatorIds.add, OperatorIds.substract, OperatorIds.multiply].includes((leftChild as OperatorNode).id))
|
|
53
|
+
// leftTex = `(${leftTex})`;
|
|
54
|
+
// }
|
|
55
|
+
// let needBrackets = rightTex[0] === "-";
|
|
56
|
+
// if (rightChild.type === NodeType.operator) {
|
|
57
|
+
// const operatorRightChild = rightChild as OperatorNode;
|
|
58
|
+
// needBrackets ||= [OperatorIds.add, OperatorIds.substract].includes(operatorRightChild.id);
|
|
59
|
+
// }
|
|
60
|
+
// if (needBrackets) rightTex = `(${rightTex})`;
|
|
61
|
+
// return `${leftTex} \\div ${rightTex}`;
|
|
62
|
+
// }
|
|
63
|
+
// case OperatorIds.fraction: {
|
|
64
|
+
// return `\\frac{${leftTex}}{${rightTex}}`;
|
|
65
|
+
// }
|
|
66
|
+
// case OperatorIds.power: {
|
|
67
|
+
// let needBrackets = leftTex[0] === "-";
|
|
68
|
+
// if (leftChild.type === NodeType.operator) {
|
|
69
|
+
// const childOperator = leftChild as OperatorNode;
|
|
70
|
+
// needBrackets ||= [
|
|
71
|
+
// OperatorIds.add,
|
|
72
|
+
// OperatorIds.substract,
|
|
73
|
+
// OperatorIds.multiply,
|
|
74
|
+
// OperatorIds.divide,
|
|
75
|
+
// OperatorIds.fraction,
|
|
76
|
+
// OperatorIds.power,
|
|
77
|
+
// ].includes(childOperator.id);
|
|
78
|
+
// }
|
|
79
|
+
// if (needBrackets) leftTex = `(${leftTex})`;
|
|
80
|
+
// return `${leftTex}^{${rightTex}}`;
|
|
81
|
+
// }
|
|
82
|
+
// case OperatorIds.equal: {
|
|
83
|
+
// return `${leftTex} = ${rightTex}`;
|
|
84
|
+
// }
|
|
85
|
+
// default:
|
|
86
|
+
// return node.tex;
|
|
87
|
+
// }
|
|
88
|
+
// case NodeType.function: {
|
|
89
|
+
// const functionNode = node as FunctionNode;
|
|
90
|
+
// const child = functionNode.child;
|
|
91
|
+
// let childTex = latexParser(functionNode.child);
|
|
92
|
+
// switch (functionNode.id) {
|
|
93
|
+
// case FunctionsIds.sqrt: {
|
|
94
|
+
// return `\\sqrt{${childTex}}`;
|
|
95
|
+
// }
|
|
96
|
+
// case FunctionsIds.opposite: {
|
|
97
|
+
// let needBrackets = childTex[0] === "-";
|
|
98
|
+
// if (child.type === NodeType.operator) {
|
|
99
|
+
// const operatorChild = child as OperatorNode;
|
|
100
|
+
// needBrackets ||= [OperatorIds.add, OperatorIds.substract].includes(operatorChild.id);
|
|
101
|
+
// }
|
|
102
|
+
// if (needBrackets) childTex = `(${childTex})`;
|
|
103
|
+
// return `-${childTex}`;
|
|
104
|
+
// }
|
|
105
|
+
// }
|
|
106
|
+
// }
|
|
107
|
+
// default:
|
|
108
|
+
// return "";
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Node } from '../nodes/node';
|
|
2
|
-
export declare const simplifyNode: (node: Node) => Node;
|
|
1
|
+
import { Node } from '../nodes/node';
|
|
2
|
+
export declare const simplifyNode: (node: Node) => Node;
|
|
3
3
|
//# sourceMappingURL=simplify.d.ts.map
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.simplifyNode = void 0;
|
|
4
|
-
const mathjs_1 = require("mathjs");
|
|
5
|
-
const oppositeNode_1 = require("../nodes/functions/oppositeNode");
|
|
6
|
-
const sqrtNode_1 = require("../nodes/functions/sqrtNode");
|
|
7
|
-
const numberNode_1 = require("../nodes/numbers/numberNode");
|
|
8
|
-
const piNode_1 = require("../nodes/numbers/piNode");
|
|
9
|
-
const addNode_1 = require("../nodes/operators/addNode");
|
|
10
|
-
const fractionNode_1 = require("../nodes/operators/fractionNode");
|
|
11
|
-
const multiplyNode_1 = require("../nodes/operators/multiplyNode");
|
|
12
|
-
const powerNode_1 = require("../nodes/operators/powerNode");
|
|
13
|
-
const substractNode_1 = require("../nodes/operators/substractNode");
|
|
14
|
-
const variableNode_1 = require("../nodes/variables/variableNode");
|
|
15
|
-
const simplifyNode = (node) => {
|
|
16
|
-
return mathjsNodeToNode((0, mathjs_1.simplify)(node.toMathString()));
|
|
17
|
-
};
|
|
18
|
-
exports.simplifyNode = simplifyNode;
|
|
19
|
-
const mathjsNodeToNode = (mathjsNode) => {
|
|
20
|
-
if (mathjsNode.isSymbolNode) {
|
|
21
|
-
if (mathjsNode.name === 'pi')
|
|
22
|
-
return piNode_1.PiNode;
|
|
23
|
-
return new variableNode_1.VariableNode(mathjsNode.name);
|
|
24
|
-
}
|
|
25
|
-
else if (mathjsNode.isConstantNode) {
|
|
26
|
-
return new numberNode_1.NumberNode(mathjsNode.value);
|
|
27
|
-
}
|
|
28
|
-
else if (mathjsNode.isOperatorNode) {
|
|
29
|
-
switch (mathjsNode.fn) {
|
|
30
|
-
case 'add':
|
|
31
|
-
return new addNode_1.AddNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
32
|
-
case 'substract':
|
|
33
|
-
return new substractNode_1.SubstractNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
34
|
-
case 'unaryMinus':
|
|
35
|
-
return new oppositeNode_1.OppositeNode(mathjsNodeToNode(mathjsNode.args[0]));
|
|
36
|
-
case 'divide':
|
|
37
|
-
return new fractionNode_1.FractionNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
38
|
-
case 'multiply':
|
|
39
|
-
return new multiplyNode_1.MultiplyNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
40
|
-
case 'pow':
|
|
41
|
-
return new powerNode_1.PowerNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (mathjsNode.isFunctionNode) {
|
|
45
|
-
const fn = mathjsNode.fn;
|
|
46
|
-
switch (fn.name) {
|
|
47
|
-
case 'sqrt':
|
|
48
|
-
return new sqrtNode_1.SqrtNode(mathjsNodeToNode(mathjsNode.args[0]));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
throw Error('unrecognized mathjs node');
|
|
52
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.simplifyNode = void 0;
|
|
4
|
+
const mathjs_1 = require("mathjs");
|
|
5
|
+
const oppositeNode_1 = require("../nodes/functions/oppositeNode");
|
|
6
|
+
const sqrtNode_1 = require("../nodes/functions/sqrtNode");
|
|
7
|
+
const numberNode_1 = require("../nodes/numbers/numberNode");
|
|
8
|
+
const piNode_1 = require("../nodes/numbers/piNode");
|
|
9
|
+
const addNode_1 = require("../nodes/operators/addNode");
|
|
10
|
+
const fractionNode_1 = require("../nodes/operators/fractionNode");
|
|
11
|
+
const multiplyNode_1 = require("../nodes/operators/multiplyNode");
|
|
12
|
+
const powerNode_1 = require("../nodes/operators/powerNode");
|
|
13
|
+
const substractNode_1 = require("../nodes/operators/substractNode");
|
|
14
|
+
const variableNode_1 = require("../nodes/variables/variableNode");
|
|
15
|
+
const simplifyNode = (node) => {
|
|
16
|
+
return mathjsNodeToNode((0, mathjs_1.simplify)(node.toMathString()));
|
|
17
|
+
};
|
|
18
|
+
exports.simplifyNode = simplifyNode;
|
|
19
|
+
const mathjsNodeToNode = (mathjsNode) => {
|
|
20
|
+
if (mathjsNode.isSymbolNode) {
|
|
21
|
+
if (mathjsNode.name === 'pi')
|
|
22
|
+
return piNode_1.PiNode;
|
|
23
|
+
return new variableNode_1.VariableNode(mathjsNode.name);
|
|
24
|
+
}
|
|
25
|
+
else if (mathjsNode.isConstantNode) {
|
|
26
|
+
return new numberNode_1.NumberNode(mathjsNode.value);
|
|
27
|
+
}
|
|
28
|
+
else if (mathjsNode.isOperatorNode) {
|
|
29
|
+
switch (mathjsNode.fn) {
|
|
30
|
+
case 'add':
|
|
31
|
+
return new addNode_1.AddNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
32
|
+
case 'substract':
|
|
33
|
+
return new substractNode_1.SubstractNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
34
|
+
case 'unaryMinus':
|
|
35
|
+
return new oppositeNode_1.OppositeNode(mathjsNodeToNode(mathjsNode.args[0]));
|
|
36
|
+
case 'divide':
|
|
37
|
+
return new fractionNode_1.FractionNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
38
|
+
case 'multiply':
|
|
39
|
+
return new multiplyNode_1.MultiplyNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
40
|
+
case 'pow':
|
|
41
|
+
return new powerNode_1.PowerNode(mathjsNodeToNode(mathjsNode.args[0]), mathjsNodeToNode(mathjsNode.args[1]));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (mathjsNode.isFunctionNode) {
|
|
45
|
+
const fn = mathjsNode.fn;
|
|
46
|
+
switch (fn.name) {
|
|
47
|
+
case 'sqrt':
|
|
48
|
+
return new sqrtNode_1.SqrtNode(mathjsNodeToNode(mathjsNode.args[0]));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
throw Error('unrecognized mathjs node');
|
|
52
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function arrayEqual<T>(arr1: T[], arr2: T[]): boolean;
|
|
1
|
+
export declare function arrayEqual<T>(arr1: T[], arr2: T[]): boolean;
|
|
2
2
|
//# sourceMappingURL=arrayEqual.d.ts.map
|
package/lib/utils/arrayEqual.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arrayEqual = void 0;
|
|
4
|
-
function arrayEqual(arr1, arr2) {
|
|
5
|
-
if (arr1.length !== arr2.length)
|
|
6
|
-
return false;
|
|
7
|
-
for (let i = 0; i < arr1.length; i++) {
|
|
8
|
-
if (arr1[i] !== arr2[i])
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
exports.arrayEqual = arrayEqual;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arrayEqual = void 0;
|
|
4
|
+
function arrayEqual(arr1, arr2) {
|
|
5
|
+
if (arr1.length !== arr2.length)
|
|
6
|
+
return false;
|
|
7
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
8
|
+
if (arr1[i] !== arr2[i])
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
exports.arrayEqual = arrayEqual;
|
package/lib/utils/coin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coin = void 0;
|
|
4
|
-
const coin = () => {
|
|
5
|
-
return Math.random() < 0.5;
|
|
6
|
-
};
|
|
7
|
-
exports.coin = coin;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coin = void 0;
|
|
4
|
+
const coin = () => {
|
|
5
|
+
return Math.random() < 0.5;
|
|
6
|
+
};
|
|
7
|
+
exports.coin = coin;
|
package/lib/utils/coinFlip.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const coinFlip: () => Boolean;
|
|
1
|
+
export declare const coinFlip: () => Boolean;
|
|
2
2
|
//# sourceMappingURL=coinFlip.d.ts.map
|
package/lib/utils/coinFlip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.coinFlip = void 0;
|
|
4
|
-
const coinFlip = () => {
|
|
5
|
-
return Math.random() < 0.5;
|
|
6
|
-
};
|
|
7
|
-
exports.coinFlip = coinFlip;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coinFlip = void 0;
|
|
4
|
+
const coinFlip = () => {
|
|
5
|
+
return Math.random() < 0.5;
|
|
6
|
+
};
|
|
7
|
+
exports.coinFlip = coinFlip;
|
package/lib/utils/random.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function random<t>(array: t[]): t;
|
|
1
|
+
export declare function random<t>(array: t[]): t;
|
|
2
2
|
//# sourceMappingURL=random.d.ts.map
|
package/lib/utils/random.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.random = void 0;
|
|
4
|
-
function random(array) {
|
|
5
|
-
return array[Math.floor(Math.random() * array.length)];
|
|
6
|
-
}
|
|
7
|
-
exports.random = random;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.random = void 0;
|
|
4
|
+
function random(array) {
|
|
5
|
+
return array[Math.floor(Math.random() * array.length)];
|
|
6
|
+
}
|
|
7
|
+
exports.random = random;
|
package/lib/utils/shuffle.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function shuffle<T>(array: T[]): T[];
|
|
1
|
+
export declare function shuffle<T>(array: T[]): T[];
|
|
2
2
|
//# sourceMappingURL=shuffle.d.ts.map
|
package/lib/utils/shuffle.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shuffle = void 0;
|
|
4
|
-
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
|
5
|
-
function shuffle(array) {
|
|
6
|
-
const res = [...array];
|
|
7
|
-
for (var i = res.length - 1; i > 0; i--) {
|
|
8
|
-
var j = Math.floor(Math.random() * (i + 1));
|
|
9
|
-
var temp = res[i];
|
|
10
|
-
res[i] = res[j];
|
|
11
|
-
res[j] = temp;
|
|
12
|
-
}
|
|
13
|
-
return res;
|
|
14
|
-
}
|
|
15
|
-
exports.shuffle = shuffle;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shuffle = void 0;
|
|
4
|
+
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
|
5
|
+
function shuffle(array) {
|
|
6
|
+
const res = [...array];
|
|
7
|
+
for (var i = res.length - 1; i > 0; i--) {
|
|
8
|
+
var j = Math.floor(Math.random() * (i + 1));
|
|
9
|
+
var temp = res[i];
|
|
10
|
+
res[i] = res[j];
|
|
11
|
+
res[j] = temp;
|
|
12
|
+
}
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
exports.shuffle = shuffle;
|
package/package.json
CHANGED
|
@@ -1,45 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "math-exercises",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "Math exercises generator for middle school and high school",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"lib/**/*"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"dev": "
|
|
11
|
-
"start": "ts-node -r tsconfig-paths/register src/index.ts",
|
|
12
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
-
"start:dev": "nodemon",
|
|
14
|
-
"build": "tsc &&
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "math-exercises",
|
|
3
|
+
"version": "1.3.13",
|
|
4
|
+
"description": "Math exercises generator for middle school and high school",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib/**/*"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "nodemon",
|
|
11
|
+
"start": "ts-node -r tsconfig-paths/register src/index.ts",
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
13
|
+
"start:dev": "nodemon",
|
|
14
|
+
"build": "tsc && tsc-alias"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "Heureux Hasard",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"mathjs": "^11.5.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/cors": "^2.8.13",
|
|
24
|
+
"@types/express": "^4.17.17",
|
|
25
|
+
"@types/node": "^18.11.9",
|
|
26
|
+
"cors": "^2.8.5",
|
|
27
|
+
"dotenv": "^16.0.3",
|
|
28
|
+
"express": "^4.18.2",
|
|
29
|
+
"nodemon": "^2.0.20",
|
|
30
|
+
"prettier": "^2.8.4",
|
|
31
|
+
"ts-node": "^10.9.1",
|
|
32
|
+
"ts-node-dev": "^2.0.0",
|
|
33
|
+
"tsc-alias": "^1.8.2",
|
|
34
|
+
"tsconfig-paths": "^4.1.2",
|
|
35
|
+
"tslint": "^6.1.3",
|
|
36
|
+
"tslint-config-prettier": "^1.18.0",
|
|
37
|
+
"typescript": "^4.9.3"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/krirkrirk/math-exercises.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/krirkrirk/math-exercises/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/krirkrirk/math-exercises#readme",
|
|
47
|
+
"exports": {
|
|
48
|
+
".": "./lib/index.js"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* type (ax+b)(cx+d) ± (ax+b)(ex+f)
|
|
3
|
-
*/
|
|
4
|
-
import { Exercise, Question } from '../../../exercises/exercise';
|
|
5
|
-
export declare const factoType1Exercise: Exercise;
|
|
6
|
-
export declare function getFactoType1Question(): Question;
|
|
7
|
-
//# sourceMappingURL=factoIdRmq.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factoIdRmq.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/factorisation/factoIdRmq.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS9D,eAAO,MAAM,kBAAkB,EAAE,QAShC,CAAC;AAEF,wBAAgB,qBAAqB,IAAI,QAAQ,CA4BhD"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* type (ax+b)(cx+d) ± (ax+b)(ex+f)
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getFactoType1Question = exports.factoType1Exercise = void 0;
|
|
7
|
-
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
8
|
-
const affine_1 = require("../../../math/polynomials/affine");
|
|
9
|
-
const addNode_1 = require("../../../tree/nodes/operators/addNode");
|
|
10
|
-
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
11
|
-
const substractNode_1 = require("../../../tree/nodes/operators/substractNode");
|
|
12
|
-
const random_1 = require("../../../utils/random");
|
|
13
|
-
const shuffle_1 = require("../../../utils/shuffle");
|
|
14
|
-
exports.factoType1Exercise = {
|
|
15
|
-
id: 'factoIdRmq1',
|
|
16
|
-
connector: '=',
|
|
17
|
-
instruction: 'Factoriser :',
|
|
18
|
-
isSingleStep: false,
|
|
19
|
-
label: 'Factorisation du type $(ax+b)(cx+d) \\pm (ax+b)(ex+f)$',
|
|
20
|
-
levels: ['3', '2'],
|
|
21
|
-
section: 'Calcul littéral',
|
|
22
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getFactoType1Question, nb),
|
|
23
|
-
};
|
|
24
|
-
function getFactoType1Question() {
|
|
25
|
-
const affines = affine_1.AffineConstructor.differentRandoms(3);
|
|
26
|
-
const permut = [(0, shuffle_1.shuffle)([affines[0], affines[1]]), (0, shuffle_1.shuffle)([affines[0], affines[2]])];
|
|
27
|
-
const operation = (0, random_1.random)(['add', 'substract']);
|
|
28
|
-
const statementTree = operation === 'add'
|
|
29
|
-
? new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(permut[0][0].toTree(), permut[0][1].toTree()), new multiplyNode_1.MultiplyNode(permut[1][0].toTree(), permut[1][1].toTree()))
|
|
30
|
-
: new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(permut[0][0].toTree(), permut[0][1].toTree()), new multiplyNode_1.MultiplyNode(permut[1][0].toTree(), permut[1][1].toTree()));
|
|
31
|
-
const answerTree = new multiplyNode_1.MultiplyNode(affines[0].toTree(), affines[1].add(operation === 'add' ? affines[2] : affines[2].opposite()).toTree());
|
|
32
|
-
const question = {
|
|
33
|
-
startStatement: statementTree.toTex(),
|
|
34
|
-
answer: answerTree.toTex(),
|
|
35
|
-
};
|
|
36
|
-
return question;
|
|
37
|
-
}
|
|
38
|
-
exports.getFactoType1Question = getFactoType1Question;
|