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.
Files changed (125) hide show
  1. package/package.json +1 -1
  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 +1 -0
  23. package/src/exercises/calculLitteral/distributivity/allIdentities.ts +1 -0
  24. package/src/exercises/calculLitteral/distributivity/doubleDistributivity.js +1 -0
  25. package/src/exercises/calculLitteral/distributivity/doubleDistributivity.ts +2 -1
  26. package/src/exercises/calculLitteral/distributivity/firstIdentity.js +1 -0
  27. package/src/exercises/calculLitteral/distributivity/firstIdentity.ts +2 -1
  28. package/src/exercises/calculLitteral/distributivity/secondIdentity.js +1 -0
  29. package/src/exercises/calculLitteral/distributivity/secondIdentity.ts +2 -1
  30. package/src/exercises/calculLitteral/distributivity/simpleDistributivity.js +1 -0
  31. package/src/exercises/calculLitteral/distributivity/simpleDistributivity.ts +2 -1
  32. package/src/exercises/calculLitteral/distributivity/thirdIdentity.js +1 -0
  33. package/src/exercises/calculLitteral/distributivity/thirdIdentity.ts +2 -1
  34. package/src/exercises/calculLitteral/equation/equationType1Exercise.js +1 -0
  35. package/src/exercises/calculLitteral/equation/equationType1Exercise.ts +1 -0
  36. package/src/exercises/calculLitteral/equation/equationType2Exercise.js +1 -0
  37. package/src/exercises/calculLitteral/equation/equationType2Exercise.ts +1 -0
  38. package/src/exercises/calculLitteral/equation/equationType3Exercise.js +1 -0
  39. package/src/exercises/calculLitteral/equation/equationType3Exercise.ts +1 -0
  40. package/src/exercises/calculLitteral/equation/equationType4Exercise.js +1 -0
  41. package/src/exercises/calculLitteral/equation/equationType4Exercise.ts +1 -0
  42. package/src/exercises/calculLitteral/factorisation/factoType1Exercise.js +2 -6
  43. package/src/exercises/calculLitteral/factorisation/factoType1Exercise.ts +3 -7
  44. package/src/exercises/calculLitteral/reduction.ts +27 -0
  45. package/src/exercises/exercise.ts +1 -0
  46. package/src/exercises/exercises.js +54 -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 +1 -0
  59. package/src/exercises/squareRoots/simpifySquareRoot.ts +1 -0
  60. package/src/index.js +5 -0
  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/numbers/rationals/division.ts +0 -0
  125. 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
+ }
@@ -12,6 +12,7 @@ exports.allIdentities = {
12
12
  instruction: "Développer et réduire :",
13
13
  label: "Identités remarquables (toutes)",
14
14
  levels: ["3", "2"],
15
+ isSingleStep: false,
15
16
  section: "Calcul Littéral",
16
17
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getAllIdentitiesQuestion, nb); }
17
18
  };
@@ -11,6 +11,7 @@ export const allIdentities: Exercise = {
11
11
  instruction: "Développer et réduire :",
12
12
  label: "Identités remarquables (toutes)",
13
13
  levels: ["3", "2"],
14
+ isSingleStep: false,
14
15
  section: "Calcul Littéral",
15
16
  generator: (nb: number) => getDistinctQuestions(getAllIdentitiesQuestion, nb),
16
17
  };
@@ -14,6 +14,7 @@ exports.doubleDistributivity = {
14
14
  instruction: "Développer et réduire :",
15
15
  label: "Distributivité double",
16
16
  levels: ["3", "2"],
17
+ isSingleStep: false,
17
18
  section: "Calcul Littéral",
18
19
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getDoubleDistributivityQuestion, nb); }
19
20
  };
@@ -14,7 +14,8 @@ export const doubleDistributivity: Exercise = {
14
14
  instruction: "Développer et réduire :",
15
15
  label: "Distributivité double",
16
16
  levels: ["3", "2"],
17
- section: "Calcul Littéral",
17
+ isSingleStep: false,
18
+ section: "Calcul littéral",
18
19
  generator: (nb: number) => getDistinctQuestions(getDoubleDistributivityQuestion, nb),
19
20
  };
20
21
 
@@ -15,6 +15,7 @@ exports.firstIdentity = {
15
15
  instruction: "Développer et réduire :",
16
16
  label: "Identité remarquable $(a+b)^2$",
17
17
  levels: ["3", "2"],
18
+ isSingleStep: false,
18
19
  section: "Calcul Littéral",
19
20
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getFirstIdentityQuestion, nb); }
20
21
  };
@@ -14,7 +14,8 @@ export const firstIdentity: Exercise = {
14
14
  instruction: "Développer et réduire :",
15
15
  label: "Identité remarquable $(a+b)^2$",
16
16
  levels: ["3", "2"],
17
- section: "Calcul Littéral",
17
+ isSingleStep: false,
18
+ section: "Calcul littéral",
18
19
  generator: (nb: number) => getDistinctQuestions(getFirstIdentityQuestion, nb),
19
20
  };
