math-exercises 2.2.94 → 2.2.96

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 (209) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionSquare.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/fractions/fractionSquare.js +2 -1
  3. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
  4. package/lib/exercises/math/calcul/fractions/fractionsSum.js +2 -1
  5. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +2 -1
  7. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +2 -1
  9. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +2 -1
  11. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
  12. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +2 -1
  13. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.d.ts.map +1 -1
  14. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.js +0 -4
  15. package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.d.ts.map +1 -1
  16. package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.js +82 -34
  17. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.js +2 -1
  19. package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.d.ts.map +1 -1
  20. package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.js +86 -36
  21. package/lib/exercises/math/calculLitteral/distributivity/thirdIdentity.d.ts.map +1 -1
  22. package/lib/exercises/math/calculLitteral/distributivity/thirdIdentity.js +82 -32
  23. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
  24. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +2 -1
  25. package/lib/exercises/math/calculLitteral/factorisation/factoByX.d.ts.map +1 -1
  26. package/lib/exercises/math/calculLitteral/factorisation/factoByX.js +2 -1
  27. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -1
  28. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.js +2 -1
  29. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -1
  30. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.js +2 -1
  31. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
  32. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.js +2 -1
  33. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  34. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +3 -1
  35. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType0.d.ts.map +1 -1
  36. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType0.js +2 -1
  37. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType1.d.ts.map +1 -1
  38. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType1.js +2 -1
  39. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType2.d.ts.map +1 -1
  40. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType2.js +2 -1
  41. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
  42. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.js +2 -1
  43. package/lib/exercises/math/calculLitteral/inequations/squareFunctionInequation.d.ts.map +1 -1
  44. package/lib/exercises/math/calculLitteral/inequations/squareFunctionInequation.js +2 -1
  45. package/lib/exercises/math/calculLitteral/simplifying/distributeAndSimplify.d.ts.map +1 -1
  46. package/lib/exercises/math/calculLitteral/simplifying/distributeAndSimplify.js +38 -16
  47. package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts +3 -3
  48. package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.d.ts.map +1 -1
  49. package/lib/exercises/math/calculLitteral/simplifying/reduceExpression.js +171 -75
  50. package/lib/exercises/math/dataReading/index.d.ts +2 -0
  51. package/lib/exercises/math/dataReading/index.d.ts.map +1 -0
  52. package/lib/exercises/math/dataReading/index.js +17 -0
  53. package/lib/exercises/math/dataReading/tableReading.d.ts +8 -0
  54. package/lib/exercises/math/dataReading/tableReading.d.ts.map +1 -0
  55. package/lib/exercises/math/dataReading/tableReading.js +105 -0
  56. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.d.ts.map +1 -1
  57. package/lib/exercises/math/derivation/derivative/convexityQuadrinomials.js +2 -1
  58. package/lib/exercises/math/derivation/derivative/expDerivativeFour.d.ts.map +1 -1
  59. package/lib/exercises/math/derivation/derivative/expDerivativeFour.js +2 -1
  60. package/lib/exercises/math/derivation/derivative/expDerivativeThree.d.ts.map +1 -1
  61. package/lib/exercises/math/derivation/derivative/expDerivativeThree.js +2 -1
  62. package/lib/exercises/math/derivation/derivative/lnDerivativeThree.d.ts.map +1 -1
  63. package/lib/exercises/math/derivation/derivative/lnDerivativeThree.js +2 -1
  64. package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.d.ts.map +1 -1
  65. package/lib/exercises/math/derivation/derivative/powerCompositionDerivation.js +75 -11
  66. package/lib/exercises/math/derivation/derivative/quotientDerivative.d.ts.map +1 -1
  67. package/lib/exercises/math/derivation/derivative/quotientDerivative.js +2 -1
  68. package/lib/exercises/math/derivation/derivative/rootFunctionDerivative.d.ts.map +1 -1
  69. package/lib/exercises/math/derivation/derivative/rootFunctionDerivative.js +2 -1
  70. package/lib/exercises/math/derivation/derivative/sqrtCompositionDerivation.d.ts.map +1 -1
  71. package/lib/exercises/math/derivation/derivative/sqrtCompositionDerivation.js +2 -1
  72. package/lib/exercises/math/derivation/derivative/thirdDegreeDerivative.d.ts.map +1 -1
  73. package/lib/exercises/math/derivation/derivative/thirdDegreeDerivative.js +2 -1
  74. package/lib/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.d.ts.map +1 -1
  75. package/lib/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.js +2 -1
  76. package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.d.ts.map +1 -1
  77. package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.js +2 -1
  78. package/lib/exercises/math/functions/absolute/absolueValueInequationsSup.d.ts.map +1 -1
  79. package/lib/exercises/math/functions/absolute/absolueValueInequationsSup.js +2 -1
  80. package/lib/exercises/math/functions/absolute/absoluteValueInequations.d.ts.map +1 -1
  81. package/lib/exercises/math/functions/absolute/absoluteValueInequations.js +2 -1
  82. package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.d.ts.map +1 -1
  83. package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +2 -2
  84. package/lib/exercises/math/functions/affines/affineExpressionReading.js +2 -1
  85. package/lib/exercises/math/functions/affines/signFunction.d.ts.map +1 -1
  86. package/lib/exercises/math/functions/affines/signFunction.js +2 -1
  87. package/lib/exercises/math/functions/basics/graphicEquation.d.ts.map +1 -1
  88. package/lib/exercises/math/functions/basics/graphicEquation.js +2 -1
  89. package/lib/exercises/math/functions/basics/graphicInequation.d.ts.map +1 -1
  90. package/lib/exercises/math/functions/basics/graphicInequation.js +2 -1
  91. package/lib/exercises/math/functions/basics/graphicInequationAffine.d.ts.map +1 -1
  92. package/lib/exercises/math/functions/basics/graphicInequationAffine.js +2 -1
  93. package/lib/exercises/math/functions/basics/imageFunction.d.ts.map +1 -1
  94. package/lib/exercises/math/functions/basics/imageFunction.js +2 -1
  95. package/lib/exercises/math/functions/basics/twoFunctionsInequation.d.ts.map +1 -1
  96. package/lib/exercises/math/functions/basics/twoFunctionsInequation.js +2 -1
  97. package/lib/exercises/math/functions/exponential/expEquation.d.ts.map +1 -1
  98. package/lib/exercises/math/functions/exponential/expEquation.js +2 -1
  99. package/lib/exercises/math/functions/logarithm/logPowerEquation.d.ts.map +1 -1
  100. package/lib/exercises/math/functions/logarithm/logPowerEquation.js +2 -1
  101. package/lib/exercises/math/functions/sign/affineProductSign.d.ts.map +1 -1
  102. package/lib/exercises/math/functions/sign/affineProductSign.js +2 -1
  103. package/lib/exercises/math/functions/square/squareImageInterval.d.ts.map +1 -1
  104. package/lib/exercises/math/functions/square/squareImageInterval.js +2 -1
  105. package/lib/exercises/math/functions/trinoms/coefficientsIdentification.d.ts.map +1 -1
  106. package/lib/exercises/math/functions/trinoms/coefficientsIdentification.js +2 -1
  107. package/lib/exercises/math/functions/trinoms/secondDegreeInequation.d.ts.map +1 -1
  108. package/lib/exercises/math/functions/trinoms/secondDegreeInequation.js +2 -1
  109. package/lib/exercises/math/functions/trinoms/trinomSignFromRoots.d.ts.map +1 -1
  110. package/lib/exercises/math/functions/trinoms/trinomSignFromRoots.js +2 -1
  111. package/lib/exercises/math/geometry/cartesian/readAbscissOnLine.d.ts.map +1 -1
  112. package/lib/exercises/math/geometry/cartesian/readAbscissOnLine.js +2 -1
  113. package/lib/exercises/math/geometry/cartesian/readAbscissOnSemiLine.d.ts.map +1 -1
  114. package/lib/exercises/math/geometry/cartesian/readAbscissOnSemiLine.js +2 -1
  115. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.d.ts.map +1 -1
  116. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.js +2 -1
  117. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.d.ts.map +1 -1
  118. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.js +2 -1
  119. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts.map +1 -1
  120. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.js +2 -1
  121. package/lib/exercises/math/index.d.ts +1 -0
  122. package/lib/exercises/math/index.d.ts.map +1 -1
  123. package/lib/exercises/math/index.js +1 -0
  124. package/lib/exercises/math/matrices/matrixInversibilityDomain.d.ts.map +1 -1
  125. package/lib/exercises/math/matrices/matrixInversibilityDomain.js +2 -1
  126. package/lib/exercises/math/percent/index.d.ts +1 -0
  127. package/lib/exercises/math/percent/index.d.ts.map +1 -1
  128. package/lib/exercises/math/percent/index.js +1 -1
  129. package/lib/exercises/math/percent/percentWritings.d.ts.map +1 -1
  130. package/lib/exercises/math/percent/percentWritings.js +10 -1
  131. package/lib/exercises/math/powers/powersMixOperations.d.ts.map +1 -1
  132. package/lib/exercises/math/powers/powersMixOperations.js +2 -1
  133. package/lib/exercises/math/probaStat/diceBasicProbas.d.ts.map +1 -1
  134. package/lib/exercises/math/probaStat/diceBasicProbas.js +72 -20
  135. package/lib/exercises/math/probaStat/probabilityTree.d.ts.map +1 -1
  136. package/lib/exercises/math/probaStat/probabilityTree.js +2 -1
  137. package/lib/exercises/math/sampling/confidenceInterval.d.ts.map +1 -1
  138. package/lib/exercises/math/sampling/confidenceInterval.js +2 -1
  139. package/lib/exercises/math/sampling/fluctuationInterval.d.ts.map +1 -1
  140. package/lib/exercises/math/sampling/fluctuationInterval.js +2 -1
  141. package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.d.ts.map +1 -1
  142. package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.js +2 -1
  143. package/lib/exercises/math/sets/intervals/inequalityToInterval.d.ts.map +1 -1
  144. package/lib/exercises/math/sets/intervals/inequalityToInterval.js +2 -1
  145. package/lib/exercises/math/sets/intervals/intervalsIntersection.d.ts.map +1 -1
  146. package/lib/exercises/math/sets/intervals/intervalsIntersection.js +2 -1
  147. package/lib/exercises/math/sets/intervals/intervalsUnion.d.ts.map +1 -1
  148. package/lib/exercises/math/sets/intervals/intervalsUnion.js +2 -1
  149. package/lib/exercises/math/trigonometry/degreeToRadians.d.ts.map +1 -1
  150. package/lib/exercises/math/trigonometry/degreeToRadians.js +2 -1
  151. package/lib/exercises/math/trigonometry/mainAngleMeasure.d.ts.map +1 -1
  152. package/lib/exercises/math/trigonometry/mainAngleMeasure.js +2 -1
  153. package/lib/exercises/vea/equationVEA.d.ts.map +1 -1
  154. package/lib/exercises/vea/equationVEA.js +2 -1
  155. package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
  156. package/lib/exercises/vea/rationalVEA.js +3 -2
  157. package/lib/exercises/vea/sqrtVEA.d.ts.map +1 -1
  158. package/lib/exercises/vea/sqrtVEA.js +2 -1
  159. package/lib/index.d.ts +9 -3
  160. package/lib/index.d.ts.map +1 -1
  161. package/lib/tree/nodes/algebraicNode.d.ts +1 -0
  162. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  163. package/lib/tree/nodes/operators/addNode.d.ts +2 -1
  164. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  165. package/lib/tree/nodes/operators/addNode.js +22 -4
  166. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  167. package/lib/tree/nodes/operators/fractionNode.js +1 -1
  168. package/lib/tree/nodes/operators/multiplyNode.d.ts +2 -1
  169. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  170. package/lib/tree/nodes/operators/multiplyNode.js +13 -1
  171. package/lib/tree/nodes/operators/operatorNode.d.ts +5 -0
  172. package/lib/tree/nodes/operators/operatorNode.d.ts.map +1 -1
  173. package/lib/tree/nodes/operators/operatorNode.js +5 -1
  174. package/lib/tree/nodes/polynomials/monomNode.d.ts +2 -6
  175. package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -1
  176. package/lib/tree/nodes/polynomials/monomNode.js +102 -94
  177. package/lib/tree/parsers/affineParser.d.ts +1 -1
  178. package/lib/tree/parsers/affineParser.d.ts.map +1 -1
  179. package/lib/tree/parsers/affineParser.js +18 -22
  180. package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
  181. package/lib/tree/parsers/discreteSetParser.js +2 -1
  182. package/lib/tree/parsers/equationSolutionParser.d.ts.map +1 -1
  183. package/lib/tree/parsers/equationSolutionParser.js +2 -1
  184. package/lib/tree/parsers/inequationParser.d.ts.map +1 -1
  185. package/lib/tree/parsers/inequationParser.js +2 -1
  186. package/lib/tree/parsers/intervalParser.d.ts.map +1 -1
  187. package/lib/tree/parsers/intervalParser.js +3 -2
  188. package/lib/tree/parsers/latexParser.js +3 -3
  189. package/lib/tree/parsers/monomParser.d.ts.map +1 -1
  190. package/lib/tree/parsers/monomParser.js +2 -1
  191. package/lib/tree/parsers/polynomialParser.d.ts +5 -1
  192. package/lib/tree/parsers/polynomialParser.d.ts.map +1 -1
  193. package/lib/tree/parsers/polynomialParser.js +5 -4
  194. package/lib/tree/parsers/powerParser.d.ts.map +1 -1
  195. package/lib/tree/parsers/powerParser.js +2 -1
  196. package/lib/tree/parsers/purifyLatex.d.ts +1 -1
  197. package/lib/tree/parsers/purifyLatex.js +1 -1
  198. package/lib/tree/parsers/sqrtParser.d.ts.map +1 -1
  199. package/lib/tree/parsers/sqrtParser.js +2 -1
  200. package/lib/tree/parsers/trinomParser.d.ts.map +1 -1
  201. package/lib/tree/parsers/trinomParser.js +2 -1
  202. package/lib/tree/parsers/unionIntervalParser.d.ts.map +1 -1
  203. package/lib/tree/parsers/unionIntervalParser.js +2 -1
  204. package/lib/utils/alea/random.js +1 -1
  205. package/lib/utils/alea/shuffle.js +1 -1
  206. package/lib/utils/errors/handleVEAError.d.ts +2 -0
  207. package/lib/utils/errors/handleVEAError.d.ts.map +1 -0
  208. package/lib/utils/errors/handleVEAError.js +9 -0
  209. package/package.json +1 -1
