math-exercises 1.3.2 → 1.3.4

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.
Files changed (89) hide show
  1. package/README.md +71 -71
  2. package/lib/exercises/calcul/addAndSub.js +40 -39
  3. package/lib/exercises/calcul/fractions/fractionAndIntegerDivision.js +35 -34
  4. package/lib/exercises/calcul/fractions/fractionAndIntegerProduct.js +31 -31
  5. package/lib/exercises/calcul/fractions/fractionAndIntegerSum.js +32 -31
  6. package/lib/exercises/calcul/fractions/fractionsDivision.js +29 -28
  7. package/lib/exercises/calcul/fractions/fractionsProduct.js +29 -28
  8. package/lib/exercises/calcul/fractions/fractionsSum.js +29 -28
  9. package/lib/exercises/calcul/fractions/simplifyFraction.js +25 -24
  10. package/lib/exercises/calcul/operationsPriorities.js +88 -88
  11. package/lib/exercises/calcul/rounding/rounding.js +86 -85
  12. package/lib/exercises/calculLitteral/distributivity/allIdentities.js +27 -27
  13. package/lib/exercises/calculLitteral/distributivity/doubleDistributivity.js +31 -30
  14. package/lib/exercises/calculLitteral/distributivity/firstIdentity.js +32 -31
  15. package/lib/exercises/calculLitteral/distributivity/secondIdentity.js +33 -32
  16. package/lib/exercises/calculLitteral/distributivity/simpleDistributivity.js +33 -32
  17. package/lib/exercises/calculLitteral/distributivity/thirdIdentity.js +32 -31
  18. package/lib/exercises/calculLitteral/equation/equationType1Exercise.js +38 -37
  19. package/lib/exercises/calculLitteral/equation/equationType2Exercise.js +41 -40
  20. package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +42 -41
  21. package/lib/exercises/calculLitteral/equation/equationType4Exercise.js +44 -43
  22. package/lib/exercises/calculLitteral/factorisation/factoType1Exercise.js +39 -38
  23. package/lib/exercises/exercise.js +7 -7
  24. package/lib/exercises/exercises.js +85 -95
  25. package/lib/exercises/powers/powersDivision.js +45 -44
  26. package/lib/exercises/powers/powersOfTenToDecimal.js +33 -32
  27. package/lib/exercises/powers/powersPower.js +44 -43
  28. package/lib/exercises/powers/powersProduct.js +45 -44
  29. package/lib/exercises/powers/scientificToDecimal.js +38 -37
  30. package/lib/exercises/squareRoots/simpifySquareRoot.js +28 -27
  31. package/lib/exercises/utils/getDistinctQuestions.js +15 -15
  32. package/lib/geometry/point.js +1 -27
  33. package/lib/index.js +5 -9
  34. package/lib/mathutils/arithmetic/coprimesOf.js +13 -13
  35. package/lib/mathutils/arithmetic/dividersOf.js +12 -12
  36. package/lib/mathutils/arithmetic/gcd.js +7 -7
  37. package/lib/mathutils/arithmetic/isSquare.js +7 -7
  38. package/lib/mathutils/arithmetic/lcd.js +12 -12
  39. package/lib/mathutils/arithmetic/nonCoprimesOf.js +13 -13
  40. package/lib/mathutils/arithmetic/nonDividersOf.js +14 -14
  41. package/lib/mathutils/arithmetic/primeFactors.js +22 -22
  42. package/lib/mathutils/decimals/decimalPartLengthOf.js +14 -14
  43. package/lib/mathutils/random/randint.js +18 -18
  44. package/lib/mathutils/round.js +8 -8
  45. package/lib/numbers/decimals/decimal.js +140 -140
  46. package/lib/numbers/epsilon.js +10 -10
  47. package/lib/numbers/integer/integer.js +68 -68
  48. package/lib/numbers/integer/power.js +52 -52
  49. package/lib/numbers/nombre.js +10 -10
  50. package/lib/numbers/rationals/rational.js +113 -113
  51. package/lib/numbers/reals/real.js +16 -16
  52. package/lib/numbers/reals/squareRoot.js +63 -63
  53. package/lib/polynomials/affine.js +42 -42
  54. package/lib/polynomials/polynomial.js +125 -125
  55. package/lib/sets/discreteSet.js +28 -28
  56. package/lib/sets/emptySet.js +6 -6
  57. package/lib/sets/intervals/intervals.js +108 -108
  58. package/lib/sets/intervals/union.js +1 -1
  59. package/lib/sets/mathSet.js +10 -10
  60. package/lib/sets/mathSetInterface.js +2 -2
  61. package/lib/tree/nodes/functions/functionNode.js +18 -18
  62. package/lib/tree/nodes/functions/oppositeNode.js +13 -26
  63. package/lib/tree/nodes/functions/sqrtNode.js +15 -18
  64. package/lib/tree/nodes/node.js +10 -10
  65. package/lib/tree/nodes/numbers/numberNode.js +15 -18
  66. package/lib/tree/nodes/operators/addNode.js +15 -19
  67. package/lib/tree/nodes/operators/divideNode.js +17 -34
  68. package/lib/tree/nodes/operators/equalNode.js +13 -16
  69. package/lib/tree/nodes/operators/fractionNode.js +17 -20
  70. package/lib/tree/nodes/operators/multiplyNode.js +13 -36
  71. package/lib/tree/nodes/operators/operatorNode.js +35 -35
  72. package/lib/tree/nodes/operators/powerNode.js +13 -33
  73. package/lib/tree/nodes/operators/substractNode.js +13 -24
  74. package/lib/tree/nodes/variables/variableNode.js +16 -19
  75. package/lib/tree/parsers/derivateParser.js +60 -62
  76. package/lib/tree/parsers/latexParser.js +117 -110
  77. package/lib/utils/coin.js +7 -7
  78. package/lib/utils/random.js +7 -7
  79. package/lib/utils/shuffle.js +15 -15
  80. package/package.json +41 -38
  81. package/lib/exercises/calcul/operations/operationsPriorities.js +0 -98
  82. package/lib/exercises/calcul/operations/operationsPrioritiesWithoutRelative.js +0 -111
  83. package/lib/exercises/geometry/cartesian/midpoint.js +0 -29
  84. package/lib/exercises/geometry/vectors/scalarProductViaCoords.js +0 -28
  85. package/lib/exercises/geometry/vectors/scalarProductViaNorms.js +0 -27
  86. package/lib/geometry/vector.js +0 -31
  87. package/lib/mathutils/random/randTupleInt.js +0 -30
  88. package/lib/tree/parsers/simplify.js +0 -51
  89. package/lib/utils/arrayEqual.js +0 -13
