math-exercises 1.2.7 → 1.2.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/addAndSub.js +40 -0
- package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.js +35 -0
- package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.js +31 -0
- package/lib/exercises/calcul/fractions/fractionAndIntegerSum.js +32 -0
- package/lib/exercises/calcul/fractions/fractionsDivision.js +29 -0
- package/lib/exercises/calcul/fractions/fractionsProduct.js +29 -0
- package/lib/exercises/calcul/fractions/fractionsSum.js +29 -0
- package/lib/exercises/calcul/fractions/simplifyFraction.js +25 -0
- package/lib/exercises/calcul/operations/operationsPriorities.js +88 -0
- package/lib/exercises/calcul/operations/operationsPrioritiesWithoutRelative.js +111 -0
- package/{src → lib}/exercises/calcul/operationsPriorities.js +88 -89
- package/lib/exercises/calcul/rounding/rounding.js +86 -0
- package/{src → lib}/exercises/calculLitteral/distributivity/allIdentities.js +27 -27
- package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.js +31 -0
- package/lib/exercises/calculLitteral/distributivity/firstIdentity.js +32 -0
- package/lib/exercises/calculLitteral/distributivity/secondIdentity.js +33 -0
- package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.js +33 -0
- package/lib/exercises/calculLitteral/distributivity/thirdIdentity.js +32 -0
- package/lib/exercises/calculLitteral/equation/equationType1Exercise.js +38 -0
- package/lib/exercises/calculLitteral/equation/equationType2Exercise.js +41 -0
- package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +42 -0
- package/lib/exercises/calculLitteral/equation/equationType4Exercise.js +44 -0
- package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.js +39 -0
- package/{src → lib}/exercises/exercise.js +7 -7
- package/lib/exercises/exercises.js +95 -0
- package/lib/exercises/geometry/cartesian/midpoint.js +29 -0
- package/lib/exercises/geometry/vectors/scalarProductViaCoords.js +29 -0
- package/lib/exercises/geometry/vectors/scalarProductViaNorms.js +27 -0
- package/lib/exercises/powers/powersDivision.js +45 -0
- package/lib/exercises/powers/powersOfTenToDecimal.js +33 -0
- package/lib/exercises/powers/powersPower.js +44 -0
- package/lib/exercises/powers/powersProduct.js +45 -0
- package/lib/exercises/powers/scientificToDecimal.js +38 -0
- package/{src → lib}/exercises/squareRoots/simpifySquareRoot.js +28 -28
- package/lib/exercises/utils/getDistinctQuestions.js +16 -0
- package/lib/geometry/point.js +27 -0
- package/lib/geometry/vector.js +31 -0
- package/lib/index.js +10 -0
- package/lib/mathutils/arithmetic/coprimesOf.js +13 -0
- package/lib/mathutils/arithmetic/dividersOf.js +12 -0
- package/{src → lib}/mathutils/arithmetic/gcd.js +7 -7
- package/{src → lib}/mathutils/arithmetic/isSquare.js +7 -7
- package/{src → lib}/mathutils/arithmetic/lcd.js +12 -12
- package/lib/mathutils/arithmetic/nonCoprimesOf.js +13 -0
- package/lib/mathutils/arithmetic/nonDividersOf.js +14 -0
- package/{src → lib}/mathutils/arithmetic/primeFactors.js +22 -22
- package/lib/mathutils/decimals/decimalPartLengthOf.js +14 -0
- package/lib/mathutils/random/randTupleInt.js +30 -0
- package/{src → lib}/mathutils/random/randint.js +18 -18
- package/{src → lib}/mathutils/round.js +8 -8
- package/{src → lib}/numbers/decimals/decimal.js +140 -144
- package/{src → lib}/numbers/epsilon.js +10 -10
- package/{src → lib}/numbers/integer/integer.js +68 -72
- package/{src → lib}/numbers/integer/power.js +52 -53
- package/{src → lib}/numbers/nombre.js +10 -10
- package/lib/numbers/rationals/rational.js +113 -0
- package/lib/numbers/reals/real.js +16 -0
- package/lib/numbers/reals/squareRoot.js +63 -0
- package/lib/polynomials/affine.js +42 -0
- package/lib/polynomials/polynomial.js +125 -0
- package/lib/sets/discreteSet.js +28 -0
- package/{src/sets/emptySet.ts → lib/sets/emptySet.js} +6 -6
- package/{src → lib}/sets/intervals/intervals.js +108 -113
- package/lib/sets/intervals/union.js +1 -0
- package/lib/sets/mathSet.js +10 -0
- package/lib/sets/mathSetInterface.js +2 -0
- package/{src → lib}/tree/nodes/functions/functionNode.js +18 -19
- package/lib/tree/nodes/functions/oppositeNode.js +13 -0
- package/lib/tree/nodes/functions/sqrtNode.js +15 -0
- package/{src → lib}/tree/nodes/node.js +10 -10
- package/lib/tree/nodes/numbers/numberNode.js +18 -0
- package/lib/tree/nodes/operators/addNode.js +15 -0
- package/lib/tree/nodes/operators/divideNode.js +17 -0
- package/lib/tree/nodes/operators/equalNode.js +13 -0
- package/lib/tree/nodes/operators/fractionNode.js +17 -0
- package/lib/tree/nodes/operators/multiplyNode.js +13 -0
- package/{src → lib}/tree/nodes/operators/operatorNode.js +35 -37
- package/lib/tree/nodes/operators/powerNode.js +13 -0
- package/lib/tree/nodes/operators/substractNode.js +13 -0
- package/lib/tree/nodes/variables/variableNode.js +16 -0
- package/{src → lib}/tree/parsers/derivateParser.js +60 -60
- package/{src → lib}/tree/parsers/latexParser.js +117 -117
- package/lib/utils/arrayEqual.js +13 -0
- package/{src → lib}/utils/coin.js +7 -7
- package/{src → lib}/utils/random.js +7 -7
- package/lib/utils/shuffle.js +15 -0
- package/package.json +35 -28
- package/nodemon.json +0 -5
- package/src/exercises/calcul/addAndSub.js +0 -40
- package/src/exercises/calcul/addAndSub.ts +0 -39
- package/src/exercises/calcul/fractions/fractionAndIntegerDivision.js +0 -35
- package/src/exercises/calcul/fractions/fractionAndIntegerDivision.ts +0 -38
- package/src/exercises/calcul/fractions/fractionAndIntegerProduct.js +0 -31
- package/src/exercises/calcul/fractions/fractionAndIntegerProduct.ts +0 -32
- package/src/exercises/calcul/fractions/fractionAndIntegerSum.js +0 -32
- package/src/exercises/calcul/fractions/fractionAndIntegerSum.ts +0 -31
- package/src/exercises/calcul/fractions/fractionsDivision.js +0 -29
- package/src/exercises/calcul/fractions/fractionsDivision.ts +0 -30
- package/src/exercises/calcul/fractions/fractionsProduct.js +0 -29
- package/src/exercises/calcul/fractions/fractionsProduct.ts +0 -29
- package/src/exercises/calcul/fractions/fractionsSum.js +0 -29
- package/src/exercises/calcul/fractions/fractionsSum.ts +0 -28
- package/src/exercises/calcul/fractions/simplifyFraction.js +0 -25
- package/src/exercises/calcul/fractions/simplifyFraction.ts +0 -24
- package/src/exercises/calcul/operationsPriorities.ts +0 -115
- package/src/exercises/calcul/rounding/roundToUnit.js +0 -70
- package/src/exercises/calcul/rounding/roundToUnit.ts +0 -68
- package/src/exercises/calculLitteral/distributivity/allIdentities.ts +0 -26
- package/src/exercises/calculLitteral/distributivity/doubleDistributivity.js +0 -31
- package/src/exercises/calculLitteral/distributivity/doubleDistributivity.ts +0 -33
- package/src/exercises/calculLitteral/distributivity/firstIdentity.js +0 -32
- package/src/exercises/calculLitteral/distributivity/firstIdentity.ts +0 -33
- package/src/exercises/calculLitteral/distributivity/secondIdentity.js +0 -33
- package/src/exercises/calculLitteral/distributivity/secondIdentity.ts +0 -35
- package/src/exercises/calculLitteral/distributivity/simpleDistributivity.js +0 -33
- package/src/exercises/calculLitteral/distributivity/simpleDistributivity.ts +0 -33
- package/src/exercises/calculLitteral/distributivity/thirdIdentity.js +0 -32
- package/src/exercises/calculLitteral/distributivity/thirdIdentity.ts +0 -34
- package/src/exercises/calculLitteral/equation/equationType1Exercise.js +0 -38
- package/src/exercises/calculLitteral/equation/equationType1Exercise.ts +0 -38
- package/src/exercises/calculLitteral/equation/equationType2Exercise.js +0 -41
- package/src/exercises/calculLitteral/equation/equationType2Exercise.ts +0 -41
- package/src/exercises/calculLitteral/equation/equationType3Exercise.js +0 -42
- package/src/exercises/calculLitteral/equation/equationType3Exercise.ts +0 -43
- package/src/exercises/calculLitteral/equation/equationType4Exercise.js +0 -44
- package/src/exercises/calculLitteral/equation/equationType4Exercise.ts +0 -46
- package/src/exercises/calculLitteral/factorisation/factoType1Exercise.js +0 -39
- package/src/exercises/calculLitteral/factorisation/factoType1Exercise.ts +0 -54
- package/src/exercises/calculLitteral/reduction.ts +0 -27
- package/src/exercises/exercise.ts +0 -25
- package/src/exercises/exercises.js +0 -86
- package/src/exercises/exercises.ts +0 -91
- package/src/exercises/powers/powersDivision.js +0 -46
- package/src/exercises/powers/powersDivision.ts +0 -51
- package/src/exercises/powers/powersOfTenToDecimal.js +0 -33
- package/src/exercises/powers/powersOfTenToDecimal.ts +0 -37
- package/src/exercises/powers/powersPower.js +0 -45
- package/src/exercises/powers/powersPower.ts +0 -55
- package/src/exercises/powers/powersProduct.js +0 -46
- package/src/exercises/powers/powersProduct.ts +0 -51
- package/src/exercises/powers/scientificToDecimal.js +0 -38
- package/src/exercises/powers/scientificToDecimal.ts +0 -44
- package/src/exercises/squareRoots/simpifySquareRoot.ts +0 -27
- package/src/exercises/utils/getDistinctQuestions.js +0 -18
- package/src/exercises/utils/getDistinctQuestions.ts +0 -14
- package/src/index.js +0 -10
- package/src/index.ts +0 -14
- package/src/mathutils/arithmetic/coprimesOf.js +0 -13
- package/src/mathutils/arithmetic/coprimesOf.ts +0 -9
- package/src/mathutils/arithmetic/dividersOf.ts +0 -7
- package/src/mathutils/arithmetic/gcd.ts +0 -3
- package/src/mathutils/arithmetic/isSquare.ts +0 -3
- package/src/mathutils/arithmetic/lcd.ts +0 -7
- package/src/mathutils/arithmetic/nonCoprimesOf.ts +0 -9
- package/src/mathutils/arithmetic/nonDividersOf.ts +0 -12
- package/src/mathutils/arithmetic/primeFactors.ts +0 -18
- package/src/mathutils/decimals/decimalPartLengthOf.ts +0 -10
- package/src/mathutils/random/randint.ts +0 -12
- package/src/mathutils/round.ts +0 -5
- package/src/numbers/decimals/decimal.ts +0 -140
- package/src/numbers/epsilon.ts +0 -7
- package/src/numbers/integer/integer.ts +0 -72
- package/src/numbers/integer/power.ts +0 -49
- package/src/numbers/nombre.ts +0 -15
- package/src/numbers/number.js +0 -8
- package/src/numbers/rationals/rational.js +0 -128
- package/src/numbers/rationals/rational.ts +0 -122
- package/src/numbers/reals/real.js +0 -17
- package/src/numbers/reals/real.ts +0 -17
- package/src/numbers/reals/squareRoot.js +0 -85
- package/src/numbers/reals/squareRoot.ts +0 -70
- package/src/polynomials/affine.js +0 -71
- package/src/polynomials/affine.ts +0 -60
- package/src/polynomials/polynomial.js +0 -128
- package/src/polynomials/polynomial.ts +0 -137
- package/src/sets/discreteSet.js +0 -30
- package/src/sets/discreteSet.ts +0 -30
- package/src/sets/intervals/intervals.ts +0 -122
- package/src/sets/intervals/union.ts +0 -0
- package/src/sets/mathSet.js +0 -11
- package/src/sets/mathSet.ts +0 -12
- package/src/sets/mathSetInterface.js +0 -2
- package/src/sets/mathSetInterface.ts +0 -10
- package/src/tree/latexParser/latexParse.js +0 -117
- package/src/tree/nodes/functions/functionNode.ts +0 -18
- package/src/tree/nodes/functions/oppositeNode.js +0 -30
- package/src/tree/nodes/functions/oppositeNode.ts +0 -12
- package/src/tree/nodes/functions/sqrtNode.js +0 -33
- package/src/tree/nodes/functions/sqrtNode.ts +0 -12
- package/src/tree/nodes/node.ts +0 -12
- package/src/tree/nodes/numbers/numberNode.js +0 -16
- package/src/tree/nodes/numbers/numberNode.ts +0 -16
- package/src/tree/nodes/operators/addNode.js +0 -33
- package/src/tree/nodes/operators/addNode.ts +0 -13
- package/src/tree/nodes/operators/divideNode.js +0 -34
- package/src/tree/nodes/operators/divideNode.ts +0 -16
- package/src/tree/nodes/operators/equalNode.js +0 -30
- package/src/tree/nodes/operators/equalNode.ts +0 -11
- package/src/tree/nodes/operators/fractionNode.js +0 -34
- package/src/tree/nodes/operators/fractionNode.ts +0 -16
- package/src/tree/nodes/operators/multiplyNode.js +0 -30
- package/src/tree/nodes/operators/multiplyNode.ts +0 -12
- package/src/tree/nodes/operators/operatorNode.ts +0 -36
- package/src/tree/nodes/operators/oppositeNode.js +0 -18
- package/src/tree/nodes/operators/powerNode.js +0 -30
- package/src/tree/nodes/operators/powerNode.ts +0 -12
- package/src/tree/nodes/operators/substractNode.js +0 -30
- package/src/tree/nodes/operators/substractNode.ts +0 -11
- package/src/tree/nodes/variables/variableNode.js +0 -17
- package/src/tree/nodes/variables/variableNode.ts +0 -15
- package/src/tree/parsers/derivateParser.ts +0 -66
- package/src/tree/parsers/latexParser.ts +0 -122
- package/src/utils/coin.ts +0 -3
- package/src/utils/random.ts +0 -3
- package/src/utils/randomIn.js +0 -7
- package/src/utils/shuffle.js +0 -24
- package/src/utils/shuffle.ts +0 -11
- package/tsconfig.json +0 -110
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { randint } from "../../mathutils/random/randint";
|
|
2
|
-
import { Integer } from "../../numbers/integer/integer";
|
|
3
|
-
import { Power } from "../../numbers/integer/power";
|
|
4
|
-
import { DiscreteSet } from "../../sets/discreteSet";
|
|
5
|
-
import { Interval } from "../../sets/intervals/intervals";
|
|
6
|
-
import { latexParser } from "../../tree/parsers/latexParser";
|
|
7
|
-
import { Node } from "../../tree/nodes/node";
|
|
8
|
-
import { NumberNode } from "../../tree/nodes/numbers/numberNode";
|
|
9
|
-
import { AddNode } from "../../tree/nodes/operators/addNode";
|
|
10
|
-
import { DivideNode } from "../../tree/nodes/operators/divideNode";
|
|
11
|
-
import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode";
|
|
12
|
-
import { PowerNode } from "../../tree/nodes/operators/powerNode";
|
|
13
|
-
import { coin } from "../../utils/coin";
|
|
14
|
-
import { Exercise, Question } from "../exercise";
|
|
15
|
-
import { getDistinctQuestions } from "../utils/getDistinctQuestions";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* (a^b)^c
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
export const powersOfTenPower: Exercise = {
|
|
22
|
-
id: "powersOfTenPower",
|
|
23
|
-
connector: "=",
|
|
24
|
-
instruction: "Calculer :",
|
|
25
|
-
label: "Puissance d'une puissance de 10 ",
|
|
26
|
-
levels: ["4", "3", "2", "1"],
|
|
27
|
-
section: "Puissances",
|
|
28
|
-
isSingleStep: true,
|
|
29
|
-
generator: (nb: number) => getDistinctQuestions(() => getPowersPowerQuestion(true), nb),
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const powersPower: Exercise = {
|
|
33
|
-
id: "powersPower",
|
|
34
|
-
connector: "=",
|
|
35
|
-
instruction: "Calculer :",
|
|
36
|
-
label: "Puissance d'une puissance",
|
|
37
|
-
levels: ["4", "3", "2", "1"],
|
|
38
|
-
section: "Puissances",
|
|
39
|
-
isSingleStep: true,
|
|
40
|
-
generator: (nb: number) => getDistinctQuestions(getPowersPowerQuestion, nb),
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export function getPowersPowerQuestion(useOnlyPowersOfTen: boolean = false): Question {
|
|
44
|
-
const a = useOnlyPowersOfTen ? 10 : randint(-11, 11);
|
|
45
|
-
const [b, c] = [1, 2].map((el) => randint(-11, 11));
|
|
46
|
-
|
|
47
|
-
const statement = new PowerNode(new PowerNode(new NumberNode(a), new NumberNode(b)), new NumberNode(c));
|
|
48
|
-
let answerTree = new Power(a, b * c).simplify();
|
|
49
|
-
|
|
50
|
-
const question: Question = {
|
|
51
|
-
startStatement: latexParser(statement),
|
|
52
|
-
answer: latexParser(answerTree),
|
|
53
|
-
};
|
|
54
|
-
return question;
|
|
55
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.getPowersProductQuestion = exports.powersProduct = exports.powersOfTenProduct = void 0;
|
|
4
|
-
var randint_1 = require("../../mathutils/random/randint");
|
|
5
|
-
var power_1 = require("../../numbers/integer/power");
|
|
6
|
-
var latexParser_1 = require("../../tree/parsers/latexParser");
|
|
7
|
-
var numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
8
|
-
var multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
9
|
-
var powerNode_1 = require("../../tree/nodes/operators/powerNode");
|
|
10
|
-
var getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
11
|
-
/**
|
|
12
|
-
* a^b*a^c
|
|
13
|
-
*/
|
|
14
|
-
exports.powersOfTenProduct = {
|
|
15
|
-
id: "powersOfTenProduct",
|
|
16
|
-
connector: "=",
|
|
17
|
-
instruction: "Calculer :",
|
|
18
|
-
label: "Multiplication de puissances de 10",
|
|
19
|
-
levels: ["4", "3", "2", "1"],
|
|
20
|
-
section: "Puissances",
|
|
21
|
-
isSingleStep: true,
|
|
22
|
-
generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(function () { return getPowersProductQuestion(true); }, nb); }
|
|
23
|
-
};
|
|
24
|
-
exports.powersProduct = {
|
|
25
|
-
id: "powersProduct",
|
|
26
|
-
connector: "=",
|
|
27
|
-
instruction: "Calculer :",
|
|
28
|
-
label: "Multiplication de puissances",
|
|
29
|
-
levels: ["4", "3", "2", "1"],
|
|
30
|
-
section: "Puissances",
|
|
31
|
-
isSingleStep: true,
|
|
32
|
-
generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getPowersProductQuestion, nb); }
|
|
33
|
-
};
|
|
34
|
-
function getPowersProductQuestion(useOnlyPowersOfTen) {
|
|
35
|
-
if (useOnlyPowersOfTen === void 0) { useOnlyPowersOfTen = false; }
|
|
36
|
-
var a = useOnlyPowersOfTen ? 10 : (0, randint_1.randint)(-11, 11);
|
|
37
|
-
var _a = [1, 2].map(function (el) { return (0, randint_1.randint)(-11, 11); }), b = _a[0], c = _a[1];
|
|
38
|
-
var statement = new multiplyNode_1.MultiplyNode(new powerNode_1.PowerNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new powerNode_1.PowerNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(c)));
|
|
39
|
-
var answerTree = new power_1.Power(a, b + c).simplify();
|
|
40
|
-
var question = {
|
|
41
|
-
startStatement: (0, latexParser_1.latexParser)(statement),
|
|
42
|
-
answer: (0, latexParser_1.latexParser)(answerTree)
|
|
43
|
-
};
|
|
44
|
-
return question;
|
|
45
|
-
}
|
|
46
|
-
exports.getPowersProductQuestion = getPowersProductQuestion;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { randint } from "../../mathutils/random/randint";
|
|
2
|
-
import { Power } from "../../numbers/integer/power";
|
|
3
|
-
import { latexParser } from "../../tree/parsers/latexParser";
|
|
4
|
-
import { NumberNode } from "../../tree/nodes/numbers/numberNode";
|
|
5
|
-
import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode";
|
|
6
|
-
import { PowerNode } from "../../tree/nodes/operators/powerNode";
|
|
7
|
-
import { Exercise, Question } from "../exercise";
|
|
8
|
-
import { getDistinctQuestions } from "../utils/getDistinctQuestions";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* a^b*a^c
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export const powersOfTenProduct: Exercise = {
|
|
15
|
-
id: "powersOfTenProduct",
|
|
16
|
-
connector: "=",
|
|
17
|
-
instruction: "Calculer :",
|
|
18
|
-
label: "Multiplication de puissances de 10",
|
|
19
|
-
levels: ["4", "3", "2", "1"],
|
|
20
|
-
section: "Puissances",
|
|
21
|
-
isSingleStep: true,
|
|
22
|
-
generator: (nb: number) => getDistinctQuestions(() => getPowersProductQuestion(true), nb),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const powersProduct: Exercise = {
|
|
26
|
-
id: "powersProduct",
|
|
27
|
-
connector: "=",
|
|
28
|
-
instruction: "Calculer :",
|
|
29
|
-
label: "Multiplication de puissances",
|
|
30
|
-
levels: ["4", "3", "2", "1"],
|
|
31
|
-
section: "Puissances",
|
|
32
|
-
isSingleStep: true,
|
|
33
|
-
generator: (nb: number) => getDistinctQuestions(getPowersProductQuestion, nb),
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export function getPowersProductQuestion(useOnlyPowersOfTen: boolean = false): Question {
|
|
37
|
-
const a = useOnlyPowersOfTen ? 10 : randint(-11, 11);
|
|
38
|
-
const [b, c] = [1, 2].map((el) => randint(-11, 11));
|
|
39
|
-
|
|
40
|
-
const statement = new MultiplyNode(
|
|
41
|
-
new PowerNode(new NumberNode(a), new NumberNode(b)),
|
|
42
|
-
new PowerNode(new NumberNode(a), new NumberNode(c))
|
|
43
|
-
);
|
|
44
|
-
const answerTree = new Power(a, b + c).simplify();
|
|
45
|
-
|
|
46
|
-
const question: Question = {
|
|
47
|
-
startStatement: latexParser(statement),
|
|
48
|
-
answer: latexParser(answerTree),
|
|
49
|
-
};
|
|
50
|
-
return question;
|
|
51
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.getScientificToDecimalQuestion = exports.scientificToDecimal = void 0;
|
|
4
|
-
var randint_1 = require("../../mathutils/random/randint");
|
|
5
|
-
var decimal_1 = require("../../numbers/decimals/decimal");
|
|
6
|
-
var integer_1 = require("../../numbers/integer/integer");
|
|
7
|
-
var latexParser_1 = require("../../tree/parsers/latexParser");
|
|
8
|
-
var numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
9
|
-
var multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
10
|
-
var powerNode_1 = require("../../tree/nodes/operators/powerNode");
|
|
11
|
-
var getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
|
|
12
|
-
/**
|
|
13
|
-
* a*10^x vers décimal
|
|
14
|
-
* */
|
|
15
|
-
exports.scientificToDecimal = {
|
|
16
|
-
id: "scientificToDecimal",
|
|
17
|
-
connector: "=",
|
|
18
|
-
instruction: "Donner l'écriture décimale de :",
|
|
19
|
-
label: "Ecriture décimale de $a\\times 10^x$",
|
|
20
|
-
levels: ["5", "4", "3", "2"],
|
|
21
|
-
section: "Puissances",
|
|
22
|
-
isSingleStep: true,
|
|
23
|
-
generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getScientificToDecimalQuestion, nb); }
|
|
24
|
-
};
|
|
25
|
-
function getScientificToDecimalQuestion() {
|
|
26
|
-
var randPower = (0, randint_1.randint)(-6, 8);
|
|
27
|
-
var int = integer_1.IntegerConstructor.random((0, randint_1.randint)(1, 4));
|
|
28
|
-
var fracPart = decimal_1.DecimalConstructor.randomFracPart((0, randint_1.randint)(0, 4));
|
|
29
|
-
var randDecimal = decimal_1.DecimalConstructor.fromParts(int + "", fracPart);
|
|
30
|
-
var statement = new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(randDecimal.value), new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(randPower)));
|
|
31
|
-
var answerTree = randDecimal.multiplyByPowerOfTen(randPower).toTree();
|
|
32
|
-
var question = {
|
|
33
|
-
startStatement: (0, latexParser_1.latexParser)(statement),
|
|
34
|
-
answer: (0, latexParser_1.latexParser)(answerTree)
|
|
35
|
-
};
|
|
36
|
-
return question;
|
|
37
|
-
}
|
|
38
|
-
exports.getScientificToDecimalQuestion = getScientificToDecimalQuestion;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { randint } from "../../mathutils/random/randint";
|
|
2
|
-
import { DecimalConstructor } from "../../numbers/decimals/decimal";
|
|
3
|
-
import { IntegerConstructor } from "../../numbers/integer/integer";
|
|
4
|
-
import { Power } from "../../numbers/integer/power";
|
|
5
|
-
import { latexParser } from "../../tree/parsers/latexParser";
|
|
6
|
-
import { NumberNode } from "../../tree/nodes/numbers/numberNode";
|
|
7
|
-
import { FractionNode } from "../../tree/nodes/operators/fractionNode";
|
|
8
|
-
import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode";
|
|
9
|
-
import { PowerNode } from "../../tree/nodes/operators/powerNode";
|
|
10
|
-
import { Exercise, Question } from "../exercise";
|
|
11
|
-
import { getDistinctQuestions } from "../utils/getDistinctQuestions";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* a*10^x vers décimal
|
|
15
|
-
* */
|
|
16
|
-
|
|
17
|
-
export const scientificToDecimal: Exercise = {
|
|
18
|
-
id: "scientificToDecimal",
|
|
19
|
-
connector: "=",
|
|
20
|
-
instruction: "Donner l'écriture décimale de :",
|
|
21
|
-
label: "Ecriture décimale de $a\\times 10^x$",
|
|
22
|
-
levels: ["5", "4", "3", "2"],
|
|
23
|
-
section: "Puissances",
|
|
24
|
-
isSingleStep: true,
|
|
25
|
-
generator: (nb: number) => getDistinctQuestions(getScientificToDecimalQuestion, nb),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export function getScientificToDecimalQuestion(): Question {
|
|
29
|
-
const randPower = randint(-6, 8);
|
|
30
|
-
const int = IntegerConstructor.random(randint(1, 4));
|
|
31
|
-
const fracPart = DecimalConstructor.randomFracPart(randint(0, 4));
|
|
32
|
-
const randDecimal = DecimalConstructor.fromParts(int + "", fracPart);
|
|
33
|
-
const statement = new MultiplyNode(
|
|
34
|
-
new NumberNode(randDecimal.value),
|
|
35
|
-
new PowerNode(new NumberNode(10), new NumberNode(randPower))
|
|
36
|
-
);
|
|
37
|
-
const answerTree = randDecimal.multiplyByPowerOfTen(randPower).toTree();
|
|
38
|
-
|
|
39
|
-
const question: Question = {
|
|
40
|
-
startStatement: latexParser(statement),
|
|
41
|
-
answer: latexParser(answerTree),
|
|
42
|
-
};
|
|
43
|
-
return question;
|
|
44
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { SquareRootConstructor } from "../../numbers/reals/squareRoot";
|
|
2
|
-
import { latexParser } from "../../tree/parsers/latexParser";
|
|
3
|
-
import { Exercise, Question } from "../exercise";
|
|
4
|
-
import { getDistinctQuestions } from "../utils/getDistinctQuestions";
|
|
5
|
-
|
|
6
|
-
export const simplifySquareRoot: Exercise = {
|
|
7
|
-
id: "simplifySqrt",
|
|
8
|
-
connector: "=",
|
|
9
|
-
instruction: "Simplifier :",
|
|
10
|
-
label: "Simplification de racines carrées",
|
|
11
|
-
levels: ["3", "2", "1"],
|
|
12
|
-
isSingleStep: false,
|
|
13
|
-
section: "Racines carrées",
|
|
14
|
-
generator: (nb: number) => getDistinctQuestions(getSimplifySquareRoot, nb),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export function getSimplifySquareRoot(): Question {
|
|
18
|
-
const squareRoot = SquareRootConstructor.randomSimplifiable({
|
|
19
|
-
allowPerfectSquare: false,
|
|
20
|
-
maxSquare: 11,
|
|
21
|
-
});
|
|
22
|
-
const question: Question = {
|
|
23
|
-
startStatement: latexParser(squareRoot.toTree()),
|
|
24
|
-
answer: latexParser(squareRoot.simplify().toTree()),
|
|
25
|
-
};
|
|
26
|
-
return question;
|
|
27
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.getDistinctQuestions = void 0;
|
|
4
|
-
var getDistinctQuestions = function (generator, nb) {
|
|
5
|
-
var res = [];
|
|
6
|
-
var _loop_1 = function (i) {
|
|
7
|
-
var question;
|
|
8
|
-
do {
|
|
9
|
-
question = generator();
|
|
10
|
-
} while (res.some(function (q) { return q.startStatement === question.startStatement; }));
|
|
11
|
-
res.push(question);
|
|
12
|
-
};
|
|
13
|
-
for (var i = 0; i < nb; i++) {
|
|
14
|
-
_loop_1(i);
|
|
15
|
-
}
|
|
16
|
-
return res;
|
|
17
|
-
};
|
|
18
|
-
exports.getDistinctQuestions = getDistinctQuestions;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Question } from "../exercise";
|
|
2
|
-
export const getDistinctQuestions = (generator: Function, nb: number): Question[] => {
|
|
3
|
-
const res: Question[] = [];
|
|
4
|
-
|
|
5
|
-
for (let i = 0; i < nb; i++) {
|
|
6
|
-
let question: Question;
|
|
7
|
-
|
|
8
|
-
do {
|
|
9
|
-
question = generator();
|
|
10
|
-
} while (res.some((q) => q.startStatement === question.startStatement));
|
|
11
|
-
res.push(question);
|
|
12
|
-
}
|
|
13
|
-
return res;
|
|
14
|
-
};
|
package/src/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.exercises = void 0;
|
|
4
|
-
var exercises_1 = require("./exercises/exercises");
|
|
5
|
-
exports.exercises = exercises_1.exercises;
|
|
6
|
-
var polynomial_1 = require("./polynomials/polynomial");
|
|
7
|
-
// exercises.forEach((exo) => {
|
|
8
|
-
// console.log(exo.instruction, exo.generator(10));
|
|
9
|
-
// });
|
|
10
|
-
var pol = new polynomial_1.Polynomial([2, 3, 1, 4]);
|
package/src/index.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { operationsPriorities } from "./exercises/calcul/operationsPriorities";
|
|
2
|
-
import { exercises } from "./exercises/exercises";
|
|
3
|
-
import { latexParser } from "./tree/parsers/latexParser";
|
|
4
|
-
import { NumberNode } from "./tree/nodes/numbers/numberNode";
|
|
5
|
-
import { MultiplyNode } from "./tree/nodes/operators/multiplyNode";
|
|
6
|
-
import { Polynomial } from "./polynomials/polynomial";
|
|
7
|
-
import { derivateParser } from "./tree/parsers/derivateParser";
|
|
8
|
-
|
|
9
|
-
// exercises.forEach((exo) => {
|
|
10
|
-
// console.log(exo.instruction, exo.generator(10));
|
|
11
|
-
// });
|
|
12
|
-
|
|
13
|
-
const pol = new Polynomial([2, 3, 1, 4]);
|
|
14
|
-
export { exercises };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.coprimesOf = void 0;
|
|
4
|
-
var gcd_1 = require("./gcd");
|
|
5
|
-
var coprimesOf = function (nb) {
|
|
6
|
-
var coprimes = [];
|
|
7
|
-
for (var i = 2; i <= nb; i++) {
|
|
8
|
-
if ((0, gcd_1.gcd)(nb, i) === 1)
|
|
9
|
-
coprimes.push(i);
|
|
10
|
-
}
|
|
11
|
-
return coprimes;
|
|
12
|
-
};
|
|
13
|
-
exports.coprimesOf = coprimesOf;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { dividersOf } from "./dividersOf";
|
|
2
|
-
|
|
3
|
-
export const nonDivisorOf = (nb: number) => {
|
|
4
|
-
let nonDividers = [];
|
|
5
|
-
let dividers = dividersOf(nb);
|
|
6
|
-
|
|
7
|
-
for (let i = 2; i < nb; i++) {
|
|
8
|
-
if (nb % i !== 0) nonDividers.push(i);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return nonDividers;
|
|
12
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* returns array of prime factors
|
|
3
|
-
* e.g 12 -> [2, 2, 3]
|
|
4
|
-
*/
|
|
5
|
-
export const primeFactors = (a: number): number[] => {
|
|
6
|
-
const factors: number[] = [];
|
|
7
|
-
let divisor = 2;
|
|
8
|
-
|
|
9
|
-
while (a >= 2) {
|
|
10
|
-
if (a % divisor === 0) {
|
|
11
|
-
factors.push(divisor);
|
|
12
|
-
a = a / divisor;
|
|
13
|
-
} else {
|
|
14
|
-
divisor++;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return factors;
|
|
18
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const decimalPartLengthOf = (x: number) => {
|
|
2
|
-
function hasFraction(x: number) {
|
|
3
|
-
return Math.abs(Math.round(x) - x) > 1e-10;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
let count = 0;
|
|
7
|
-
// multiply by increasing powers of 10 until the fractional part is ~ 0
|
|
8
|
-
while (hasFraction(x * 10 ** count) && isFinite(10 ** count)) count++;
|
|
9
|
-
return count;
|
|
10
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @returns random [[a, b[[
|
|
3
|
-
*/
|
|
4
|
-
export const randint = (a: number, b?: number, excludes?: number[]): number => {
|
|
5
|
-
if (b === undefined) return Math.floor(Math.random() * a);
|
|
6
|
-
if (!excludes) return a + Math.floor(Math.random() * (b - a));
|
|
7
|
-
let res;
|
|
8
|
-
do {
|
|
9
|
-
res = a + Math.floor(Math.random() * (b - a));
|
|
10
|
-
} while (excludes.includes(res));
|
|
11
|
-
return res;
|
|
12
|
-
};
|
package/src/mathutils/round.ts
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { randint } from "../../mathutils/random/randint";
|
|
2
|
-
import { Node } from "../../tree/nodes/node";
|
|
3
|
-
import { NumberNode } from "../../tree/nodes/numbers/numberNode";
|
|
4
|
-
import { Integer } from "../integer/integer";
|
|
5
|
-
import { Nombre, NumberType } from "../nombre";
|
|
6
|
-
|
|
7
|
-
export abstract class DecimalConstructor {
|
|
8
|
-
static randomFracPart(precision: number): string {
|
|
9
|
-
let decimals = "";
|
|
10
|
-
for (let i = 0; i < precision; i++) {
|
|
11
|
-
decimals += randint(i === precision - 1 ? 1 : 0, 10);
|
|
12
|
-
}
|
|
13
|
-
return decimals;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static random(min: number, max: number, precision: number): Decimal {
|
|
17
|
-
const int = randint(min, max) + "";
|
|
18
|
-
const decimals = DecimalConstructor.randomFracPart(precision);
|
|
19
|
-
return DecimalConstructor.fromParts(int, decimals);
|
|
20
|
-
}
|
|
21
|
-
static fromParts(intPart: string, decimalPart: string): Decimal {
|
|
22
|
-
return new Decimal(Number("" + intPart + "." + decimalPart));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class Decimal implements Nombre {
|
|
27
|
-
value: number;
|
|
28
|
-
tex: string;
|
|
29
|
-
type = NumberType.Decimal;
|
|
30
|
-
precision: number;
|
|
31
|
-
intPart: number;
|
|
32
|
-
decimalPart: string;
|
|
33
|
-
constructor(value: number) {
|
|
34
|
-
this.value = value;
|
|
35
|
-
this.tex = value + "";
|
|
36
|
-
let [intPartString, decimalPartString] = (value + "").split(".");
|
|
37
|
-
this.intPart = Number(intPartString);
|
|
38
|
-
this.decimalPart = decimalPartString || "";
|
|
39
|
-
this.precision = this.decimalPart.length;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @param precision 0 = unité, 1 = dizieme, ... , -1 : dizaine
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
round(precision: number): Nombre {
|
|
48
|
-
const intPartString = this.intPart + "";
|
|
49
|
-
|
|
50
|
-
if (precision < 0) {
|
|
51
|
-
if (precision < -intPartString.length) throw Error("can't round to higher precision");
|
|
52
|
-
return new Integer(this.intPart).round(-precision);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (precision > this.precision) throw Error("can't round to higher precision");
|
|
56
|
-
if (precision === this.precision) return this;
|
|
57
|
-
|
|
58
|
-
let newFracPart = "",
|
|
59
|
-
newIntPart = "";
|
|
60
|
-
|
|
61
|
-
const shouldRoundUp = Number(this.decimalPart[precision]) > 4;
|
|
62
|
-
|
|
63
|
-
if (shouldRoundUp) {
|
|
64
|
-
let retenue = true;
|
|
65
|
-
let i = precision - 1;
|
|
66
|
-
while (retenue) {
|
|
67
|
-
if (i > -1) {
|
|
68
|
-
const nb = (Number(this.decimalPart[i]) + 1) % 10;
|
|
69
|
-
if (nb || newFracPart) {
|
|
70
|
-
newFracPart = nb.toString() + newFracPart;
|
|
71
|
-
}
|
|
72
|
-
if (nb !== 0) {
|
|
73
|
-
retenue = false;
|
|
74
|
-
for (let j = i - 1; j > -1; j--) {
|
|
75
|
-
newFracPart = this.decimalPart[j] + newFracPart;
|
|
76
|
-
}
|
|
77
|
-
newIntPart = intPartString;
|
|
78
|
-
} else i--;
|
|
79
|
-
} else {
|
|
80
|
-
const nb = (Number(intPartString[i + intPartString.length]) + 1) % 10;
|
|
81
|
-
newIntPart = nb + "" + newIntPart;
|
|
82
|
-
if (nb !== 0) {
|
|
83
|
-
retenue = false;
|
|
84
|
-
for (let j = i + intPartString.length - 1; j > -1; j--) {
|
|
85
|
-
newIntPart = intPartString[j] + newIntPart;
|
|
86
|
-
}
|
|
87
|
-
} else i--;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
let retenue = true;
|
|
92
|
-
let i = precision - 1;
|
|
93
|
-
while (retenue) {
|
|
94
|
-
if (i > -1) {
|
|
95
|
-
const nb = Number(this.decimalPart[i]);
|
|
96
|
-
if (nb || newFracPart) {
|
|
97
|
-
newFracPart = nb.toString() + newFracPart;
|
|
98
|
-
}
|
|
99
|
-
if (nb !== 0) {
|
|
100
|
-
retenue = false;
|
|
101
|
-
for (let j = i - 1; j > -1; j--) {
|
|
102
|
-
newFracPart = this.decimalPart[j] + newFracPart;
|
|
103
|
-
}
|
|
104
|
-
newIntPart = intPartString;
|
|
105
|
-
} else i--;
|
|
106
|
-
} else {
|
|
107
|
-
newIntPart = intPartString;
|
|
108
|
-
retenue = false;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return DecimalConstructor.fromParts(newIntPart, newFracPart);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
multiplyByPowerOfTen(power: number) {
|
|
116
|
-
let newIntPart = "",
|
|
117
|
-
newFracPart = "";
|
|
118
|
-
|
|
119
|
-
if (power > -1) {
|
|
120
|
-
newIntPart = this.intPart + "";
|
|
121
|
-
for (let i = 0; i < power; i++) {
|
|
122
|
-
newIntPart += i > this.decimalPart.length - 1 ? "0" : this.decimalPart[i];
|
|
123
|
-
}
|
|
124
|
-
newFracPart = this.decimalPart.slice(power);
|
|
125
|
-
} else {
|
|
126
|
-
const intPartString = this.intPart + "";
|
|
127
|
-
newFracPart = this.decimalPart;
|
|
128
|
-
for (let i = intPartString.length - 1; i > intPartString.length - 1 + power; i--) {
|
|
129
|
-
newFracPart = (i < 0 ? "0" : intPartString[i]) + newFracPart;
|
|
130
|
-
}
|
|
131
|
-
if (power + intPartString.length < 1) newIntPart = "0";
|
|
132
|
-
else newIntPart = intPartString.slice(0, power + intPartString.length);
|
|
133
|
-
}
|
|
134
|
-
return DecimalConstructor.fromParts(newIntPart, newFracPart);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
toTree(): Node {
|
|
138
|
-
return new NumberNode(this.value);
|
|
139
|
-
}
|
|
140
|
-
}
|