math-exercises 1.1.0 → 1.2.0

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 (124) hide show
  1. package/package.json +2 -2
  2. package/src/exercises/calcul/addAndSub.js +19 -13
  3. package/src/exercises/calcul/addAndSub.ts +31 -23
  4. package/src/exercises/calcul/fractions/fractionAndIntegerDivision.js +35 -0
  5. package/src/exercises/calcul/fractions/fractionAndIntegerDivision.ts +38 -0
  6. package/src/exercises/calcul/fractions/fractionAndIntegerProduct.js +31 -0
  7. package/src/exercises/calcul/fractions/fractionAndIntegerProduct.ts +32 -0
  8. package/src/exercises/calcul/fractions/fractionAndIntegerSum.js +32 -0
  9. package/src/exercises/calcul/fractions/fractionAndIntegerSum.ts +31 -0
  10. package/src/exercises/calcul/fractions/fractionsDivision.js +29 -0
  11. package/src/exercises/calcul/fractions/fractionsDivision.ts +30 -0
  12. package/src/exercises/calcul/fractions/fractionsProduct.js +29 -0
  13. package/src/exercises/calcul/fractions/fractionsProduct.ts +29 -0
  14. package/src/exercises/calcul/fractions/fractionsSum.js +29 -0
  15. package/src/exercises/calcul/fractions/fractionsSum.ts +28 -0
  16. package/src/exercises/calcul/fractions/simplifyFraction.js +25 -0
  17. package/src/exercises/calcul/fractions/simplifyFraction.ts +24 -0
  18. package/src/exercises/calcul/operationsPriorities.js +89 -0
  19. package/src/exercises/calcul/operationsPriorities.ts +118 -0
  20. package/src/exercises/calcul/rounding/roundToUnit.js +70 -0
  21. package/src/exercises/calcul/rounding/roundToUnit.ts +68 -0
  22. package/src/exercises/calculLitteral/distributivity/allIdentities.js +2 -0
  23. package/src/exercises/calculLitteral/distributivity/allIdentities.ts +2 -0
  24. package/src/exercises/calculLitteral/distributivity/doubleDistributivity.js +3 -3
  25. package/src/exercises/calculLitteral/distributivity/doubleDistributivity.ts +2 -0
  26. package/src/exercises/calculLitteral/distributivity/firstIdentity.js +2 -0
  27. package/src/exercises/calculLitteral/distributivity/firstIdentity.ts +2 -0
  28. package/src/exercises/calculLitteral/distributivity/secondIdentity.js +3 -3
  29. package/src/exercises/calculLitteral/distributivity/secondIdentity.ts +2 -0
  30. package/src/exercises/calculLitteral/distributivity/simpleDistributivity.js +3 -3
  31. package/src/exercises/calculLitteral/distributivity/simpleDistributivity.ts +2 -0
  32. package/src/exercises/calculLitteral/distributivity/thirdIdentity.js +4 -2
  33. package/src/exercises/calculLitteral/distributivity/thirdIdentity.ts +2 -0
  34. package/src/exercises/calculLitteral/equation/equationType1Exercise.js +3 -3
  35. package/src/exercises/calculLitteral/equation/equationType1Exercise.ts +4 -5
  36. package/src/exercises/calculLitteral/equation/equationType2Exercise.js +3 -3
  37. package/src/exercises/calculLitteral/equation/equationType2Exercise.ts +5 -5
  38. package/src/exercises/calculLitteral/equation/equationType3Exercise.js +3 -3
  39. package/src/exercises/calculLitteral/equation/equationType3Exercise.ts +5 -5
  40. package/src/exercises/calculLitteral/equation/equationType4Exercise.js +3 -3
  41. package/src/exercises/calculLitteral/equation/equationType4Exercise.ts +7 -12
  42. package/src/exercises/calculLitteral/factorisation/factoType1Exercise.js +4 -9
  43. package/src/exercises/calculLitteral/factorisation/factoType1Exercise.ts +3 -6
  44. package/src/exercises/calculLitteral/reduction.ts +27 -0
  45. package/src/exercises/exercise.ts +2 -0
  46. package/src/exercises/exercises.js +83 -0
  47. package/src/exercises/exercises.ts +58 -0
  48. package/src/exercises/powers/powersDivision.js +46 -0
  49. package/src/exercises/powers/powersDivision.ts +51 -0
  50. package/src/exercises/powers/powersOfTenToDecimal.js +33 -0
  51. package/src/exercises/powers/powersOfTenToDecimal.ts +37 -0
  52. package/src/exercises/powers/powersPower.js +45 -0
  53. package/src/exercises/powers/powersPower.ts +55 -0
  54. package/src/exercises/powers/powersProduct.js +46 -0
  55. package/src/exercises/powers/powersProduct.ts +51 -0
  56. package/src/exercises/powers/scientificToDecimal.js +38 -0
  57. package/src/exercises/powers/scientificToDecimal.ts +44 -0
  58. package/src/exercises/squareRoots/simpifySquareRoot.js +2 -3
  59. package/src/exercises/squareRoots/simpifySquareRoot.ts +2 -0
  60. package/src/index.js +8 -8
  61. package/src/index.ts +5 -16
  62. package/src/mathutils/arithmetic/coprimesOf.js +13 -0
  63. package/src/mathutils/arithmetic/coprimesOf.ts +9 -0
  64. package/src/mathutils/arithmetic/dividersOf.ts +7 -0
  65. package/src/mathutils/arithmetic/lcd.js +12 -0
  66. package/src/mathutils/arithmetic/lcd.ts +7 -0
  67. package/src/mathutils/arithmetic/nonCoprimesOf.ts +9 -0
  68. package/src/mathutils/arithmetic/nonDividersOf.ts +12 -0
  69. package/src/mathutils/decimals/decimalPartLengthOf.ts +10 -0
  70. package/src/mathutils/random/randint.js +11 -2
  71. package/src/mathutils/random/randint.ts +10 -2
  72. package/src/numbers/decimals/decimal.js +144 -0
  73. package/src/numbers/decimals/decimal.ts +140 -0
  74. package/src/numbers/integer/integer.js +61 -4
  75. package/src/numbers/integer/integer.ts +58 -7
  76. package/src/numbers/integer/power.js +53 -0
  77. package/src/numbers/integer/power.ts +49 -0
  78. package/src/numbers/nombre.js +3 -2
  79. package/src/numbers/nombre.ts +2 -0
  80. package/src/numbers/rationals/rational.js +96 -10
  81. package/src/numbers/rationals/rational.ts +81 -15
  82. package/src/numbers/reals/real.js +2 -0
  83. package/src/numbers/reals/real.ts +3 -1
  84. package/src/numbers/reals/squareRoot.ts +3 -10
  85. package/src/polynomials/affine.ts +2 -6
  86. package/src/polynomials/polynomial.js +4 -13
  87. package/src/polynomials/polynomial.ts +8 -25
  88. package/src/tree/latexParser/latexParse.js +81 -34
  89. package/src/tree/latexParser/latexParse.ts +85 -39
  90. package/src/tree/nodes/functions/functionNode.js +19 -0
  91. package/src/tree/nodes/functions/functionNode.ts +18 -0
  92. package/src/tree/nodes/functions/oppositeNode.js +30 -0
  93. package/src/tree/nodes/functions/oppositeNode.ts +12 -0
  94. package/src/tree/nodes/functions/sqrtNode.js +24 -9
  95. package/src/tree/nodes/functions/sqrtNode.ts +5 -9
  96. package/src/tree/nodes/node.ts +1 -3
  97. package/src/tree/nodes/numbers/numberNode.js +3 -6
  98. package/src/tree/nodes/numbers/numberNode.ts +4 -7
  99. package/src/tree/nodes/operators/addNode.js +23 -8
  100. package/src/tree/nodes/operators/addNode.ts +3 -7
  101. package/src/tree/nodes/operators/divideNode.js +21 -9
  102. package/src/tree/nodes/operators/divideNode.ts +4 -11
  103. package/src/tree/nodes/operators/equalNode.js +20 -8
  104. package/src/tree/nodes/operators/equalNode.ts +3 -9
  105. package/src/tree/nodes/operators/fractionNode.js +34 -0
  106. package/src/tree/nodes/operators/fractionNode.ts +16 -0
  107. package/src/tree/nodes/operators/multiplyNode.js +20 -8
  108. package/src/tree/nodes/operators/multiplyNode.ts +3 -9
  109. package/src/tree/nodes/operators/operatorNode.js +35 -0
  110. package/src/tree/nodes/operators/operatorNode.ts +35 -2
  111. package/src/tree/nodes/operators/powerNode.js +20 -8
  112. package/src/tree/nodes/operators/powerNode.ts +3 -8
  113. package/src/tree/nodes/operators/substractNode.js +20 -8
  114. package/src/tree/nodes/operators/substractNode.ts +3 -9
  115. package/src/tree/nodes/variables/variableNode.js +1 -4
  116. package/src/tree/nodes/variables/variableNode.ts +4 -7
  117. package/src/utils/coin.js +7 -0
  118. package/src/utils/coin.ts +3 -0
  119. package/src/utils/shuffle.js +15 -4
  120. package/src/utils/shuffle.ts +7 -5
  121. package/src/exercises/calcul/priority.ts +0 -33
  122. package/src/expression/expression.js +0 -9
  123. package/src/expression/expression.ts +0 -13
  124. package/src/tree/nodes/operators/oppositeNode.ts +0 -17
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.getPriorityQuestions = exports.operationsPriorities = void 0;
4
+ var randint_1 = require("../../mathutils/random/randint");
5
+ var latexParse_1 = require("../../tree/latexParser/latexParse");
6
+ var numberNode_1 = require("../../tree/nodes/numbers/numberNode");
7
+ var addNode_1 = require("../../tree/nodes/operators/addNode");
8
+ var divideNode_1 = require("../../tree/nodes/operators/divideNode");
9
+ var multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
10
+ var coin_1 = require("../../utils/coin");
11
+ var getDistinctQuestions_1 = require("../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
+ exports.operationsPriorities = {
20
+ id: "operationsPriorities",
21
+ connector: "=",
22
+ instruction: "Calculer :",
23
+ label: "Priorités opératoires",
24
+ levels: ["6", "5", "4"],
25
+ section: "Calculs",
26
+ isSingleStep: true,
27
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getPriorityQuestions, nb); }
28
+ };
29
+ function getPriorityQuestions() {
30
+ var _a, _b, _c, _d, _e, _f, _g;
31
+ var type = (0, randint_1.randint)(1, 6);
32
+ var statement;
33
+ var answer = "";
34
+ var a, b, c, d;
35
+ switch (type) {
36
+ case 1: // a*b ±c±d
37
+ _a = [1, 2, 3, 4].map(function (el) { return (0, randint_1.randint)(-10, 11, [0]); }), c = _a[0], d = _a[1];
38
+ _b = [1, 2].map(function (el) { return (0, randint_1.randint)(-10, 11); }), a = _b[0], b = _b[1];
39
+ statement = (0, coin_1.coin)()
40
+ ? //a*b first ou last
41
+ 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))).shuffle()
42
+ : //a*b middle
43
+ 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));
44
+ answer = a * b + c + d + "";
45
+ break;
46
+ case 2: // a/b ±c±d
47
+ _c = [1, 2, 3].map(function (el) { return (0, randint_1.randint)(-10, 11, [0]); }), b = _c[0], c = _c[1], d = _c[2];
48
+ a = b * (0, randint_1.randint)(0, 11);
49
+ statement = (0, coin_1.coin)()
50
+ ? //a/b first ou last
51
+ 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))).shuffle()
52
+ : //a/b middle
53
+ 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));
54
+ answer = a / b + c + d + "";
55
+ break;
56
+ case 3: // a*b ± c*d
57
+ _d = [1, 2, 3, 4].map(function (el) { return (0, randint_1.randint)(-10, 11); }), a = _d[0], b = _d[1], c = _d[2], d = _d[3];
58
+ 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)));
59
+ answer = a * b + c * d + "";
60
+ break;
61
+ case 4: // a*b ± c/d
62
+ _e = [1, 2].map(function (el) { return (0, randint_1.randint)(-10, 11); }), a = _e[0], b = _e[1];
63
+ d = (0, randint_1.randint)(-10, 11, [0]);
64
+ c = d * (0, randint_1.randint)(0, 11);
65
+ 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))).shuffle();
66
+ answer = a * b + c / d + "";
67
+ break;
68
+ case 5: // a/b ± c/d
69
+ _f = [1, 2].map(function (el) { return (0, randint_1.randint)(-10, 11, [0]); }), b = _f[0], d = _f[1];
70
+ a = b * (0, randint_1.randint)(0, 11);
71
+ c = d * (0, randint_1.randint)(0, 11);
72
+ 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)));
73
+ answer = a / b + c / d + "";
74
+ break;
75
+ case 5: // a*b*c ± d
76
+ _g = [1, 2].map(function (el) { return (0, randint_1.randint)(-10, 11, [0]); }), b = _g[0], d = _g[1];
77
+ a = b * (0, randint_1.randint)(0, 11);
78
+ c = d * (0, randint_1.randint)(0, 11);
79
+ 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)).shuffle();
80
+ answer = (a * b * c) / d + "";
81
+ break;
82
+ }
83
+ var question = {
84
+ statement: (0, latexParse_1.latexParse)(statement),
85
+ answer: answer
86
+ };
87
+ return question;
88
+ }
89
+ exports.getPriorityQuestions = getPriorityQuestions;
@@ -0,0 +1,118 @@
1
+ import { randint } from "../../mathutils/random/randint";
2
+ import { Integer } from "../../numbers/integer/integer";
3
+ import { DiscreteSet } from "../../sets/discreteSet";
4
+ import { Interval } from "../../sets/intervals/intervals";
5
+ import { latexParse } from "../../tree/latexParser/latexParse";
6
+ import { Node } from "../../tree/nodes/node";
7
+ import { NumberNode } from "../../tree/nodes/numbers/numberNode";
8
+ import { AddNode } from "../../tree/nodes/operators/addNode";
9
+ import { DivideNode } from "../../tree/nodes/operators/divideNode";
10
+ import { MultiplyNode } from "../../tree/nodes/operators/multiplyNode";
11
+ import { coin } from "../../utils/coin";
12
+ import { Exercise, Question } from "../exercise";
13
+ import { getDistinctQuestions } from "../utils/getDistinctQuestions";
14
+
15
+ /**
16
+ * a*b ±c±d
17
+ * a/b ±c±d
18
+ * a*b*c ± d
19
+ * a*b±c*d
20
+ * a/b ± c*d
21
+ */
22
+
23
+ export const operationsPriorities: Exercise = {
24
+ id: "operationsPriorities",
25
+ connector: "=",
26
+ instruction: "Calculer :",
27
+ label: "Priorités opératoires",
28
+ levels: ["6", "5", "4"],
29
+ section: "Calculs",
30
+ isSingleStep: true,
31
+ generator: (nb: number) => getDistinctQuestions(getPriorityQuestions, nb),
32
+ };
33
+
34
+ export function getPriorityQuestions(): Question {
35
+ const type = randint(1, 6);
36
+ let statement: Node;
37
+ let answer: string = "";
38
+ let a, b, c, d: number;
39
+
40
+ switch (type) {
41
+ case 1: // a*b ±c±d
42
+ [c, d] = [1, 2, 3, 4].map((el) => randint(-10, 11, [0]));
43
+ [a, b] = [1, 2].map((el) => randint(-10, 11));
44
+ statement = coin()
45
+ ? //a*b first ou last
46
+ new AddNode(
47
+ new MultiplyNode(new NumberNode(a), new NumberNode(b)),
48
+ new AddNode(new NumberNode(c), new NumberNode(d))
49
+ ).shuffle()
50
+ : //a*b middle
51
+ new AddNode(
52
+ new AddNode(new NumberNode(c), new MultiplyNode(new NumberNode(a), new NumberNode(b))),
53
+ new NumberNode(d)
54
+ );
55
+ answer = a * b + c + d + "";
56
+ break;
57
+ case 2: // a/b ±c±d
58
+ [b, c, d] = [1, 2, 3].map((el) => randint(-10, 11, [0]));
59
+ a = b * randint(0, 11);
60
+ statement = coin()
61
+ ? //a/b first ou last
62
+ new AddNode(
63
+ new DivideNode(new NumberNode(a), new NumberNode(b)),
64
+ new AddNode(new NumberNode(c), new NumberNode(d))
65
+ ).shuffle()
66
+ : //a/b middle
67
+ new AddNode(
68
+ new AddNode(new NumberNode(c), new DivideNode(new NumberNode(a), new NumberNode(b))),
69
+ new NumberNode(d)
70
+ );
71
+ answer = a / b + c + d + "";
72
+ break;
73
+ case 3: // a*b ± c*d
74
+ [a, b, c, d] = [1, 2, 3, 4].map((el) => randint(-10, 11));
75
+ statement = new AddNode(
76
+ new MultiplyNode(new NumberNode(a), new NumberNode(b)),
77
+ new MultiplyNode(new NumberNode(c), new NumberNode(d))
78
+ );
79
+ answer = a * b + c * d + "";
80
+ break;
81
+ case 4: // a*b ± c/d
82
+ [a, b] = [1, 2].map((el) => randint(-10, 11));
83
+ d = randint(-10, 11, [0]);
84
+ c = d * randint(0, 11);
85
+ statement = new AddNode(
86
+ new MultiplyNode(new NumberNode(a), new NumberNode(b)),
87
+ new DivideNode(new NumberNode(c), new NumberNode(d))
88
+ ).shuffle();
89
+ answer = a * b + c / d + "";
90
+ break;
91
+ case 5: // a/b ± c/d
92
+ [b, d] = [1, 2].map((el) => randint(-10, 11, [0]));
93
+ a = b * randint(0, 11);
94
+ c = d * randint(0, 11);
95
+ statement = new AddNode(
96
+ new DivideNode(new NumberNode(a), new NumberNode(b)),
97
+ new DivideNode(new NumberNode(c), new NumberNode(d))
98
+ );
99
+ answer = a / b + c / d + "";
100
+ break;
101
+ case 5: // a*b*c ± d
102
+ [b, d] = [1, 2].map((el) => randint(-10, 11, [0]));
103
+ a = b * randint(0, 11);
104
+ c = d * randint(0, 11);
105
+ statement = new AddNode(
106
+ new MultiplyNode(new MultiplyNode(new NumberNode(a), new NumberNode(b)), new NumberNode(c)),
107
+ new NumberNode(d)
108
+ ).shuffle();
109
+ answer = (a * b * c) / d + "";
110
+ break;
111
+ }
112
+
113
+ const question: Question = {
114
+ statement: latexParse(statement!),
115
+ answer: answer,
116
+ };
117
+ return question;
118
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.getRoundQuestions = exports.roundToMillieme = exports.roundToCentieme = exports.roundToDizieme = exports.roundToUnit = void 0;
4
+ var randint_1 = require("../../../mathutils/random/randint");
5
+ var decimal_1 = require("../../../numbers/decimals/decimal");
6
+ var latexParse_1 = require("../../../tree/latexParser/latexParse");
7
+ var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
8
+ /**
9
+ * arrondi à l'unité
10
+ */
11
+ exports.roundToUnit = {
12
+ id: "roundToUnit",
13
+ connector: "\\approx",
14
+ instruction: "Arrondir à l'unité :",
15
+ label: "Arrondir à l'unité",
16
+ levels: ["6", "5"],
17
+ section: "Calculs",
18
+ isSingleStep: true,
19
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(function () { return getRoundQuestions(0); }, nb); }
20
+ };
21
+ /**
22
+ * arrondi à l'unité
23
+ */
24
+ exports.roundToDizieme = {
25
+ id: "roundToDizieme",
26
+ connector: "\\approx",
27
+ instruction: "Arrondir au dizième :",
28
+ label: "Arrondir au dizième",
29
+ levels: ["6", "5"],
30
+ section: "Calculs",
31
+ isSingleStep: true,
32
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(function () { return getRoundQuestions(1); }, nb); }
33
+ };
34
+ /**
35
+ * arrondi à l'unité
36
+ */
37
+ exports.roundToCentieme = {
38
+ id: "roundToCentieme",
39
+ connector: "\\approx",
40
+ instruction: "Arrondir au centième :",
41
+ label: "Arrondir au centième",
42
+ levels: ["6", "5"],
43
+ section: "Calculs",
44
+ isSingleStep: true,
45
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(function () { return getRoundQuestions(2); }, nb); }
46
+ };
47
+ /**
48
+ * arrondi à l'unité
49
+ */
50
+ exports.roundToMillieme = {
51
+ id: "roundToMillieme",
52
+ connector: "\\approx",
53
+ instruction: "Arrondir au millième :",
54
+ label: "Arrondir au millième",
55
+ levels: ["6", "5"],
56
+ section: "Calculs",
57
+ isSingleStep: true,
58
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(function () { return getRoundQuestions(3); }, nb); }
59
+ };
60
+ function getRoundQuestions(precisionAsked) {
61
+ if (precisionAsked === void 0) { precisionAsked = 0; }
62
+ var precision = (0, randint_1.randint)(precisionAsked + 1, precisionAsked + 5);
63
+ var dec = decimal_1.DecimalConstructor.random(0, 1000, precision);
64
+ var question = {
65
+ statement: (0, latexParse_1.latexParse)(dec.toTree()),
66
+ answer: (0, latexParse_1.latexParse)(dec.round(precisionAsked).toTree())
67
+ };
68
+ return question;
69
+ }
70
+ exports.getRoundQuestions = getRoundQuestions;
@@ -0,0 +1,68 @@
1
+ import { randint } from "../../../mathutils/random/randint";
2
+ import { DecimalConstructor } from "../../../numbers/decimals/decimal";
3
+ import { latexParse } from "../../../tree/latexParser/latexParse";
4
+ import { Exercise, Question } from "../../exercise";
5
+ import { getDistinctQuestions } from "../../utils/getDistinctQuestions";
6
+
7
+ /**
8
+ * arrondi à l'unité
9
+ */
10
+ export const roundToUnit: Exercise = {
11
+ id: "roundToUnit",
12
+ connector: "\\approx",
13
+ instruction: "Arrondir à l'unité :",
14
+ label: "Arrondir à l'unité",
15
+ levels: ["6", "5"],
16
+ section: "Calculs",
17
+ isSingleStep: true,
18
+ generator: (nb: number) => getDistinctQuestions(() => getRoundQuestions(0), nb),
19
+ };
20
+ /**
21
+ * arrondi à l'unité
22
+ */
23
+ export const roundToDizieme: Exercise = {
24
+ id: "roundToDizieme",
25
+ connector: "\\approx",
26
+ instruction: "Arrondir au dizième :",
27
+ label: "Arrondir au dizième",
28
+ levels: ["6", "5"],
29
+ section: "Calculs",
30
+ isSingleStep: true,
31
+ generator: (nb: number) => getDistinctQuestions(() => getRoundQuestions(1), nb),
32
+ };
33
+ /**
34
+ * arrondi à l'unité
35
+ */
36
+ export const roundToCentieme: Exercise = {
37
+ id: "roundToCentieme",
38
+ connector: "\\approx",
39
+ instruction: "Arrondir au centième :",
40
+ label: "Arrondir au centième",
41
+ levels: ["6", "5"],
42
+ section: "Calculs",
43
+ isSingleStep: true,
44
+ generator: (nb: number) => getDistinctQuestions(() => getRoundQuestions(2), nb),
45
+ };
46
+ /**
47
+ * arrondi à l'unité
48
+ */
49
+ export const roundToMillieme: Exercise = {
50
+ id: "roundToMillieme",
51
+ connector: "\\approx",
52
+ instruction: "Arrondir au millième :",
53
+ label: "Arrondir au millième",
54
+ levels: ["6", "5"],
55
+ section: "Calculs",
56
+ isSingleStep: true,
57
+ generator: (nb: number) => getDistinctQuestions(() => getRoundQuestions(3), nb),
58
+ };
59
+
60
+ export function getRoundQuestions(precisionAsked: number = 0): Question {
61
+ const precision = randint(precisionAsked + 1, precisionAsked + 5);
62
+ const dec = DecimalConstructor.random(0, 1000, precision);
63
+ const question: Question = {
64
+ statement: latexParse(dec.toTree()),
65
+ answer: latexParse(dec.round(precisionAsked).toTree()),
66
+ };
67
+ return question;
68
+ }
@@ -7,10 +7,12 @@ var firstIdentity_1 = require("./firstIdentity");
7
7
  var secondIdentity_1 = require("./secondIdentity");