20
21
 
@@ -15,6 +15,7 @@ exports.secondIdentity = {
15
15
  instruction: "Développer et réduire :",
16
16
  label: "Identité remarquable $(a-b)^2$",
17
17
  levels: ["3", "2"],
18
+ isSingleStep: false,
18
19
  section: "Calcul Littéral",
19
20
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getSecondIdentityQuestion, nb); }
20
21
  };
@@ -15,7 +15,8 @@ export const secondIdentity: Exercise = {
15
15
  instruction: "Développer et réduire :",
16
16
  label: "Identité remarquable $(a-b)^2$",
17
17
  levels: ["3", "2"],
18
- section: "Calcul Littéral",
18
+ isSingleStep: false,
19
+ section: "Calcul littéral",
19
20
  generator: (nb: number) => getDistinctQuestions(getSecondIdentityQuestion, nb),
20
21
  };
21
22
 
@@ -15,6 +15,7 @@ exports.simpleDistributivity = {
15
15
  instruction: "Développer et réduire :",
16
16
  label: "Distributivité simple",
17
17
  levels: ["3", "2"],
18
+ isSingleStep: false,
18
19
  section: "Calcul Littéral",
19
20
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getSimpleDistributivityQuestion, nb); }
20
21
  };
@@ -14,7 +14,8 @@ export const simpleDistributivity: Exercise = {
14
14
  instruction: "Développer et réduire :",
15
15
  label: "Distributivité simple",
16
16
  levels: ["3", "2"],
17
- section: "Calcul Littéral",
17
+ isSingleStep: false,
18
+ section: "Calcul littéral",
18
19
  generator: (nb: number) => getDistinctQuestions(getSimpleDistributivityQuestion, nb),
19
20
  };
20
21
 
@@ -14,6 +14,7 @@ exports.thirdIdentity = {
14
14
  instruction: "Développer et réduire :",
15
15
  label: "Identité remarquable $(a+b)(a-b)$",
16
16
  levels: ["3", "2"],
17
+ isSingleStep: false,
17
18
  section: "Calcul Littéral",
18
19
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getThirdIdentityQuestion, nb); }
19
20
  };
@@ -15,7 +15,8 @@ export const thirdIdentity: Exercise = {
15
15
  instruction: "Développer et réduire :",
16
16
  label: "Identité remarquable $(a+b)(a-b)$",
17
17
  levels: ["3", "2"],
18
- section: "Calcul Littéral",
18
+ isSingleStep: false,
19
+ section: "Calcul littéral",
19
20
  generator: (nb: number) => getDistinctQuestions(getThirdIdentityQuestion, nb),
20
21
  };
21
22
 
@@ -18,6 +18,7 @@ exports.equationType1Exercise = {
18
18
  label: "Equations $x+a = b$",
19
19
  levels: ["4", "3", "2"],
20
20
  section: "Calcul littéral",
21
+ isSingleStep: false,
21
22
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType1ExerciseQuestion, nb); }
22
23
  };
23
24
  function getEquationType1ExerciseQuestion() {
@@ -17,6 +17,7 @@ export const equationType1Exercise: Exercise = {
17
17
  label: "Equations $x+a = b$",
18
18
  levels: ["4", "3", "2"],
19
19
  section: "Calcul littéral",
20
+ isSingleStep: false,
20
21
  generator: (nb: number) => getDistinctQuestions(getEquationType1ExerciseQuestion, nb),
21
22
  };
22
23
 
@@ -20,6 +20,7 @@ exports.equationType2Exercise = {
20
20
  label: "Equations $ax=b$",
21
21
  levels: ["4", "3", "2"],
22
22
  section: "Calcul littéral",
23
+ isSingleStep: false,
23
24
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType2ExerciseQuestion, nb); }
24
25
  };
25
26
  function getEquationType2ExerciseQuestion() {
@@ -20,6 +20,7 @@ export const equationType2Exercise: Exercise = {
20
20
  label: "Equations $ax=b$",
21
21
  levels: ["4", "3", "2"],
22
22
  section: "Calcul littéral",
23
+ isSingleStep: false,
23
24
  generator: (nb: number) => getDistinctQuestions(getEquationType2ExerciseQuestion, nb),
24
25
  };
25
26
 
@@ -20,6 +20,7 @@ exports.equationType3Exercise = {
20
20
  label: "Equations $ax+b=c$",
21
21
  levels: ["4", "3", "2"],
22
22
  section: "Calcul littéral",
23
+ isSingleStep: false,
23
24
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType3ExerciseQuestion, nb); }
24
25
  };
