math-exercises 1.1.1 → 1.2.1
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/package.json +1 -1
- package/src/exercises/calcul/addAndSub.js +19 -13
- package/src/exercises/calcul/addAndSub.ts +31 -23
- package/src/exercises/calcul/fractions/fractionAndIntegerDivision.js +35 -0
- package/src/exercises/calcul/fractions/fractionAndIntegerDivision.ts +38 -0
- package/src/exercises/calcul/fractions/fractionAndIntegerProduct.js +31 -0
- package/src/exercises/calcul/fractions/fractionAndIntegerProduct.ts +32 -0
- package/src/exercises/calcul/fractions/fractionAndIntegerSum.js +32 -0
- package/src/exercises/calcul/fractions/fractionAndIntegerSum.ts +31 -0
- package/src/exercises/calcul/fractions/fractionsDivision.js +29 -0
- package/src/exercises/calcul/fractions/fractionsDivision.ts +30 -0
- package/src/exercises/calcul/fractions/fractionsProduct.js +29 -0
- package/src/exercises/calcul/fractions/fractionsProduct.ts +29 -0
- package/src/exercises/calcul/fractions/fractionsSum.js +29 -0
- package/src/exercises/calcul/fractions/fractionsSum.ts +28 -0
- package/src/exercises/calcul/fractions/simplifyFraction.js +25 -0
- package/src/exercises/calcul/fractions/simplifyFraction.ts +24 -0
- package/src/exercises/calcul/operationsPriorities.js +89 -0
- package/src/exercises/calcul/operationsPriorities.ts +118 -0
- package/src/exercises/calcul/rounding/roundToUnit.js +70 -0
- package/src/exercises/calcul/rounding/roundToUnit.ts +68 -0
- package/src/exercises/calculLitteral/distributivity/allIdentities.js +1 -0
- package/src/exercises/calculLitteral/distributivity/allIdentities.ts +1 -0
- package/src/exercises/calculLitteral/distributivity/doubleDistributivity.js +1 -0
- package/src/exercises/calculLitteral/distributivity/doubleDistributivity.ts +2 -1
- package/src/exercises/calculLitteral/distributivity/firstIdentity.js +1 -0
- package/src/exercises/calculLitteral/distributivity/firstIdentity.ts +2 -1
- package/src/exercises/calculLitteral/distributivity/secondIdentity.js +1 -0
- package/src/exercises/calculLitteral/distributivity/secondIdentity.ts +2 -1
- package/src/exercises/calculLitteral/distributivity/simpleDistributivity.js +1 -0
- package/src/exercises/calculLitteral/distributivity/simpleDistributivity.ts +2 -1
- package/src/exercises/calculLitteral/distributivity/thirdIdentity.js +1 -0
- package/src/exercises/calculLitteral/distributivity/thirdIdentity.ts +2 -1
- package/src/exercises/calculLitteral/equation/equationType1Exercise.js +1 -0
- package/src/exercises/calculLitteral/equation/equationType1Exercise.ts +1 -0
- package/src/exercises/calculLitteral/equation/equationType2Exercise.js +1 -0
- package/src/exercises/calculLitteral/equation/equationType2Exercise.ts +1 -0
- package/src/exercises/calculLitteral/equation/equationType3Exercise.js +1 -0
- package/src/exercises/calculLitteral/equation/equationType3Exercise.ts +1 -0
- package/src/exercises/calculLitteral/equation/equationType4Exercise.js +1 -0
- package/src/exercises/calculLitteral/equation/equationType4Exercise.ts +1 -0
- package/src/exercises/calculLitteral/factorisation/factoType1Exercise.js +2 -6
- package/src/exercises/calculLitteral/factorisation/factoType1Exercise.ts +3 -7
- package/src/exercises/calculLitteral/reduction.ts +27 -0
- package/src/exercises/exercise.ts +1 -0
- package/src/exercises/exercises.js +54 -0
- package/src/exercises/exercises.ts +58 -0
- package/src/exercises/powers/powersDivision.js +46 -0
- package/src/exercises/powers/powersDivision.ts +51 -0
- package/src/exercises/powers/powersOfTenToDecimal.js +33 -0
- package/src/exercises/powers/powersOfTenToDecimal.ts +37 -0
- package/src/exercises/powers/powersPower.js +45 -0
- package/src/exercises/powers/powersPower.ts +55 -0
- package/src/exercises/powers/powersProduct.js +46 -0
- package/src/exercises/powers/powersProduct.ts +51 -0
- package/src/exercises/powers/scientificToDecimal.js +38 -0
- package/src/exercises/powers/scientificToDecimal.ts +44 -0
- package/src/exercises/squareRoots/simpifySquareRoot.js +1 -0
- package/src/exercises/squareRoots/simpifySquareRoot.ts +1 -0
- package/src/index.js +5 -0
- package/src/index.ts +5 -16
- package/src/mathutils/arithmetic/coprimesOf.js +13 -0
- package/src/mathutils/arithmetic/coprimesOf.ts +9 -0
- package/src/mathutils/arithmetic/dividersOf.ts +7 -0
- package/src/mathutils/arithmetic/lcd.js +12 -0
- package/src/mathutils/arithmetic/lcd.ts +7 -0
- package/src/mathutils/arithmetic/nonCoprimesOf.ts +9 -0
- package/src/mathutils/arithmetic/nonDividersOf.ts +12 -0
- package/src/mathutils/decimals/decimalPartLengthOf.ts +10 -0
- package/src/mathutils/random/randint.js +11 -2
- package/src/mathutils/random/randint.ts +10 -2
- package/src/numbers/decimals/decimal.js +144 -0
- package/src/numbers/decimals/decimal.ts +140 -0
- package/src/numbers/integer/integer.js +61 -4
- package/src/numbers/integer/integer.ts +58 -7
- package/src/numbers/integer/power.js +53 -0
- package/src/numbers/integer/power.ts +49 -0
- package/src/numbers/nombre.js +3 -2
- package/src/numbers/nombre.ts +2 -0
- package/src/numbers/rationals/rational.js +96 -10
- package/src/numbers/rationals/rational.ts +81 -15
- package/src/numbers/reals/real.js +2 -0
- package/src/numbers/reals/real.ts +3 -1
- package/src/numbers/reals/squareRoot.ts +3 -10
- package/src/polynomials/affine.ts +2 -6
- package/src/polynomials/polynomial.js +4 -13
- package/src/polynomials/polynomial.ts +8 -25
- package/src/tree/latexParser/latexParse.js +81 -34
- package/src/tree/latexParser/latexParse.ts +85 -39
- package/src/tree/nodes/functions/functionNode.js +19 -0
- package/src/tree/nodes/functions/functionNode.ts +18 -0
- package/src/tree/nodes/functions/oppositeNode.js +30 -0
- package/src/tree/nodes/functions/oppositeNode.ts +12 -0
- package/src/tree/nodes/functions/sqrtNode.js +24 -9
- package/src/tree/nodes/functions/sqrtNode.ts +5 -9
- package/src/tree/nodes/node.ts +1 -3
- package/src/tree/nodes/numbers/numberNode.js +3 -6
- package/src/tree/nodes/numbers/numberNode.ts +4 -7
- package/src/tree/nodes/operators/addNode.js +23 -8
- package/src/tree/nodes/operators/addNode.ts +3 -7
- package/src/tree/nodes/operators/divideNode.js +21 -9
- package/src/tree/nodes/operators/divideNode.ts +4 -11
- package/src/tree/nodes/operators/equalNode.js +20 -8
- package/src/tree/nodes/operators/equalNode.ts +3 -9
- package/src/tree/nodes/operators/fractionNode.js +34 -0
- package/src/tree/nodes/operators/fractionNode.ts +16 -0
- package/src/tree/nodes/operators/multiplyNode.js +20 -8
- package/src/tree/nodes/operators/multiplyNode.ts +3 -9
- package/src/tree/nodes/operators/operatorNode.js +35 -0
- package/src/tree/nodes/operators/operatorNode.ts +35 -2
- package/src/tree/nodes/operators/powerNode.js +20 -8
- package/src/tree/nodes/operators/powerNode.ts +3 -8
- package/src/tree/nodes/operators/substractNode.js +20 -8
- package/src/tree/nodes/operators/substractNode.ts +3 -9
- package/src/tree/nodes/variables/variableNode.js +1 -4
- package/src/tree/nodes/variables/variableNode.ts +4 -7
- package/src/utils/coin.js +7 -0
- package/src/utils/coin.ts +3 -0
- package/src/utils/shuffle.js +15 -4
- package/src/utils/shuffle.ts +7 -5
- package/src/exercises/calcul/priority.ts +0 -33
- package/src/expression/expression.js +0 -9
- package/src/expression/expression.ts +0 -13
- package/src/numbers/rationals/division.ts +0 -0
- package/src/tree/nodes/operators/oppositeNode.ts +0 -17
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorNode } from "./operatorNode";
|
|
2
|
+
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
3
|
|
|
4
|
-
export class MultiplyNode
|
|
5
|
-
leftChild: Node;
|
|
6
|
-
rightChild: Node;
|
|
7
|
-
type: NodeType = NodeType.operator;
|
|
8
|
-
id: string = "multiply";
|
|
9
|
-
tex = "\\times";
|
|
4
|
+
export class MultiplyNode extends OperatorNode {
|
|
10
5
|
constructor(leftChild: Node, rightChild: Node) {
|
|
11
|
-
|
|
12
|
-
this.rightChild = rightChild;
|
|
6
|
+
super(OperatorIds.multiply, leftChild, rightChild, true, "\\times");
|
|
13
7
|
}
|
|
14
8
|
|
|
15
9
|
toString(): string {
|
|
@@ -1,2 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
+
exports.OperatorNode = exports.OperatorIds = void 0;
|
|
4
|
+
var coin_1 = require("../../../utils/coin");
|
|
5
|
+
var node_1 = require("../node");
|
|
6
|
+
var OperatorIds;
|
|
7
|
+
(function (OperatorIds) {
|
|
8
|
+
OperatorIds[OperatorIds["add"] = 0] = "add";
|
|
9
|
+
OperatorIds[OperatorIds["substract"] = 1] = "substract";
|
|
10
|
+
OperatorIds[OperatorIds["multiply"] = 2] = "multiply";
|
|
11
|
+
OperatorIds[OperatorIds["fraction"] = 3] = "fraction";
|
|
12
|
+
OperatorIds[OperatorIds["divide"] = 4] = "divide";
|
|
13
|
+
OperatorIds[OperatorIds["power"] = 5] = "power";
|
|
14
|
+
OperatorIds[OperatorIds["equal"] = 6] = "equal";
|
|
15
|
+
})(OperatorIds = exports.OperatorIds || (exports.OperatorIds = {}));
|
|
16
|
+
var OperatorNode = /** @class */ (function () {
|
|
17
|
+
function OperatorNode(id, leftChild, rightChild, isCommutative, tex) {
|
|
18
|
+
this.type = node_1.NodeType.operator;
|
|
19
|
+
this.id = id;
|
|
20
|
+
this.leftChild = leftChild;
|
|
21
|
+
this.rightChild = rightChild;
|
|
22
|
+
this.isCommutative = isCommutative;
|
|
23
|
+
this.tex = tex;
|
|
24
|
+
}
|
|
25
|
+
/**shuffles in place */
|
|
26
|
+
OperatorNode.prototype.shuffle = function () {
|
|
27
|
+
var _a;
|
|
28
|
+
if (!this.isCommutative)
|
|
29
|
+
return this;
|
|
30
|
+
if ((0, coin_1.coin)())
|
|
31
|
+
return this;
|
|
32
|
+
_a = [this.rightChild, this.leftChild], this.leftChild = _a[0], this.rightChild = _a[1];
|
|
33
|
+
return this;
|
|
34
|
+
};
|
|
35
|
+
return OperatorNode;
|
|
36
|
+
}());
|
|
37
|
+
exports.OperatorNode = OperatorNode;
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { coin } from "../../../utils/coin";
|
|
2
|
+
import { Node, NodeType } from "../node";
|
|
3
|
+
|
|
4
|
+
export enum OperatorIds {
|
|
5
|
+
add,
|
|
6
|
+
substract,
|
|
7
|
+
multiply,
|
|
8
|
+
fraction,
|
|
9
|
+
divide,
|
|
10
|
+
power,
|
|
11
|
+
equal,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export abstract class OperatorNode implements Node {
|
|
15
|
+
id: OperatorIds;
|
|
16
|
+
leftChild: Node;
|
|
17
|
+
rightChild: Node;
|
|
18
|
+
isCommutative: boolean;
|
|
19
|
+
type = NodeType.operator;
|
|
20
|
+
tex: string;
|
|
21
|
+
constructor(id: OperatorIds, leftChild: Node, rightChild: Node, isCommutative: boolean, tex: string) {
|
|
22
|
+
this.id = id;
|
|
23
|
+
this.leftChild = leftChild;
|
|
24
|
+
this.rightChild = rightChild;
|
|
25
|
+
this.isCommutative = isCommutative;
|
|
26
|
+
this.tex = tex;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**shuffles in place */
|
|
30
|
+
shuffle(): Node {
|
|
31
|
+
if (!this.isCommutative) return this;
|
|
32
|
+
if (coin()) return this;
|
|
33
|
+
[this.leftChild, this.rightChild] = [this.rightChild, this.leftChild];
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
3
36
|
}
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
exports.__esModule = true;
|
|
3
18
|
exports.PowerNode = void 0;
|
|
4
|
-
var
|
|
5
|
-
var PowerNode = /** @class */ (function () {
|
|
19
|
+
var operatorNode_1 = require("./operatorNode");
|
|
20
|
+
var PowerNode = /** @class */ (function (_super) {
|
|
21
|
+
__extends(PowerNode, _super);
|
|
6
22
|
function PowerNode(leftChild, rightChild) {
|
|
7
|
-
this.
|
|
8
|
-
this.type = node_1.NodeType.operator;
|
|
9
|
-
this.id = "power";
|
|
10
|
-
this.leftChild = leftChild;
|
|
11
|
-
this.rightChild = rightChild;
|
|
23
|
+
return _super.call(this, operatorNode_1.OperatorIds.power, leftChild, rightChild, false, "^") || this;
|
|
12
24
|
}
|
|
13
25
|
PowerNode.prototype.toString = function () {
|
|
14
26
|
return "(".concat(this.leftChild, ")^{").concat(this.rightChild, "}");
|
|
15
27
|
};
|
|
16
28
|
return PowerNode;
|
|
17
|
-
}());
|
|
29
|
+
}(operatorNode_1.OperatorNode));
|
|
18
30
|
exports.PowerNode = PowerNode;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { Node, NodeType } from "../node";
|
|
2
|
+
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
2
3
|
|
|
3
|
-
export class PowerNode
|
|
4
|
-
tex = "^";
|
|
5
|
-
type = NodeType.operator;
|
|
6
|
-
id = "power";
|
|
7
|
-
leftChild: Node;
|
|
8
|
-
rightChild: Node;
|
|
4
|
+
export class PowerNode extends OperatorNode {
|
|
9
5
|
constructor(leftChild: Node, rightChild: Node) {
|
|
10
|
-
|
|
11
|
-
this.rightChild = rightChild;
|
|
6
|
+
super(OperatorIds.power, leftChild, rightChild, false, "^");
|
|
12
7
|
}
|
|
13
8
|
|
|
14
9
|
toString(): string {
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
exports.__esModule = true;
|
|
3
18
|
exports.SubstractNode = void 0;
|
|
4
|
-
var
|
|
5
|
-
var SubstractNode = /** @class */ (function () {
|
|
19
|
+
var operatorNode_1 = require("./operatorNode");
|
|
20
|
+
var SubstractNode = /** @class */ (function (_super) {
|
|
21
|
+
__extends(SubstractNode, _super);
|
|
6
22
|
function SubstractNode(leftChild, rightChild) {
|
|
7
|
-
this.
|
|
8
|
-
this.id = "substract";
|
|
9
|
-
this.tex = "-";
|
|
10
|
-
this.leftChild = leftChild;
|
|
11
|
-
this.rightChild = rightChild;
|
|
23
|
+
return _super.call(this, operatorNode_1.OperatorIds.substract, leftChild, rightChild, false, "-") || this;
|
|
12
24
|
}
|
|
13
25
|
SubstractNode.prototype.toString = function () {
|
|
14
26
|
return "".concat(this.leftChild, "-(").concat(this.rightChild, ")");
|
|
15
27
|
};
|
|
16
28
|
return SubstractNode;
|
|
17
|
-
}());
|
|
29
|
+
}(operatorNode_1.OperatorNode));
|
|
18
30
|
exports.SubstractNode = SubstractNode;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorNode } from "./operatorNode";
|
|
2
|
+
import { OperatorIds, OperatorNode } from "./operatorNode";
|
|
3
3
|
|
|
4
|
-
export class SubstractNode
|
|
5
|
-
leftChild: Node;
|
|
6
|
-
rightChild: Node;
|
|
7
|
-
type: NodeType = NodeType.operator;
|
|
8
|
-
id: string = "substract";
|
|
9
|
-
tex = "-";
|
|
4
|
+
export class SubstractNode extends OperatorNode {
|
|
10
5
|
constructor(leftChild: Node, rightChild: Node) {
|
|
11
|
-
|
|
12
|
-
this.rightChild = rightChild;
|
|
6
|
+
super(OperatorIds.substract, leftChild, rightChild, false, "-");
|
|
13
7
|
}
|
|
14
8
|
toString(): string {
|
|
15
9
|
return `${this.leftChild}-(${this.rightChild})`;
|
|
@@ -4,13 +4,10 @@ exports.VariableNode = void 0;
|
|
|
4
4
|
var node_1 = require("../node");
|
|
5
5
|
var VariableNode = /** @class */ (function () {
|
|
6
6
|
function VariableNode(tex) {
|
|
7
|
-
this.
|
|
8
|
-
this.leftChild = null;
|
|
9
|
-
this.rightChild = null;
|
|
7
|
+
this.type = node_1.NodeType.variable;
|
|
10
8
|
if (tex.length !== 1 || !tex.match("[a-zA-Z]"))
|
|
11
9
|
throw Error("variable must be a letter");
|
|
12
10
|
this.tex = tex;
|
|
13
|
-
this.type = node_1.NodeType.variable;
|
|
14
11
|
}
|
|
15
12
|
VariableNode.prototype.toString = function () {
|
|
16
13
|
return "".concat(this.tex);
|
|
@@ -2,16 +2,13 @@ import { Node, NodeType } from "../node";
|
|
|
2
2
|
|
|
3
3
|
export class VariableNode implements Node {
|
|
4
4
|
tex: string;
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
leftChild = null;
|
|
8
|
-
rightChild = null;
|
|
5
|
+
type = NodeType.variable;
|
|
6
|
+
|
|
9
7
|
constructor(tex: string) {
|
|
10
|
-
if (tex.length !== 1 || !tex.match("[a-zA-Z]"))
|
|
11
|
-
throw Error("variable must be a letter");
|
|
8
|
+
if (tex.length !== 1 || !tex.match("[a-zA-Z]")) throw Error("variable must be a letter");
|
|
12
9
|
this.tex = tex;
|
|
13
|
-
this.type = NodeType.variable;
|
|
14
10
|
}
|
|
11
|
+
|
|
15
12
|
toString(): string {
|
|
16
13
|
return `${this.tex}`;
|
|
17
14
|
}
|
package/src/utils/shuffle.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
2
11
|
exports.__esModule = true;
|
|
3
12
|
exports.shuffle = void 0;
|
|
4
13
|
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
|
5
14
|
function shuffle(array) {
|
|
6
|
-
|
|
15
|
+
var res = __spreadArray([], array, true);
|
|
16
|
+
for (var i = res.length - 1; i > 0; i--) {
|
|
7
17
|
var j = Math.floor(Math.random() * (i + 1));
|
|
8
|
-
var temp =
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
var temp = res[i];
|
|
19
|
+
res[i] = res[j];
|
|
20
|
+
res[j] = temp;
|
|
11
21
|
}
|
|
22
|
+
return res;
|
|
12
23
|
}
|
|
13
24
|
exports.shuffle = shuffle;
|
package/src/utils/shuffle.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
|
2
|
-
export function shuffle<T>(array: T[]) {
|
|
3
|
-
|
|
2
|
+
export function shuffle<T>(array: T[]): T[] {
|
|
3
|
+
const res = [...array];
|
|
4
|
+
for (var i = res.length - 1; i > 0; i--) {
|
|
4
5
|
var j = Math.floor(Math.random() * (i + 1));
|
|
5
|
-
var temp =
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var temp = res[i];
|
|
7
|
+
res[i] = res[j];
|
|
8
|
+
res[j] = temp;
|
|
8
9
|
}
|
|
10
|
+
return res;
|
|
9
11
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { randint } from "../../mathutils/random/randint";
|
|
2
|
-
import { Interval } from "../../sets/intervals/intervals";
|
|
3
|
-
import { Exercise, Question } from "../exercise";
|
|
4
|
-
import { getDistinctQuestions } from "../utils/getDistinctQuestions";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* a*b ±c±d
|
|
8
|
-
* a/b ±c±d
|
|
9
|
-
*/
|
|
10
|
-
// export const priorityExercise: Exercise = {
|
|
11
|
-
// connector: "=",
|
|
12
|
-
// instruction: "Simplifier : ",
|
|
13
|
-
// label: "Priorités opératoires",
|
|
14
|
-
// levels: ["6", "5", "4"],
|
|
15
|
-
// section: "Calculs",
|
|
16
|
-
// generator: (nb: number) => getDistinctQuestions(getPriorityQuestions, nb),
|
|
17
|
-
// };
|
|
18
|
-
|
|
19
|
-
// export function getPriorityQuestions(): Question {
|
|
20
|
-
// const nbOfTerms = randint(3, 5);
|
|
21
|
-
// const max = 20;
|
|
22
|
-
// const terms = [];
|
|
23
|
-
// const interval = new Interval(`[[${-max}; ${max}]]`).exclude(0);
|
|
24
|
-
// for (let i = 0; i < nbOfTerms; i++) {
|
|
25
|
-
// terms.push(interval.getRandomElement());
|
|
26
|
-
// }
|
|
27
|
-
// const tex = new Latex("");
|
|
28
|
-
// terms.forEach((term) => tex.add(term));
|
|
29
|
-
// const statement = tex.toTex();
|
|
30
|
-
// const answer = terms.reduce((acc, curr) => acc + curr).toString();
|
|
31
|
-
// const question: Question = { statement, answer };
|
|
32
|
-
// return question;
|
|
33
|
-
// }
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.ExpressionType = void 0;
|
|
4
|
-
var ExpressionType;
|
|
5
|
-
(function (ExpressionType) {
|
|
6
|
-
ExpressionType[ExpressionType["real"] = 0] = "real";
|
|
7
|
-
ExpressionType[ExpressionType["affine"] = 1] = "affine";
|
|
8
|
-
ExpressionType[ExpressionType["polynomial"] = 2] = "polynomial";
|
|
9
|
-
})(ExpressionType = exports.ExpressionType || (exports.ExpressionType = {}));
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export enum ExpressionType {
|
|
2
|
-
real,
|
|
3
|
-
affine,
|
|
4
|
-
polynomial,
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface Expression {
|
|
8
|
-
// type: ExpressionType;
|
|
9
|
-
add(expression: Expression): Expression;
|
|
10
|
-
multiply(expression: Expression): Expression;
|
|
11
|
-
opposite(): Expression;
|
|
12
|
-
toTex(): string;
|
|
13
|
-
}
|
|
File without changes
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Node, NodeType } from "../node";
|
|
2
|
-
import { OperatorNode } from "./operatorNode";
|
|
3
|
-
|
|
4
|
-
export class OppositeNode implements Node, OperatorNode {
|
|
5
|
-
leftChild: Node;
|
|
6
|
-
rightChild: null;
|
|
7
|
-
type: NodeType = NodeType.operator;
|
|
8
|
-
id: string = "opposite";
|
|
9
|
-
tex = "-";
|
|
10
|
-
constructor(leftChild: Node) {
|
|
11
|
-
this.leftChild = leftChild;
|
|
12
|
-
this.rightChild = null;
|
|
13
|
-
}
|
|
14
|
-
toString(): string {
|
|
15
|
-
return `-(${this.leftChild})`;
|
|
16
|
-
}
|
|
17
|
-
}
|