8
8
  var thirdIdentity_1 = require("./thirdIdentity");
9
9
  exports.allIdentities = {
10
+ id: "allIdRmq",
10
11
  connector: "=",
11
12
  instruction: "Développer et réduire :",
12
13
  label: "Identités remarquables (toutes)",
13
14
  levels: ["3", "2"],
15
+ isSingleStep: false,
14
16
  section: "Calcul Littéral",
15
17
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getAllIdentitiesQuestion, nb); }
16
18
  };
@@ -6,10 +6,12 @@ import { getSecondIdentityQuestion } from "./secondIdentity";
6
6
  import { getThirdIdentityQuestion } from "./thirdIdentity";
7
7
 
8
8
  export const allIdentities: Exercise = {
9
+ id: "allIdRmq",
9
10
  connector: "=",
10
11
  instruction: "Développer et réduire :",
11
12
  label: "Identités remarquables (toutes)",
12
13
  levels: ["3", "2"],
14
+ isSingleStep: false,
13
15
  section: "Calcul Littéral",
14
16
  generator: (nb: number) => getDistinctQuestions(getAllIdentitiesQuestion, nb),
15
17
  };
@@ -9,14 +9,14 @@ var latexParse_1 = require("../../../tree/latexParser/latexParse");
9
9
  var multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