@@ -1,110 +1,117 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.latexParser = void 0;
4
+ const functionNode_1 = require("../nodes/functions/functionNode");
5
+ const node_1 = require("../nodes/node");
6
+ const operatorNode_1 = require("../nodes/operators/operatorNode");
7
+ function latexParser(node) {
8
+ if (!node) {
9
+ console.log("parsing a null node ???");
10
+ return "";
11
+ }
12
+ switch (node.type) {
13
+ case node_1.NodeType.variable:
14
+ return node.tex;
15
+ case node_1.NodeType.number:
16
+ return node.tex;
17
+ case node_1.NodeType.operator:
18
+ const operatorNode = node;
19
+ let rightTex = latexParser(operatorNode.rightChild);
20
+ let leftTex = latexParser(operatorNode.leftChild);
21
+ const { leftChild, rightChild } = operatorNode;
22
+ switch (operatorNode.id) {
23
+ case operatorNode_1.OperatorIds.add:
24
+ return `${leftTex} ${rightTex[0] === "-" ? "" : "+ "}${rightTex}`;
25
+ case operatorNode_1.OperatorIds.substract: {
26
+ const needBrackets = (rightChild.type === node_1.NodeType.operator &&
27
+ [operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract].includes(rightChild.id)) ||
28
+ rightTex[0] === "-";
29
+ if (needBrackets)
30
+ rightTex = `(${rightTex})`;
31
+ return `${leftTex} - ${rightTex}`;
32
+ }
33
+ case operatorNode_1.OperatorIds.multiply: {
34
+ if (leftChild.type === node_1.NodeType.operator) {
35
+ if ([operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract, operatorNode_1.OperatorIds.divide].includes(leftChild.id))
36
+ leftTex = `(${leftTex})`;
37
+ }
38
+ let needBrackets = rightTex[0] === "-";
39
+ if (rightChild.type === node_1.NodeType.operator) {
40
+ const operatorRightChild = rightChild;
41
+ needBrackets || (needBrackets = [operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract].includes(operatorRightChild.id));
42
+ }
43
+ if (needBrackets)
44
+ rightTex = `(${rightTex})`;
45
+ // permet de gérer le cas 3*2^x
46
+ let showTimesSign = !isNaN(+rightTex[0]) || rightChild.type === node_1.NodeType.number;
47
+ if (rightChild.type === node_1.NodeType.operator) {
48
+ const operatorRightChild = rightChild;
49
+ showTimesSign || (showTimesSign = [operatorNode_1.OperatorIds.fraction].includes(operatorRightChild.id));
50
+ }
51
+ return `${leftTex}${showTimesSign ? "\\times " : ""}${rightTex}`;
52
+ }
53
+ case operatorNode_1.OperatorIds.divide: {
54
+ if (leftChild.type === node_1.NodeType.operator) {
55
+ if ([operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract, operatorNode_1.OperatorIds.multiply].includes(leftChild.id))
56
+ leftTex = `(${leftTex})`;
57
+ }
58
+ let needBrackets = rightTex[0] === "-";
59
+ if (rightChild.type === node_1.NodeType.operator) {
60
+ const operatorRightChild = rightChild;
61
+ needBrackets || (needBrackets = [operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract].includes(operatorRightChild.id));
62
+ }
63
+ if (needBrackets)
64
+ rightTex = `(${rightTex})`;
65
+ return `${leftTex} \\div ${rightTex}`;
66
+ }
67
+ case operatorNode_1.OperatorIds.fraction: {
68
+ return `\\frac{${leftTex}}{${rightTex}}`;
69
+ }
70
+ case operatorNode_1.OperatorIds.power: {
71
+ let needBrackets = leftTex[0] === "-";
72
+ if (leftChild.type === node_1.NodeType.operator) {
73
+ const childOperator = leftChild;
74
+ needBrackets || (needBrackets = [
75
+ operatorNode_1.OperatorIds.add,
76
+ operatorNode_1.OperatorIds.substract,
77
+ operatorNode_1.OperatorIds.multiply,
78
+ operatorNode_1.OperatorIds.divide,
79
+ operatorNode_1.OperatorIds.fraction,
80
+ operatorNode_1.OperatorIds.power,
81
+ ].includes(childOperator.id));
82
+ }
83
+ if (needBrackets)
84
+ leftTex = `(${leftTex})`;
85
+ return `${leftTex}^{${rightTex}}`;
86
+ }
87
+ case operatorNode_1.OperatorIds.equal: {
88
+ return `${leftTex} = ${rightTex}`;
89
+ }
90
+ default:
91
+ return node.tex;
92
+ }
93
+ case node_1.NodeType.function: {
94
+ const functionNode = node;
95
+ const child = functionNode.child;
96
+ let childTex = latexParser(functionNode.child);
97
+ switch (functionNode.id) {
98
+ case functionNode_1.FunctionsIds.sqrt: {
99
+ return `\\sqrt{${childTex}}`;
100
+ }
101
+ case functionNode_1.FunctionsIds.opposite: {
102
+ let needBrackets = childTex[0] === "-";
103
+ if (child.type === node_1.NodeType.operator) {
104
+ const operatorChild = child;
105
+ needBrackets || (needBrackets = [operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract].includes(operatorChild.id));
106
+ }
107
+ if (needBrackets)
108
+ childTex = `(${childTex})`;
109
+ return `-${childTex}`;
110
+ }
111
+ }
112
+ }
113
+ default:
114
+ return "";
115
+ }
116
+ }
117
+ exports.latexParser = latexParser;
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;
@@ -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;
@@ -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,38 +1,41 @@
1
- {
2
- "name": "math-exercises",
3
- "version": "1.3.2",
4
- "description": "Math exercises generator for middle school and high school",
5
- "main": "src/index.js",
6
- "files": [
7
- "lib/**/*"
8
- ],
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1",
11
- "start:dev": "nodemon",
12
- "build": "tsc",
13
- "prepublish": "tsc"
14
- },
15
- "keywords": [],
16
- "author": "Heureux Hasard",
17
- "license": "ISC",
18
- "devDependencies": {
19
- "@types/node": "^18.11.9",
20
- "nodemon": "^2.0.20",
21
- "prettier": "^2.8.4",
22
- "ts-node": "^10.9.1",
23
- "tslint": "^6.1.3",
24
- "tslint-config-prettier": "^1.18.0",
25
- "typescript": "^4.9.3"
26
- },
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/krirkrirk/math-exercises.git"
30
- },
31
- "bugs": {
32
- "url": "https://github.com/krirkrirk/math-exercises/issues"
33
- },
34
- "homepage": "https://github.com/krirkrirk/math-exercises#readme",
35
- "dependencies": {
36
- "mathjs": "^11.5.1"
37
- }
38
- }
1
+ {
2
+ "name": "math-exercises",
3
+ "version": "1.3.4",
4
+ "description": "Math exercises generator for middle school and high school",
5
+ "main": "src/index.js",
6
+ "files": [
7
+ "lib/**/*"
8
+ ],
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "start:dev": "nodemon",
12
+ "build": "tsc",
13
+ "prepublish": "tsc"
14
+ },
15
+ "keywords": [],
16
+ "author": "Heureux Hasard",
17
+ "license": "ISC",
18
+ "devDependencies": {
19
+ "@types/node": "^18.11.9",
20
+ "nodemon": "^2.0.20",
21
+ "prettier": "^2.8.4",
22
+ "ts-node": "^10.9.1",
23
+ "tslint": "^6.1.3",
24
+ "tslint-config-prettier": "^1.18.0",
25
+ "typescript": "^4.9.3"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/krirkrirk/math-exercises.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/krirkrirk/math-exercises/issues"
33
+ },
34
+ "homepage": "https://github.com/krirkrirk/math-exercises#readme",
35
+ "dependencies": {
36
+ "mathjs": "^11.5.1"
37
+ },
38
+ "exports": {
39
+ ".": "./lib/index.js"
40
+ }
41
+ }
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPriorityQuestions = exports.operationsPriorities = void 0;
4
- const randint_1 = require("../../../mathutils/random/randint");
5
- const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
6
- const addNode_1 = require("../../../tree/nodes/operators/addNode");
7
- const divideNode_1 = require("../../../tree/nodes/operators/divideNode");
8
- const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
9
- const coin_1 = require("../../../utils/coin");
10
- const getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
11
- /**
12
- * a*b ±c±d
13
- * a/b ±c±d
14
- * a*b*c ± d
15
- * a*b±c*d
16
- * a/b ± c*d
17
- */
18
- exports.operationsPriorities = {
19
- id: 'operationsPriorities',
20
- connector: '=',
21
- instruction: 'Calculer :',
22
- label: 'Priorités opératoires',
23
- levels: ['6', '5', '4'],
24
- section: 'Calculs',
25
- isSingleStep: true,
26
- generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getPriorityQuestions, nb),
27
- };
28
- function getPriorityQuestions() {
29
- const type = (0, randint_1.randint)(1, 6);
30
- let startStatement = '';
31
- let answer = '';
32
- let a, b, c, d;
33
- let statement;
34
- switch (type) {
35
- case 1: // a*b ±c±d
36
- [c, d] = [1, 2, 3, 4].map((el) => (0, randint_1.randint)(-10, 11, [0]));
37
- [a, b] = [1, 2].map((el) => (0, randint_1.randint)(-10, 11));
38
- statement = (0, coin_1.coin)()
39
- ? //a*b first ou last
40
- new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new addNode_1.AddNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d)))
41
- : //a*b middle
42
- new addNode_1.AddNode(new addNode_1.AddNode(new numberNode_1.NumberNode(c), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b))), new numberNode_1.NumberNode(d));
43
- statement.shuffle();
44
- startStatement = statement.toTex();
45
- answer = (a * b + c + d).toString();
46
- break;
47
- case 2: // a/b ±c±d
48
- [b, c, d] = [1, 2, 3].map((el) => (0, randint_1.randint)(-10, 11, [0]));
49
- a = b * (0, randint_1.randint)(0, 11);
50
- statement = (0, coin_1.coin)()
51
- ? //a/b first ou last
52
- new addNode_1.AddNode(new divideNode_1.DivideNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new addNode_1.AddNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d)))
53
- : //a/b middle
54
- new addNode_1.AddNode(new addNode_1.AddNode(new numberNode_1.NumberNode(c), new divideNode_1.DivideNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b))), new numberNode_1.NumberNode(d));
55
- statement.shuffle();
56
- startStatement = statement.toTex();
57
- answer = (a / b + c + d).toString();
58
- break;
59
- case 3: // a*b ± c*d
60
- [a, b, c, d] = [1, 2, 3, 4].map((el) => (0, randint_1.randint)(-10, 11));
61
- statement = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d)));
62
- startStatement = statement.toTex();
63
- answer = (a * b + c * d).toString();
64
- break;
65
- case 4: // a*b ± c/d
66
- [a, b] = [1, 2].map((el) => (0, randint_1.randint)(-10, 11));
67
- d = (0, randint_1.randint)(-10, 11, [0]);
68
- c = d * (0, randint_1.randint)(0, 11);
69
- statement = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new divideNode_1.DivideNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d)));
70
- statement.shuffle();
71
- startStatement = statement.toTex();
72
- answer = (a * b + c / d).toString();
73
- break;
74
- case 5: // a/b ± c/d
75
- [b, d] = [1, 2].map((el) => (0, randint_1.randint)(-10, 11, [0]));
76
- a = b * (0, randint_1.randint)(0, 11);
77
- c = d * (0, randint_1.randint)(0, 11);
78
- statement = new addNode_1.AddNode(new divideNode_1.DivideNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new divideNode_1.DivideNode(new numberNode_1.NumberNode(c), new numberNode_1.NumberNode(d)));
79
- startStatement = statement.toTex();
80
- answer = (a / b + c / d).toString();
81
- break;
82
- case 5: // a*b*c ± d
83
- [b, d] = [1, 2].map((el) => (0, randint_1.randint)(-10, 11, [0]));
84
- a = b * (0, randint_1.randint)(0, 11);
85
- c = d * (0, randint_1.randint)(0, 11);
86
- statement = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b)), new numberNode_1.NumberNode(c)), new numberNode_1.NumberNode(d));
87
- statement.shuffle();
88
- startStatement = statement.toTex();
89
- answer = (a * b * c + d).toString();
90
- break;
91
- }
92
- const question = {
93
- startStatement,
94
- answer,
95
- };
96
- return question;
97
- }
98
- exports.getPriorityQuestions = getPriorityQuestions;
@@ -1,111 +0,0 @@
1
- "use strict";
2
- // import { randint } from "../../mathutils/random/randint";
3
- // import { latexParser } from "../../tree/parsers/latexParser";
4
- // import { Node } from "../../tree/nodes/node";
5
- // import { NumberNode } from "../../tree/nodes/numbers/numberNode";
6
- // import { AddNode } from "../../tree/nodes/operators/addNode";
7
- // import { DivideNode } from "../../tree/nodes/operators/divideNode";
8
- // import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode";
9
- // import { coin } from "../../utils/coin";
10
- // import { Exercise, Question } from "../exercise";
11
- // import { getDistinctQuestions } from "../utils/getDistinctQuestions";
12
- // /**
13
- // * a*b ±c±d
14
- // * a/b ±c±d
15
- // * a*b*c ± d
16
- // * a*b±c*d
17
- // * a/b ± c*d
18
- // */
19
- // export const operationsPriorities: Exercise = {
20
- // id: "operationsPrioritiesWithoutRelative",
21
- // connector: "=",
22
- // instruction: "Calculer :",
23
- // label: "Priorités opératoires (sans relatif)",
24
- // levels: ["6", "5", "4"],
25
- // section: "Calculs",
26
- // isSingleStep: true,
27
- // generator: (nb: number) => getDistinctQuestions(getPriorityQuestionsWithoutRelatif, nb),
28
- // };
29
- // export function getPriorityQuestionsWithoutRelatif(): Question {
30
- // const type = randint(1, 6);
31
- // let statement: Node;
32
- // let answer: string = "";
33
- // let a, b, c, d: number;
34
- // switch (type) {
35
- // case 1: // a*b ±c±d
36
- // [c, d] = [1, 2, 3, 4].map((el) => randint(-10, 11, [0]));
37
- // [a, b] = [1, 2].map((el) => randint(-10, 11));
38
- // statement = coin()
39
- // ? //a*b first ou last
40
- // new AddNode(
41
- // new MultiplyNode(new NumberNode(a), new NumberNode(b)),
42
- // new AddNode(new NumberNode(c), new NumberNode(d))
43
- // ).shuffle()
44
- // : //a*b middle
45
- // new AddNode(
46
- // new AddNode(new NumberNode(c), new MultiplyNode(new NumberNode(a), new NumberNode(b))),
47
- // new NumberNode(d)
48
- // );
49
- // answer = (a * b + c + d).toString();
50
- // break;
51
- // case 2: // a/b ±c±d
52
- // [b, c, d] = [1, 2, 3].map((el) => randint(-10, 11, [0]));
53
- // a = b * randint(0, 11);
54
- // statement = coin()
55
- // ? //a/b first ou last
56
- // new AddNode(
57
- // new DivideNode(new NumberNode(a), new NumberNode(b)),
58
- // new AddNode(new NumberNode(c), new NumberNode(d))
59
- // ).shuffle()
60
- // : //a/b middle
61
- // new AddNode(
62
- // new AddNode(new NumberNode(c), new DivideNode(new NumberNode(a), new NumberNode(b))),
63
- // new NumberNode(d)
64
- // );
65
- // answer = (a / b + c + d).toString();
66
- // break;
67
- // case 3: // a*b ± c*d
68
- // [a, b, c, d] = [1, 2, 3, 4].map((el) => randint(-10, 11));
69
- // statement = new AddNode(
70
- // new MultiplyNode(new NumberNode(a), new NumberNode(b)),
71
- // new MultiplyNode(new NumberNode(c), new NumberNode(d))
72
- // );
73
- // answer = (a * b + c * d).toString();
74
- // break;
75
- // case 4: // a*b ± c/d
76
- // [a, b] = [1, 2].map((el) => randint(-10, 11));
77
- // d = randint(-10, 11, [0]);
78
- // c = d * randint(0, 11);
79
- // statement = new AddNode(
80
- // new MultiplyNode(new NumberNode(a), new NumberNode(b)),
81
- // new DivideNode(new NumberNode(c), new NumberNode(d))
82
- // ).shuffle();
83
- // answer = (a * b + c / d).toString();
84
- // break;
85
- // case 5: // a/b ± c/d
86
- // [b, d] = [1, 2].map((el) => randint(-10, 11, [0]));
87
- // a = b * randint(0, 11);
88
- // c = d * randint(0, 11);
89
- // statement = new AddNode(
90
- // new DivideNode(new NumberNode(a), new NumberNode(b)),
91
- // new DivideNode(new NumberNode(c), new NumberNode(d))
92
- // );
93
- // answer = (a / b + c / d).toString();
94
- // break;
95
- // case 5: // a*b*c ± d
96
- // [b, d] = [1, 2].map((el) => randint(-10, 11, [0]));
97
- // a = b * randint(0, 11);
98
- // c = d * randint(0, 11);
99
- // statement = new AddNode(
100
- // new MultiplyNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new NumberNode(c)),
101
- // new NumberNode(d)
102
- // ).shuffle();
103
- // answer = (a * b * c + d).toString();
104
- // break;
105
- // }
106
- // const question: Question = {
107
- // startStatement: latexParser(statement!),
108
- // answer: answer,
109
- // };
110
- // return question;
111
- // }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMidpointQuestion = exports.midpoint = void 0;
4
- const point_1 = require("../../../geometry/point");
5
- const randTupleInt_1 = require("../../../mathutils/random/randTupleInt");
6
- const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
7
- const getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
8
- exports.midpoint = {
9
- id: 'midpoint',
10
- connector: '=',
11
- instruction: '',
12
- label: 'Coordonnées du milieu',
13
- levels: ['3', '2', '1'],
14
- isSingleStep: false,
15
- section: 'Géométrie cartésienne',
16
- generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMidpointQuestion, nb),
17
- };
18
- function getMidpointQuestion() {
19
- const [coords1, coords2] = (0, randTupleInt_1.distinctRandTupleInt)(2, 2, { from: -9, to: 10 });
20
- const A = new point_1.Point('A', new numberNode_1.NumberNode(coords1[0]), new numberNode_1.NumberNode(coords1[1]));
21
- const B = new point_1.Point('B', new numberNode_1.NumberNode(coords2[0]), new numberNode_1.NumberNode(coords2[1]));
22
- const question = {
23
- instruction: `Soit $${A.toTexWithCoords()}$ et $${B.toTexWithCoords()}$. Quelles sont les coordonnées du milieu $I$ de $[AB]$ ?`,
24
- startStatement: 'I',
25
- answer: A.midpoint(B).toTexWithCoords(),
26
- };
27
- return question;
28
- }
29
- exports.getMidpointQuestion = getMidpointQuestion;