25
26
  function getEquationType3ExerciseQuestion() {
@@ -20,6 +20,7 @@ export const equationType3Exercise: Exercise = {
20
20
  label: "Equations $ax+b=c$",
21
21
  levels: ["4", "3", "2"],
22
22
  section: "Calcul littéral",
23
+ isSingleStep: false,
23
24
  generator: (nb: number) => getDistinctQuestions(getEquationType3ExerciseQuestion, nb),
24
25
  };
25
26
 
@@ -20,6 +20,7 @@ exports.equationType4Exercise = {
20
20
  label: "Equations $ax+b=cx+d$",
21
21
  levels: ["4", "3", "2"],
22
22
  section: "Calcul littéral",
23
+ isSingleStep: false,
23
24
  generator: function (nb) { return (0, getDistinctQuestions_1.getDistinctQuestions)(getEquationType4ExerciseQuestion, nb); }
24
25
  };
25
26
  function getEquationType4ExerciseQuestion() {
@@ -20,6 +20,7 @@ export const equationType4Exercise: Exercise = {
20
20
  label: "Equations $ax+b=cx+d$",
21
21
  levels: ["4", "3", "2"],
22
22
  section: "Calcul littéral",
23
+ isSingleStep: false,
23
24
  generator: (nb: number) => getDistinctQuestions(getEquationType4ExerciseQuestion, nb),
24
25
  };
25
26
 
@@ -16,6 +16,7 @@ exports.factoType1Exercise = {
16
16
  id: "facto1",
17
17
  connector: "=",
18
18
  instruction: "Factoriser :",
19
+ isSingleStep: false,
19
20
  label: "Factorisation du type $(ax+b)(cx+d) \\pm (ax+b)(ex+f)$",
20
21
  levels: ["3", "2"],
21
22
  section: "Calcul Littéral",
@@ -23,12 +24,7 @@ exports.factoType1Exercise = {
23
24
  };
24
25
  function getFactoType1Question() {
25
26
  var affines = affine_1.AffineConstructor.differentRandoms(3);
26
- var permut = [
27
- [affines[0], affines[1]],
28
- [affines[0], affines[2]],
29
- ];
30
- (0, shuffle_1.shuffle)(permut[0]);
31
- (0, shuffle_1.shuffle)(permut[1]);
27
+ var permut = [(0, shuffle_1.shuffle)([affines[0], affines[1]]), (0, shuffle_1.shuffle)([affines[0], affines[2]])];
32
28
  var operation = (0, random_1.random)(["add", "substract"]);
33
29
  var statementTree = operation === "add"
34
30
  ? new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(permut[0][0].toTree(), permut[0][1].toTree()), new multiplyNode_1.MultiplyNode(permut[1][0].toTree(), permut[1][1].toTree()))
@@ -16,21 +16,17 @@ export const factoType1Exercise: Exercise = {
16
16
  id: "facto1",
17
17
  connector: "=",
18
18
  instruction: "Factoriser :",
19
+ isSingleStep: false,
19
20
  label: "Factorisation du type $(ax+b)(cx+d) \\pm (ax+b)(ex+f)$",
20
21
  levels: ["3", "2"],
21
- section: "Calcul Littéral",
22
+ section: "Calcul littéral",
22
23
  generator: (nb: number) => getDistinctQuestions(getFactoType1Question, nb),
23
24
  };
24
25
 
25
26
  export function getFactoType1Question(): Question {
26
27
  const affines = AffineConstructor.differentRandoms(3);
27
28
 
28
- const permut: Affine[][] = [
29
- [affines[0], affines[1]],
30
- [affines[0], affines[2]],
31
- ];
32
- shuffle(permut[0]);
33
- shuffle(permut[1]);
29
+ const permut: Affine[][] = [shuffle([affines[0], affines[1]]), shuffle([affines[0], affines[2]])];
34
30
 
35
31
  const operation = random(["add", "substract"]);
36
32
 
@@ -0,0 +1,27 @@
1
+ // import { Interval } from "../../sets/intervals/intervals";
2
+ // import { Exercise, Question } from "../exercise";
3
+ // import { getDistinctQuestions } from "../utils/getDistinctQuestions";
4
+
5
+ // export const reduction: Exercise = {
6
+ // id: "reduction",
7
+ // connector: "=",
8
+ // instruction: "Réduire :",
9
+ // label: "Réduire une expression polynomiale",
10
+ // levels: ["3", "2"],
11
+ // isSingleStep: false,
12
+ // section: "Calcul Littéral",
13
+ // generator: (nb: number) => getDistinctQuestions(getReductionQuestion, nb),
14
+ // };
15
+
16
+ // export function getReductionQuestion(): Question {
17
+ // const interval = new Interval("[[1; 10]]").difference(new DiscreteSet([new Integer(0)]));
18
+ // const affine = AffineConstructor.random(interval, interval);
19
+
20
+ // const statementTree = new PowerNode(affine.toTree(), new NumberNode(2));
21
+ // const answerTree = affine.multiply(affine).toTree();
22
+
23
+ // return {
24
+ // statement: latexParse(statementTree),
25
+ // answer: latexParse(answerTree),
26
+ // };
27
+ // }
@@ -12,6 +12,7 @@ export interface Question {
12
12
  export interface Exercise {
13
13
  id: string;
14
14
  instruction: string;
15
+ isSingleStep: boolean;
15
16
  label: string;
16
17
  section: string;
17
18
  levels: string[];