10
10
  var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
11
11
  exports.doubleDistributivity = {
12
+ id: "doubleDistri",
12
13
  connector: "=",
13
14
  instruction: "Développer et réduire :",
14
15
  label: "Distributivité double",
15
16
  levels: ["3", "2"],
17
+ isSingleStep: false,
16
18
  section: "Calcul Littéral",
17
- generator: function (nb) {
18
- return (0, getDistinctQuestions_1.getDistinctQuestions)(getDoubleDistributivityQuestion, nb);
19
- }
19
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getDoubleDistributivityQuestion, nb); }
20
20
  };
21
21
  function getDoubleDistributivityQuestion() {
22
22
  var interval = new intervals_1.Interval("[[-10; 10]]").difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)]));
@@ -9,10 +9,12 @@ import { Exercise, Question } from "../../exercise";
9
9
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions";
10
10
 
11
11
  export const doubleDistributivity: Exercise = {
12
+ id: "doubleDistri",
12
13
  connector: "=",
13
14
  instruction: "Développer et réduire :",
14
15
  label: "Distributivité double",
15
16
  levels: ["3", "2"],
17
+ isSingleStep: false,
16
18
  section: "Calcul Littéral",
17
19
  generator: (nb: number) => getDistinctQuestions(getDoubleDistributivityQuestion, nb),
18
20
  };