@@ -3,100 +3,193 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reduceExpression = void 0;
4
4
  const exercise_1 = require("../../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
- const polynomial_1 = require("../../../../math/polynomials/polynomial");
6
+ const affine_1 = require("../../../../math/polynomials/affine");
7
+ const trinom_1 = require("../../../../math/polynomials/trinom");
7
8
  const randint_1 = require("../../../../math/utils/random/randint");
8
9
  const addNode_1 = require("../../../../tree/nodes/operators/addNode");
10
+ const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
11
+ const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
12
+ const polynomialParser_1 = require("../../../../tree/parsers/polynomialParser");
13
+ const operatorComposition_1 = require("../../../../tree/utilities/operatorComposition");
14
+ const random_1 = require("../../../../utils/alea/random");
9
15
  const shuffle_1 = require("../../../../utils/alea/shuffle");
16
+ const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
17
+ const rebuildIdentifiers = (oldids) => {
18
+ if (oldids.variable)
19
+ return oldids;
20
+ const { polynome1Coeffs, polynome2Coeffs } = oldids;
21
+ const nbTerms = polynome1Coeffs.filter((e) => e === 0 || !!e).length +
22
+ polynome2Coeffs.filter((e) => e === 0 || !!e).length;
23
+ return {
24
+ variable: "x",
25
+ coeffs: [
26
+ [polynome1Coeffs[0], polynome2Coeffs[0]].filter((e) => e === 0 || !!e),
27
+ [polynome1Coeffs[1], polynome2Coeffs[1]].filter((e) => e === 0 || !!e),
28
+ [polynome1Coeffs[2], polynome2Coeffs[2]].filter((e) => e === 0 || !!e),
29
+ ],
30
+ order: (0, shuffle_1.shuffle)(Array.from({ length: nbTerms }, (_, i) => i)),
31
+ };
32
+ };
33
+ const getStatementNode = (identifiers) => {
34
+ const { variable, coeffs, order } = identifiers;
35
+ const nodes = coeffs.flatMap((coeff, i) => coeff.map((c) => {
36
+ if (i === 0)
37
+ return c.toTree();
38
+ if (i === 1)
39
+ return (0, multiplyNode_1.multiply)(c, variable);
40
+ else
41
+ return (0, multiplyNode_1.multiply)(c, (0, powerNode_1.square)(variable));
42
+ }));
43
+ const shuffled = order.map((i) => nodes[i]);
44
+ // const polynome1 = new Polynomial(polynome1Coeffs, variable);
45
+ // const polynome2 = new Polynomial(polynome2Coeffs, variable);
46
+ return (0, operatorComposition_1.operatorComposition)(addNode_1.AddNode, shuffled);
47
+ // const statement = new AddNode(polynome1.toTree(), polynome2.toTree());
48
+ // return statement.deepShuffle({ nodeIdsToShuffle: [OperatorIds.add] });
49
+ };
50
+ const getStartStatement = (identifiers) => {
51
+ return getStatementNode(identifiers).toTex();
52
+ };
53
+ const getAnswer = (identifiers) => {
54
+ const answer = getStatementNode(identifiers)
55
+ .simplify({
56
+ forbidFactorize: true,
57
+ towardsDistribute: true,
58
+ })
59
+ .toTex();
60
+ return answer;
61
+ };
62
+ const getInstruction = (identifiers) => {
63
+ return `Réduire l'expression suivante :
64
+
65
+ $$
66
+ ${getStartStatement(identifiers)}
67
+ $$`;
68
+ };
10
69
  const getReduceExpression = () => {
11
70
  const rand = (0, randint_1.randint)(0, 7);
12
71
  let polynome1;
13
72
  let polynome2;
14
- switch (rand) {
15
- case 0: // ax + b + cx + d
16
- polynome1 = new polynomial_1.Polynomial([(0, randint_1.randint)(-9, 10), (0, randint_1.randint)(-9, 10, [0])]);
17
- polynome2 = new polynomial_1.Polynomial([(0, randint_1.randint)(-5, 6), (0, randint_1.randint)(-5, 6, [0])]);
18
- break;
19
- case 1:
20
- polynome1 = new polynomial_1.Polynomial([(0, randint_1.randint)(-9, 10), (0, randint_1.randint)(-9, 10, [0])]);
21
- polynome2 = new polynomial_1.Polynomial([0, (0, randint_1.randint)(-5, 6, [0])]);
22
- break;
23
- case 2:
24
- polynome1 = new polynomial_1.Polynomial([(0, randint_1.randint)(-9, 10), (0, randint_1.randint)(-9, 10, [0])]);
25
- polynome2 = new polynomial_1.Polynomial([(0, randint_1.randint)(-5, 6, [0])]);
26
- break;
27
- case 3:
28
- polynome1 = new polynomial_1.Polynomial([
29
- (0, randint_1.randint)(-9, 10),
30
- (0, randint_1.randint)(-9, 10),
31
- (0, randint_1.randint)(-9, 10, [0]),
32
- ]);
33
- polynome2 = new polynomial_1.Polynomial([0, (0, randint_1.randint)(-5, 6), (0, randint_1.randint)(-5, 6, [0])]);
34
- break;
35
- case 4:
36
- polynome1 = new polynomial_1.Polynomial([
37
- (0, randint_1.randint)(-9, 10),
38
- (0, randint_1.randint)(-9, 10),
39
- (0, randint_1.randint)(-9, 10, [0]),
40
- ]);
41
- polynome2 = new polynomial_1.Polynomial([0, 0, (0, randint_1.randint)(-5, 6, [0])]);
42
- break;
43
- case 5:
44
- polynome1 = new polynomial_1.Polynomial([
45
- (0, randint_1.randint)(-9, 10),
46
- (0, randint_1.randint)(-9, 10),
47
- (0, randint_1.randint)(-9, 10, [0]),
48
- ]);
49
- polynome2 = new polynomial_1.Polynomial([0, (0, randint_1.randint)(-5, 6, [0])]);
50
- break;
51
- case 6:
52
- polynome1 = new polynomial_1.Polynomial([
53
- (0, randint_1.randint)(-9, 10),
54
- (0, randint_1.randint)(-9, 10),
55
- (0, randint_1.randint)(-9, 10, [0]),
56
- ]);
57
- polynome2 = new polynomial_1.Polynomial([(0, randint_1.randint)(-5, 6, [0])]);
58
- break;
59
- default:
60
- throw Error("something went wrong");
73
+ //coeffs[0] est degré 0, coeffs[1] est degré 1, coeffs[2] degré 2
74
+ const coeffs = [[], [], []];
75
+ const nbTerms = (0, randint_1.randint)(4, 6);
76
+ for (let i = 0; i < nbTerms; i++) {
77
+ if (i === nbTerms - 1) {
78
+ let availableDegree = coeffs.findIndex((coeff) => coeff.length === 0);
79
+ if (availableDegree === -1)
80
+ availableDegree = (0, randint_1.randint)(0, 3);
81
+ coeffs[availableDegree].push((0, randint_1.randint)(-9, 10, [0]));
82
+ }
83
+ else {
84
+ const degree = (0, randint_1.randint)(0, 3);
85
+ coeffs[degree].push((0, randint_1.randint)(-9, 10, [0]));
86
+ }
61
87
  }
62
- const statement = new addNode_1.AddNode(polynome1.toTree(), polynome2.toTree());
63
- statement.shuffle();
64
- const statementTex = statement.toTex();
65
- const answer = polynome1.add(polynome2).toTree().toTex();
88
+ const order = (0, shuffle_1.shuffle)(Array.from({ length: nbTerms }, (_, i) => i));
89
+ // switch (rand) {
90
+ // case 0: // ax + b + cx + d
91
+ // polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
92
+ // polynome2 = new Polynomial([randint(-5, 6, [0]), randint(-5, 6, [0])]);
93
+ // break;
94
+ // case 1: //ax+b + cx
95
+ // polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
96
+ // polynome2 = new Polynomial([0, randint(-5, 6, [0])]);
97
+ // break;
98
+ // case 2: //ax+b+c
99
+ // polynome1 = new Polynomial([randint(-9, 10, [0]), randint(-9, 10, [0])]);
100
+ // polynome2 = new Polynomial([randint(-5, 6, [0])]);
101
+ // break;
102
+ // case 3: //ax^2+bx+c + ax^2+bx
103
+ // polynome1 = new Polynomial([
104
+ // randint(-9, 10),
105
+ // randint(-9, 10),
106
+ // randint(-9, 10, [0]),
107
+ // ]);
108
+ // polynome2 = new Polynomial([0, randint(-5, 6), randint(-5, 6, [0])]);
109
+ // break;
110
+ // case 4: //ax^2+bx+c + ax^2
111
+ // polynome1 = new Polynomial([
112
+ // randint(-9, 10),
113
+ // randint(-9, 10),
114
+ // randint(-9, 10, [0]),
115
+ // ]);
116
+ // polynome2 = new Polynomial([0, 0, randint(-5, 6, [0])]);
117
+ // break;
118
+ // case 5: //ax^2+bx+c + ax
119
+ // polynome1 = new Polynomial([
120
+ // randint(-9, 10),
121
+ // randint(-9, 10),
122
+ // randint(-9, 10, [0]),
123
+ // ]);
124
+ // polynome2 = new Polynomial([0, randint(-5, 6, [0])]);
125
+ // break;
126
+ // case 6: //ax^2 +bx+c + c
127
+ // polynome1 = new Polynomial([
128
+ // randint(-9, 10),
129
+ // randint(-9, 10),
130
+ // randint(-9, 10, [0]),
131
+ // ]);
132
+ // polynome2 = new Polynomial([randint(-5, 6, [0])]);
133
+ // break;
134
+ // default:
135
+ // throw Error("something went wrong");
136
+ // }
137
+ const variable = (0, random_1.random)(["x", "n", "a", "y", "t"]);
138
+ const identifiers = {
139
+ // rand,
140
+ // polynome1Coeffs: polynome1.coefficients,
141
+ // polynome2Coeffs: polynome2.coefficients,
142
+ coeffs,
143
+ variable,
144
+ order,
145
+ };
66
146
  const question = {
67
- instruction: `Réduire l'expression suivante : $${statementTex}$`,
68
- startStatement: statementTex,
69
- answer,
70
- keys: ["x"],
147
+ instruction: getInstruction(identifiers),
148
+ startStatement: getStartStatement(identifiers),
149
+ answer: getAnswer(identifiers),
150
+ keys: [variable],
71
151
  answerFormat: "tex",
72
- identifiers: {
73
- rand,
74
- polynome1Coeffs: polynome1.coefficients,
75
- polynome2Coeffs: polynome2.coefficients,
76
- },
152
+ identifiers,
77
153
  };
78
154
  return question;
79
155
  };
80
- const getPropositions = (n, { answer, rand, polynome1Coeffs }) => {
156
+ const getPropositions = (n, { answer, coeffs, variable }) => {
81
157
  const propositions = [];
82
158
  (0, exercise_1.addValidProp)(propositions, answer);
83
- const polynome1 = new polynomial_1.Polynomial(polynome1Coeffs);
159
+ (0, exercise_1.tryToAddWrongProp)(propositions, coeffs
160
+ .flatMap((e) => e)
161
+ .reduce((acc, curr) => acc + curr, 0)
162
+ .frenchify());
84
163
  while (propositions.length < n) {
85
- const polynome2 = new polynomial_1.Polynomial(rand < 3
86
- ? [(0, randint_1.randint)(-5, 6, [0]), (0, randint_1.randint)(-5, 6, [0])]
87
- : [(0, randint_1.randint)(-5, 6, [0]), (0, randint_1.randint)(-5, 6, [0]), (0, randint_1.randint)(-5, 6, [0])]);
88
- (0, exercise_1.tryToAddWrongProp)(propositions, polynome1.add(polynome2).toTree().toTex());
164
+ if (coeffs[2].length) {
165
+ (0, exercise_1.tryToAddWrongProp)(propositions, new trinom_1.Trinom((0, randint_1.randint)(-9, 10, [0]), (0, randint_1.randint)(-9, 10), (0, randint_1.randint)(-9, 10), {
166
+ variable,
167
+ })
168
+ .toTree()
169
+ .toTex());
170
+ }
171
+ else {
172
+ (0, exercise_1.tryToAddWrongProp)(propositions, new affine_1.Affine((0, randint_1.randint)(-9, 10, [0]), (0, randint_1.randint)(-9, 10)).toTree().toTex());
173
+ }
89
174
  }
90
175
  return (0, shuffle_1.shuffle)(propositions);
91
176
  };
92
- const isAnswerValid = (ans, { polynome1Coeffs, polynome2Coeffs, rand }) => {
93
- const polynome1 = new polynomial_1.Polynomial(polynome1Coeffs);
94
- const polynome2 = new polynomial_1.Polynomial(polynome2Coeffs);
95
- const answer = polynome1
96
- .add(polynome2)
97
- .toTree({ forbidPowerToProduct: true });
98
- const texs = answer.toAllValidTexs();
99
- return texs.includes(ans);
177
+ const isAnswerValid = (ans, { variable, answer }) => {
178
+ try {
179
+ const parsed = (0, polynomialParser_1.polynomialParser)(ans, { variable });
180
+ if (!parsed)
181
+ return false;
182
+ return (parsed
183
+ .simplify({
184
+ forbidFactorize: true,
185
+ towardsDistribute: true,
186
+ forbidAdditions: true,
187
+ })
188
+ .toTex() === answer);
189
+ }
190
+ catch (err) {
191
+ return (0, handleVEAError_1.handleVEAError)(err);
192
+ }
100
193
  };
101
194
  exports.reduceExpression = {
102
195
  id: "reduceExpression",
@@ -111,4 +204,7 @@ exports.reduceExpression = {
111
204
  getPropositions,
112
205
  isAnswerValid,
113
206
  subject: "Mathématiques",
207
+ rebuildIdentifiers,
208
+ getAnswer,
209
+ getInstruction,
114
210
  };
@@ -0,0 +1,2 @@
1
+ export * from "./tableReading";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataReading/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./tableReading"), exports);
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise";
2
+ type Identifiers = {
3
+ values: number[][];
4
+ caseAsked: number;
5
+ };
6
+ export declare const tableReading: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=tableReading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataReading/tableReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IAIjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4FF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAgB9C,CAAC"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tableReading = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const numberVEA_1 = require("../../../exercises/vea/numberVEA");
7
+ const randint_1 = require("../../../math/utils/random/randint");
8
+ const random_1 = require("../../../utils/alea/random");
9
+ const handleVEAError_1 = require("../../../utils/errors/handleVEAError");
10
+ const dollarize_1 = require("../../../utils/latex/dollarize");
11
+ const mdTable_1 = require("../../../utils/markdown/mdTable");
12
+ const getPropositions = (n, { answer, values, caseAsked }) => {
13
+ const propositions = [];
14
+ (0, exercise_1.addValidProp)(propositions, answer);
15
+ while (propositions.length < n) {
16
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, random_1.random)(values.flat()).frenchify());
17
+ }
18
+ return (0, exercise_1.shuffleProps)(propositions, n);
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { values, caseAsked } = identifiers;
22
+ const flatValues = values.flat();
23
+ return flatValues[caseAsked].frenchify();
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const { values, caseAsked } = identifiers;
27
+ let population = caseAsked % 3 === 0
28
+ ? "de la $6^e$ A"
29
+ : caseAsked % 3 === 1
30
+ ? "de la $6^e$ B"
31
+ : "";
32
+ let caractere = caseAsked < 3
33
+ ? "préfèrent le jeu Minecraft"
34
+ : caseAsked < 6
35
+ ? "préfèrent le jeu The Legend of Zelda"
36
+ : "ont répondu au sondage";
37
+ return `Un sondage a été réalisé auprès des élèves de deux classes de $6^e$ pour connaître leur jeu vidéo préféré. Voici leurs réponses :
38
+
39
+ ${(0, mdTable_1.mdTable)([
40
+ ["", "$6^e$ A", "$6^e$ B", "Total"],
41
+ ["Minecraft", ...values[0].map(dollarize_1.dollarize)],
42
+ ["The Legend of Zelda", ...values[1].map(dollarize_1.dollarize)],
43
+ ["Total", ...values[2].map(dollarize_1.dollarize)],
44
+ ])}
45
+
46
+ Combien d'élèves ${population} ${caractere} ?
47
+ `;
48
+ };
49
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
50
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
51
+ const getKeys = (identifiers) => {
52
+ return [];
53
+ };
54
+ const isAnswerValid = (ans, { answer }) => {
55
+ try {
56
+ return (0, numberVEA_1.numberVEA)(ans, answer);
57
+ }
58
+ catch (err) {
59
+ return (0, handleVEAError_1.handleVEAError)(err);
60
+ }
61
+ };
62
+ const getTableReadingQuestion = (ops) => {
63
+ const caseAsked = (0, randint_1.randint)(0, 9);
64
+ const totalA = (0, randint_1.randint)(20, 30);
65
+ const totalB = (0, randint_1.randint)(20, 30, [totalA]);
66
+ const case0 = (0, randint_1.randint)(3, totalA - 5);
67
+ const case1 = (0, randint_1.randint)(3, totalB - 5, [case0]);
68
+ const case3 = totalA - case0;
69
+ const case4 = totalB - case1;
70
+ const values = [
71
+ [case0, case1, case0 + case1],
72
+ [case3, case4, case3 + case4],
73
+ [totalA, totalB, totalA + totalB],
74
+ ];
75
+ const identifiers = {
76
+ caseAsked,
77
+ values,
78
+ };
79
+ const question = {
80
+ answer: getAnswer(identifiers),
81
+ instruction: getInstruction(identifiers),
82
+ keys: getKeys(identifiers),
83
+ answerFormat: "tex",
84
+ identifiers,
85
+ // hint: getHint(identifiers),
86
+ // correction: getCorrection(identifiers),
87
+ };
88
+ return question;
89
+ };
90
+ exports.tableReading = {
91
+ id: "tableReading",
92
+ connector: "=",
93
+ label: "Lire un tableau à double entrée",
94
+ isSingleStep: true,
95
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getTableReadingQuestion(opts), nb),
96
+ qcmTimer: 60,
97
+ freeTimer: 60,
98
+ getPropositions,
99
+ isAnswerValid,
100
+ subject: "Mathématiques",
101
+ getInstruction,
102
+ // getHint,
103
+ // getCorrection,
104
+ getAnswer,
105
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"convexityQuadrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/convexityQuadrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAmBlC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAqHF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
1
+ {"version":3,"file":"convexityQuadrinomials.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/convexityQuadrinomials.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAoBlC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAqHF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
@@ -13,6 +13,7 @@ const closure_1 = require("../../../../tree/nodes/sets/closure");
13
13
  const intervalNode_1 = require("../../../../tree/nodes/sets/intervalNode");
14
14
  const intervalParser_1 = require("../../../../tree/parsers/intervalParser");
15
15
  const coinFlip_1 = require("../../../../utils/alea/coinFlip");
16
+ const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
16
17
  const getConvexityQuadrinomialsQuestion = () => {
17
18
  const quadrinomial = polynomial_1.PolynomialConstructor.randomWithOrder(3);
18
19
  const quadcoeffs = quadrinomial.coefficients;
@@ -68,7 +69,7 @@ const isAnswerValid = (ans, { answer, askConvex, quadcoeffs }) => {
68
69
  return parsed.simplify().toTex() === answer;
69
70
  }
70
71
  catch (err) {
71
- return false;
72
+ return (0, handleVEAError_1.handleVEAError)(err);
72
73
  }
73
74
  };
74
75
  exports.convexityQuadrinomials = {
@@ -1 +1 @@
1
- {"version":3,"file":"expDerivativeFour.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeFour.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AA4EF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAgBnD,CAAC"}
1
+ {"version":3,"file":"expDerivativeFour.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeFour.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AA4EF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAgBnD,CAAC"}
@@ -7,6 +7,7 @@ const affine_1 = require("../../../../math/polynomials/affine");
7
7
  const expNode_1 = require("../../../../tree/nodes/functions/expNode");
8
8
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
9
9
  const latexParser_1 = require("../../../../tree/parsers/latexParser");
10
+ const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
10
11
  const getInstruction = (identifiers) => {
11
12
  const { affine1Coeffs, affine2Coeffs } = identifiers;
12
13
  const affine1 = new affine_1.Affine(affine1Coeffs[1], affine1Coeffs[0]);
@@ -56,7 +57,7 @@ const isAnswerValid = (ans, { answer, affine1Coeffs, affine2Coeffs }) => {
56
57
  return parsed.simplify().toTex() === answer;
57
58
  }
58
59
  catch (err) {
59
- return false;
60
+ return (0, handleVEAError_1.handleVEAError)(err);
60
61
  }
61
62
  };
62
63
  exports.expDerivativeFour = {
@@ -1 +1 @@
1
- {"version":3,"file":"expDerivativeThree.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeThree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqFF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAepD,CAAC"}
1
+ {"version":3,"file":"expDerivativeThree.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/expDerivativeThree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqFF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAepD,CAAC"}
@@ -10,6 +10,7 @@ const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
10
10
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
11
11
  const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
12
12
  const latexParser_1 = require("../../../../tree/parsers/latexParser");
13
+ const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
13
14
  const getInstruction = (identifiers) => {
14
15
  const { a, b } = identifiers;
15
16
  const myfunction = new multiplyNode_1.MultiplyNode(new polynomial_1.Polynomial([b, a]).toTree(), new expNode_1.ExpNode(new variableNode_1.VariableNode("x")));
@@ -56,7 +57,7 @@ const isAnswerValid = (ans, { a, b, answer }) => {
56
57
  return parsed.simplify().toTex() === answer;
57
58
  }
58
59
  catch (err) {
59
- return false;
60
+ return (0, handleVEAError_1.handleVEAError)(err);
60
61
  }
61
62
  };
62
63
  exports.expDerivativeThree = {
@@ -1 +1 @@
1
- {"version":3,"file":"lnDerivativeThree.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/lnDerivativeThree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8GF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAgBnD,CAAC"}
1
+ {"version":3,"file":"lnDerivativeThree.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/lnDerivativeThree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAgBlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8GF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAgBnD,CAAC"}
@@ -13,6 +13,7 @@ const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
13
13
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
14
14
  const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
15
15
  const latexParser_1 = require("../../../../tree/parsers/latexParser");
16
+ const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
16
17
  const getInstruction = (identifiers) => {
17
18
  const { a, b } = identifiers;
18
19
  const affine = new polynomial_1.Polynomial([b, a]).toTree();
@@ -83,7 +84,7 @@ const isAnswerValid = (ans, { a, b, answer }) => {
83
84
  .toTex() === answer);
84
85
  }
85
86
  catch (err) {
86
- return false;
87
+ return (0, handleVEAError_1.handleVEAError)(err);
87
88
  }
88
89
  };
89
90
  exports.lnDerivativeThree = {
@@ -1 +1 @@
1
- {"version":3,"file":"powerCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAOlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA0EF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAc5D,CAAC"}
1
+ {"version":3,"file":"powerCompositionDerivation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/powerCompositionDerivation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAoIF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAmB5D,CAAC"}
@@ -7,19 +7,73 @@ const affine_1 = require("../../../../math/polynomials/affine");
7
7
  const randint_1 = require("../../../../math/utils/random/randint");
8
8
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
9
9
  const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
10
- const getPowerCompositionDerivationQuestion = () => {
11
- const affine = affine_1.AffineConstructor.random(undefined, { excludes: [0] });
12
- const affineTree = affine.toTree();
13
- const power = (0, randint_1.randint)(3, 10);
10
+ const substractNode_1 = require("../../../../tree/nodes/operators/substractNode");
11
+ const latexParser_1 = require("../../../../tree/parsers/latexParser");
12
+ const handleVEAError_1 = require("../../../../utils/errors/handleVEAError");
13
+ const alignTex_1 = require("../../../../utils/latex/alignTex");
14
+ const getInstruction = (identifiers) => {
15
+ const { affineA, affineB, power } = identifiers;
16
+ const affine = new affine_1.Affine(affineA, affineB);
14
17
  const powerTree = power.toTree();
18
+ const affineTree = affine.toTree();
15
19
  const fct = new powerNode_1.PowerNode(affineTree, powerTree);
20
+ return `Déterminer la fonction dérivée de la fonction $f$ définie par :
21
+ $$
22
+ f(x) = ${fct.toTex()}
23
+ $$`;
24
+ };
25
+ const getAnswer = (identifiers) => {
26
+ const { affineA, affineB, power } = identifiers;
27
+ const affine = new affine_1.Affine(affineA, affineB);
28
+ const affineTree = affine.toTree();
16
29
  const deriv = new multiplyNode_1.MultiplyNode((power * affine.a).toTree(), new powerNode_1.PowerNode(affineTree, (power - 1).toTree()));
30
+ return deriv.toTex();
31
+ };
32
+ const getHint = (identifiers) => {
33
+ return `On rappelle la règle de dérivation suivante :
34
+
35
+ $$
36
+ \\left(u^n \\right)' = n \\times u' \\times u^{n-1}
37
+ $$
38
+ `;
39
+ };
40
+ const getCorrection = (identifiers) => {
41
+ const { affineA, affineB, power: pow } = identifiers;
42
+ const affine = new affine_1.Affine(affineA, affineB).toTree();
43
+ const affineTex = affine.toTex();
44
+ const answer = getAnswer(identifiers);
45
+ return `On sait que :
46
+
47
+ $$
48
+ \\left(u^n \\right)' = n \\times u' \\times u^{n-1}
49
+ $$
50
+
51
+ Ici, on a $n = ${pow}$, et $u(x) = ${affineTex}$, donc $u'(x) = ${affineA}$.
52
+
53
+ Ainsi,
54
+
55
+ ${(0, alignTex_1.alignTex)([
56
+ [
57
+ "f'(x)",
58
+ "=",
59
+ (0, multiplyNode_1.multiply)(pow, (0, multiplyNode_1.multiply)(affineA, (0, powerNode_1.power)(affine, (0, substractNode_1.substract)(pow, 1)))).toTex(),
60
+ ],
61
+ ["", "=", answer],
62
+ ])}
63
+ `;
64
+ };
65
+ const getPowerCompositionDerivationQuestion = () => {
66
+ const affine = affine_1.AffineConstructor.random(undefined, { excludes: [0] });
67
+ const power = (0, randint_1.randint)(3, 10);
68
+ const identifiers = { affineA: affine.a, affineB: affine.b, power };
17
69
  const question = {
18
- answer: deriv.toTex(),
19
- instruction: `Déterminer la dérivée de $f(x) = ${fct.toTex()}$`,
70
+ answer: getAnswer(identifiers),
71
+ instruction: getInstruction(identifiers),
72
+ hint: getHint(identifiers),
73
+ correction: getCorrection(identifiers),
20
74
  keys: ["x"],
21
75
  answerFormat: "tex",
22
- identifiers: { affineA: affine.a, affineB: affine.b, power },
76
+ identifiers,
23
77
  };
24
78
  return question;
25
79
  };
@@ -39,10 +93,15 @@ const getPropositions = (n, { answer, affineA, affineB, power }) => {
39
93
  return (0, exercise_1.shuffleProps)(propositions, n);
40
94
  };
41
95
  const isAnswerValid = (ans, { answer, power, affineA, affineB }) => {
42
- const affineTree = new affine_1.Affine(affineA, affineB).toTree();
43
- const deriv = new multiplyNode_1.MultiplyNode((power * affineA).toTree(), new powerNode_1.PowerNode(affineTree, (power - 1).toTree()));
44
- const texs = deriv.toAllValidTexs({ forbidPowerToProduct: true });
45
- return texs.includes(ans);
96
+ try {
97
+ const parsed = (0, latexParser_1.parseAlgebraic)(ans);
98
+ if (!parsed)
99
+ return false;
100
+ return parsed.simplify({ forbidFactorize: true }).toTex() === answer;
101
+ }
102
+ catch (err) {
103
+ return (0, handleVEAError_1.handleVEAError)(err);
104
+ }
46
105
  };
47
106
  exports.powerCompositionDerivation = {
48
107
  id: "powerCompositionDerivation",
@@ -57,4 +116,9 @@ exports.powerCompositionDerivation = {
57
116
  getPropositions,
58
117
  isAnswerValid,
59
118
  subject: "Mathématiques",
119
+ getAnswer,
120
+ getInstruction,
121
+ getHint,
122
+ getCorrection,
123
+ hasHintAndCorrection: true,
60
124
  };
@@ -1 +1 @@
1
- {"version":3,"file":"quotientDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/quotientDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAuGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAcpD,CAAC"}
1
+ {"version":3,"file":"quotientDerivative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/quotientDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAuGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAcpD,CAAC"}