@@ -10,10 +10,12 @@ var numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
10
10
  var powerNode_1 = require("../../../tree/nodes/operators/powerNode");
11
11
  var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
12
12
  exports.firstIdentity = {
13
+ id: "idRmq1",
13
14
  connector: "=",
14
15
  instruction: "Développer et réduire :",
15
16
  label: "Identité remarquable $(a+b)^2$",
16
17
  levels: ["3", "2"],
18
+ isSingleStep: false,
17
19
  section: "Calcul Littéral",
18
20
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getFirstIdentityQuestion, nb); }
19
21
  };
@@ -9,10 +9,12 @@ import { Exercise, Question } from "../../exercise";
9
9
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions";
10
10
 
11
11
  export const firstIdentity: Exercise = {
12
+ id: "idRmq1",
12
13
  connector: "=",
13
14
  instruction: "Développer et réduire :",
14
15
  label: "Identité remarquable $(a+b)^2$",
15
16
  levels: ["3", "2"],
17
+ isSingleStep: false,
16
18
  section: "Calcul Littéral",
17
19
  generator: (nb: number) => getDistinctQuestions(getFirstIdentityQuestion, nb),
18
20
  };
@@ -10,14 +10,14 @@ var numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
10
10
  var powerNode_1 = require("../../../tree/nodes/operators/powerNode");
11
11
  var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
12
12
  exports.secondIdentity = {
13
+ id: "idRmq2",
13
14
  connector: "=",
14
15
  instruction: "Développer et réduire :",
15
16
  label: "Identité remarquable $(a-b)^2$",
16
17
  levels: ["3", "2"],
18
+ isSingleStep: false,
17
19
  section: "Calcul Littéral",
18
- generator: function (nb) {
19
- return (0, getDistinctQuestions_1.getDistinctQuestions)(getSecondIdentityQuestion, nb);
20
- }
20
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getSecondIdentityQuestion, nb); }
21
21
  };
22
22
  function getSecondIdentityQuestion() {
23
23
  var intervalA = new intervals_1.Interval("[[0; 10]]").difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)]));
@@ -10,10 +10,12 @@ import { Exercise, Question } from "../../exercise";
10
10
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions";
11
11
 
12
12
  export const secondIdentity: Exercise = {
13
+ id: "idRmq2",
13
14
  connector: "=",
14
15
  instruction: "Développer et réduire :",
15
16
  label: "Identité remarquable $(a-b)^2$",
16
17
  levels: ["3", "2"],
18
+ isSingleStep: false,
17
19
  section: "Calcul Littéral",
18
20
  generator: (nb: number) => getDistinctQuestions(getSecondIdentityQuestion, nb),
19
21
  };
@@ -10,14 +10,14 @@ var numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
10
10
  var multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
11
11
  var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
12
12
  exports.simpleDistributivity = {
13
+ id: "simpleDistri",
13
14
  connector: "=",
14
15
  instruction: "Développer et réduire :",
15
16
  label: "Distributivité simple",
16
17
  levels: ["3", "2"],
18
+ isSingleStep: false,
17
19
  section: "Calcul Littéral",
18
- generator: function (nb) {
19
- return (0, getDistinctQuestions_1.getDistinctQuestions)(getSimpleDistributivityQuestion, nb);
20
- }
20
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getSimpleDistributivityQuestion, nb); }
21
21
  };
22
22
  function getSimpleDistributivityQuestion() {
23
23
  var interval = new intervals_1.Interval("[[-10; 10]]").difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)]));
@@ -9,10 +9,12 @@ import { Exercise, Question } from "../../exercise";
9
9
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions";
10
10
 
11
11
  export const simpleDistributivity: Exercise = {
12
+ id: "simpleDistri",
12
13
  connector: "=",
13
14
  instruction: "Développer et réduire :",
14
15
  label: "Distributivité simple",
15
16
  levels: ["3", "2"],
17
+ isSingleStep: false,
16
18
  section: "Calcul Littéral",
17
19
  generator: (nb: number) => getDistinctQuestions(getSimpleDistributivityQuestion, nb),
18
20
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.getThirdIdentityQuestion = exports.firstIdentity = void 0;
3
+ exports.getThirdIdentityQuestion = exports.thirdIdentity = void 0;
4
4
  var integer_1 = require("../../../numbers/integer/integer");
5
5
  var affine_1 = require("../../../polynomials/affine");
6
6
  var discreteSet_1 = require("../../../sets/discreteSet");
@@ -8,11 +8,13 @@ var intervals_1 = require("../../../sets/intervals/intervals");
8
8
  var latexParse_1 = require("../../../tree/latexParser/latexParse");
9
9
  var multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
10
10
  var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
11
- exports.firstIdentity = {
11
+ exports.thirdIdentity = {
12
+ id: "idRmq3",
12
13
  connector: "=",
13
14
  instruction: "Développer et réduire :",
14
15
  label: "Identité remarquable $(a+b)(a-b)$",
15
16
  levels: ["3", "2"],
17
+ isSingleStep: false,
16
18
  section: "Calcul Littéral",
17
19
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getThirdIdentityQuestion, nb); }
18
20
  };
@@ -10,10 +10,12 @@ import { Exercise, Question } from "../../exercise";
10
10
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions";
11
11
 
12
12
  export const thirdIdentity: Exercise = {
13
+ id: "idRmq3",
13
14
  connector: "=",
14
15
  instruction: "Développer et réduire :",
15
16
  label: "Identité remarquable $(a+b)(a-b)$",
16
17
  levels: ["3", "2"],
18
+ isSingleStep: false,
17
19
  section: "Calcul Littéral",
18
20
  generator: (nb: number) => getDistinctQuestions(getThirdIdentityQuestion, nb),
19
21
  };
@@ -12,14 +12,14 @@ var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
12
12
  * type x+a=b
13
13
  */
14
14
  exports.equationType1Exercise = {
15
+ id: "equa1",
15
16
  connector: "\\iff",
16
17
  instruction: "Résoudre : ",
17
18
  label: "Equations $x+a = b$",
18
19
  levels: ["4", "3", "2"],
19
20
  section: "Calcul littéral",
20
- generator: function (nb) {
21
- return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType1ExerciseQuestion, nb);
22
- }
21
+ isSingleStep: false,
22
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType1ExerciseQuestion, nb); }
23
23
  };
24
24
  function getEquationType1ExerciseQuestion() {
25
25
  var interval = new intervals_1.Interval("[[-10; 10]]");
@@ -11,20 +11,19 @@ import { getDistinctQuestions } from "../../utils/getDistinctQuestions";
11
11
  * type x+a=b
12
12
  */
13
13
  export const equationType1Exercise: Exercise = {
14
+ id: "equa1",
14
15
  connector: "\\iff",
15
16
  instruction: "Résoudre : ",
16
17
  label: "Equations $x+a = b$",
17
18
  levels: ["4", "3", "2"],
18
19
  section: "Calcul littéral",
19
- generator: (nb: number) =>
20
- getDistinctQuestions(getEquationType1ExerciseQuestion, nb),
20
+ isSingleStep: false,
21
+ generator: (nb: number) => getDistinctQuestions(getEquationType1ExerciseQuestion, nb),
21
22
  };
22
23
 
23
24
  export function getEquationType1ExerciseQuestion(): Question {
24
25
  const interval = new Interval("[[-10; 10]]");
25
- const intervalStar = new Interval("[[-10; 10]]").difference(
26
- new DiscreteSet([new Integer(0)])
27
- );
26
+ const intervalStar = new Interval("[[-10; 10]]").difference(new DiscreteSet([new Integer(0)]));
28
27
  const b = interval.getRandomElement();
29
28
  const a = intervalStar.getRandomElement();
30
29
  const solution = b.value - a.value;
@@ -14,14 +14,14 @@ var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
14
14
  * type ax=b
15
15
  */
16
16
  exports.equationType2Exercise = {
17
+ id: "equa2",
17
18
  connector: "\\iff",
18
19
  instruction: "Résoudre : ",
19
20
  label: "Equations $ax=b$",
20
21
  levels: ["4", "3", "2"],
21
22
  section: "Calcul littéral",
22
- generator: function (nb) {
23
- return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType2ExerciseQuestion, nb);
24
- }
23
+ isSingleStep: false,
24
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType2ExerciseQuestion, nb); }
25
25
  };
26
26
  function getEquationType2ExerciseQuestion() {
27
27
  var interval = new intervals_1.Interval("[[-10; 10]]");
@@ -13,20 +13,20 @@ import { getDistinctQuestions } from "../../utils/getDistinctQuestions";
13
13
  * type ax=b
14
14
  */
15
15
  export const equationType2Exercise: Exercise = {
16
+ id: "equa2",
17
+
16
18
  connector: "\\iff",
17
19
  instruction: "Résoudre : ",
18
20
  label: "Equations $ax=b$",
19
21
  levels: ["4", "3", "2"],
20
22
  section: "Calcul littéral",
21
- generator: (nb: number) =>
22
- getDistinctQuestions(getEquationType2ExerciseQuestion, nb),
23
+ isSingleStep: false,
24
+ generator: (nb: number) => getDistinctQuestions(getEquationType2ExerciseQuestion, nb),
23
25
  };
24
26
 
25
27
  export function getEquationType2ExerciseQuestion(): Question {
26
28
  const interval = new Interval("[[-10; 10]]");
27
- const intervalStar = new Interval("[[-10; 10]]").difference(
28
- new DiscreteSet([new Integer(0)])
29
- );
29
+ const intervalStar = new Interval("[[-10; 10]]").difference(new DiscreteSet([new Integer(0)]));
30
30
  const b = interval.getRandomElement();
31
31
  const a = intervalStar.getRandomElement();
32
32
  const solution = new Rational(b.value, a.value).simplify();
@@ -14,14 +14,14 @@ var getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
14
14
  * type ax+b=c
15
15
  */
16
16
  exports.equationType3Exercise = {
17
+ id: "equa3",
17
18
  connector: "\\iff",
18
19
  instruction: "Résoudre : ",
19
20
  label: "Equations $ax+b=c$",
20
21
  levels: ["4", "3", "2"],
21
22
  section: "Calcul littéral",
22
- generator: function (nb) {
23
- return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType3ExerciseQuestion, nb);
24
- }
23
+ isSingleStep: false,
24
+ generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType3ExerciseQuestion, nb); }
25
25
  };
26
26
  function getEquationType3ExerciseQuestion() {
27
27
  var interval = new intervals_1.Interval("[[-10; 10]]");