math-exercises 3.0.216 → 3.0.218

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 (199) hide show
  1. package/lib/exercises/math/calcul/arithmetics/commonDivisorsList.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/arithmetics/commonDivisorsList.js +1 -0
  3. package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.d.ts.map +1 -1
  4. package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.js +5 -8
  5. package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.js +7 -17
  7. package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/fractions/fractionForbiddenValue.js +5 -6
  9. package/lib/exercises/math/calcul/fractions/fractionsDivision.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/fractions/fractionsDivision.js +7 -17
  11. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
  12. package/lib/exercises/math/calcul/fractions/fractionsSum.js +7 -22
  13. package/lib/exercises/math/calcul/fractions/fractionsSumFillInTheBlank.d.ts.map +1 -1
  14. package/lib/exercises/math/calcul/fractions/fractionsSumFillInTheBlank.js +7 -19
  15. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
  16. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +7 -22
  17. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
  18. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +7 -22
  19. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts +4 -1
  20. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts.map +1 -1
  21. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +7 -23
  22. package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.d.ts.map +1 -1
  23. package/lib/exercises/math/calcul/fractions/periodicWritingToFraction.js +3 -7
  24. package/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
  25. package/lib/exercises/math/calcul/fractions/simplifyFraction.js +6 -7
  26. package/lib/exercises/math/calcul/mentalCaluls/mentalDivisions.d.ts.map +1 -1
  27. package/lib/exercises/math/calcul/mentalCaluls/mentalDivisions.js +3 -4
  28. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication101AndFriends.d.ts.map +1 -1
  29. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication101AndFriends.js +2 -4
  30. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication11AndFriends.d.ts.map +1 -1
  31. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplication11AndFriends.js +2 -4
  32. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplicationTable.d.ts.map +1 -1
  33. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplicationTable.js +2 -4
  34. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.d.ts.map +1 -1
  35. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.js +2 -4
  36. package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.d.ts.map +1 -1
  37. package/lib/exercises/math/calcul/operations/operationsPrioritiesWithoutRelative.js +3 -4
  38. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.d.ts.map +1 -1
  39. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityAdd.js +14 -3
  40. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts.map +1 -1
  41. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.js +14 -3
  42. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.d.ts.map +1 -1
  43. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.js +8 -5
  44. package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.d.ts.map +1 -1
  45. package/lib/exercises/math/calculLitteral/distributivity/simpleDistriXCoeff.js +14 -5
  46. package/lib/exercises/math/calculLitteral/equation/exp/expOfFEqualsExpOfGEquation.d.ts.map +1 -1
  47. package/lib/exercises/math/calculLitteral/equation/exp/expOfFEqualsExpOfGEquation.js +19 -32
  48. package/lib/exercises/math/calculLitteral/equation/fractionEquation.d.ts.map +1 -1
  49. package/lib/exercises/math/calculLitteral/equation/fractionEquation.js +10 -10
  50. package/lib/exercises/math/calculLitteral/factorisation/factoByXK.d.ts +0 -8
  51. package/lib/exercises/math/calculLitteral/factorisation/factoByXK.d.ts.map +1 -1
  52. package/lib/exercises/math/calculLitteral/factorisation/factoByXK.js +223 -190
  53. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.d.ts.map +1 -1
  54. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.js +22 -9
  55. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +0 -1
  56. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
  57. package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -1
  58. package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts.map +1 -1
  59. package/lib/exercises/math/complex/argumentFromAlgebraicComplex.js +10 -4
  60. package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +2 -2
  61. package/lib/exercises/math/functions/absolute/absoluteValueEquations.js +12 -12
  62. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -1
  63. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +10 -18
  64. package/lib/exercises/math/functions/affines/affineMeanValue.d.ts.map +1 -1
  65. package/lib/exercises/math/functions/affines/affineMeanValue.js +3 -5
  66. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -1
  67. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +0 -1
  68. package/lib/exercises/math/functions/basics/twoFunctionsEquation.d.ts.map +1 -1
  69. package/lib/exercises/math/functions/basics/twoFunctionsEquation.js +12 -7
  70. package/lib/exercises/math/functions/integral/integralExpAxPlusB.d.ts.map +1 -1
  71. package/lib/exercises/math/functions/integral/integralExpAxPlusB.js +19 -3
  72. package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
  73. package/lib/exercises/math/functions/logarithm/log10Simplifying.js +20 -6
  74. package/lib/exercises/math/functions/logarithm/logSimplifiying.d.ts.map +1 -1
  75. package/lib/exercises/math/functions/logarithm/logSimplifiying.js +14 -9
  76. package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.d.ts.map +1 -1
  77. package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.js +9 -6
  78. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts.map +1 -1
  79. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.js +12 -8
  80. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.d.ts.map +1 -1
  81. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.js +21 -4
  82. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.d.ts.map +1 -1
  83. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.js +4 -7
  84. package/lib/exercises/math/functions/trinoms/trinomialMeanValue.d.ts.map +1 -1
  85. package/lib/exercises/math/functions/trinoms/trinomialMeanValue.js +3 -5
  86. package/lib/exercises/math/geometry/areas/circleArea.d.ts.map +1 -1
  87. package/lib/exercises/math/geometry/areas/circleArea.js +4 -2
  88. package/lib/exercises/math/geometry/areas/rectangleArea.d.ts.map +1 -1
  89. package/lib/exercises/math/geometry/areas/rectangleArea.js +4 -2
  90. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
  91. package/lib/exercises/math/geometry/areas/rightTriangleArea.js +14 -11
  92. package/lib/exercises/math/geometry/areas/squareArea.d.ts.map +1 -1
  93. package/lib/exercises/math/geometry/areas/squareArea.js +4 -2
  94. package/lib/exercises/math/geometry/areas/squareSideFromArea.d.ts.map +1 -1
  95. package/lib/exercises/math/geometry/areas/squareSideFromArea.js +6 -4
  96. package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
  97. package/lib/exercises/math/geometry/areas/triangleArea.js +3 -1
  98. package/lib/exercises/math/geometry/areas/triangleAreaV2.d.ts.map +1 -1
  99. package/lib/exercises/math/geometry/areas/triangleAreaV2.js +4 -2
  100. package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
  101. package/lib/exercises/math/geometry/cartesian/midpoint.js +6 -11
  102. package/lib/exercises/math/geometry/perimeters/rectangleSideFromPerimeter.d.ts.map +1 -1
  103. package/lib/exercises/math/geometry/perimeters/rectangleSideFromPerimeter.js +3 -3
  104. package/lib/exercises/math/geometry/perimeters/squareSideFromPerimeter.d.ts.map +1 -1
  105. package/lib/exercises/math/geometry/perimeters/squareSideFromPerimeter.js +3 -3
  106. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.d.ts.map +1 -1
  107. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.js +3 -5
  108. package/lib/exercises/math/geometry/volumes/parallelepipedVolume.d.ts.map +1 -1
  109. package/lib/exercises/math/geometry/volumes/parallelepipedVolume.js +3 -4
  110. package/lib/exercises/math/geometry/volumes/sphereVolume.d.ts.map +1 -1
  111. package/lib/exercises/math/geometry/volumes/sphereVolume.js +3 -4
  112. package/lib/exercises/math/geometry/volumes/volumeOfCube.d.ts.map +1 -1
  113. package/lib/exercises/math/geometry/volumes/volumeOfCube.js +3 -4
  114. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.d.ts.map +1 -1
  115. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.js +3 -6
  116. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.d.ts.map +1 -1
  117. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.js +3 -6
  118. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.d.ts.map +1 -1
  119. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.js +3 -1
  120. package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.d.ts +11 -0
  121. package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.d.ts.map +1 -0
  122. package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.js +155 -0
  123. package/lib/exercises/math/graphs/graphsCheckIsConnectedUndirectedGraph.js +1 -1
  124. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts +0 -2
  125. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts.map +1 -1
  126. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.js +4 -14
  127. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.d.ts.map +1 -1
  128. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.js +3 -1
  129. package/lib/exercises/math/graphs/graphsDegreeOfVertex.d.ts.map +1 -1
  130. package/lib/exercises/math/graphs/graphsDegreeOfVertex.js +3 -1
  131. package/lib/exercises/math/graphs/graphsOrderOfGraph.d.ts.map +1 -1
  132. package/lib/exercises/math/graphs/graphsOrderOfGraph.js +3 -1
  133. package/lib/exercises/math/graphs/index.d.ts +1 -1
  134. package/lib/exercises/math/graphs/index.d.ts.map +1 -1
  135. package/lib/exercises/math/graphs/index.js +1 -1
  136. package/lib/exercises/math/integration/fromExpr/integralFromExpr.d.ts.map +1 -1
  137. package/lib/exercises/math/integration/fromExpr/integralFromExpr.js +2 -0
  138. package/lib/exercises/math/limits/rationalFracLimit.d.ts.map +1 -1
  139. package/lib/exercises/math/limits/rationalFracLimit.js +9 -20
  140. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts.map +1 -1
  141. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.js +9 -20
  142. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
  143. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +11 -28
  144. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.d.ts.map +1 -1
  145. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.js +12 -27
  146. package/lib/exercises/math/spaceGeometry/parametricLine/lineLineRelativePositionsFromParametricLines.d.ts.map +1 -1
  147. package/lib/exercises/math/spaceGeometry/parametricLine/lineLineRelativePositionsFromParametricLines.js +56 -3
  148. package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlaneEquation.d.ts.map +1 -1
  149. package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlaneEquation.js +6 -0
  150. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -1
  151. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +3 -5
  152. package/lib/exercises/math/squareRoots/simpifySquareRoot.d.ts.map +1 -1
  153. package/lib/exercises/math/squareRoots/simpifySquareRoot.js +5 -4
  154. package/lib/exercises/math/squareRoots/squareRootEquation.d.ts.map +1 -1
  155. package/lib/exercises/math/squareRoots/squareRootEquation.js +9 -8
  156. package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
  157. package/lib/exercises/math/squareRoots/squareRootIdentities.js +7 -4
  158. package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
  159. package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +7 -8
  160. package/lib/exercises/math/trigonometry/arcLength.d.ts.map +1 -1
  161. package/lib/exercises/math/trigonometry/arcLength.js +3 -8
  162. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.d.ts.map +1 -1
  163. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.js +0 -6
  164. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts.map +1 -1
  165. package/lib/exercises/pc/dosage/beerLambertRandomValue.js +3 -4
  166. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.d.ts.map +1 -1
  167. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.js +3 -18
  168. package/lib/exercises/pc/energy/energyTransfer.d.ts.map +1 -1
  169. package/lib/exercises/pc/energy/energyTransfer.js +3 -8
  170. package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.d.ts.map +1 -1
  171. package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.js +3 -24
  172. package/lib/exercises/pc/math/proportionnalityCoeffFromLine.d.ts.map +1 -1
  173. package/lib/exercises/pc/math/proportionnalityCoeffFromLine.js +9 -6
  174. package/lib/exercises/vea/equationVEA.d.ts.map +1 -1
  175. package/lib/exercises/vea/equationVEA.js +2 -0
  176. package/lib/exercises/vea/rationalVEA.d.ts +2 -1
  177. package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
  178. package/lib/exercises/vea/rationalVEA.js +36 -2
  179. package/lib/exercises/vea/treeTableVEA.d.ts.map +1 -1
  180. package/lib/exercises/vea/treeTableVEA.js +2 -0
  181. package/lib/index.d.ts +3 -8
  182. package/lib/index.d.ts.map +1 -1
  183. package/lib/math/graphs/graph.d.ts +1 -1
  184. package/lib/math/graphs/graph.d.ts.map +1 -1
  185. package/lib/math/graphs/graph.js +86 -30
  186. package/lib/math/utils/graphs/graphRenderer.d.ts +7 -9
  187. package/lib/math/utils/graphs/graphRenderer.d.ts.map +1 -1
  188. package/lib/math/utils/graphs/graphRenderer.js +25 -117
  189. package/lib/tree/nodes/algebraicNode.d.ts +2 -0
  190. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  191. package/lib/tree/nodes/algebraicNode.js +11 -0
  192. package/lib/tree/nodes/functions/log10Node.d.ts +2 -2
  193. package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
  194. package/lib/tree/nodes/functions/log10Node.js +3 -1
  195. package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
  196. package/lib/tree/nodes/functions/logNode.js +2 -0
  197. package/lib/tree/nodes/operators/addNode.js +1 -1
  198. package/lib/tree/nodes/operators/fractionNode.js +1 -1
  199. package/package.json +1 -7
@@ -1,12 +1,9 @@
1
1
  import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../../exercises/vea/numberVEA.js";
3
4
  import { round } from "../../../../../math/utils/round.js";
4
5
  import { generateAffineCloud } from "../../../../../math/utils/stats/generateAffineCloud.js";
5
6
  import { rSquared } from "../../../../../math/utils/stats/rSquared.js";
6
- import { EqualNode } from "../../../../../tree/nodes/equations/equalNode.js";
7
- import { NumberNode } from "../../../../../tree/nodes/numbers/numberNode.js";
8
- import { PowerNode } from "../../../../../tree/nodes/operators/powerNode.js";
9
- import { VariableNode } from "../../../../../tree/nodes/variables/variableNode.js";
10
7
  import { dollarize } from "../../../../../utils/latex/dollarize.js";
11
8
  import { mdTable } from "../../../../../utils/markdown/mdTable.js";
12
9
  const getInstruction = (identifiers) => {
@@ -25,7 +22,7 @@ Déterminer la valeur du coefficient de détermination pour un ajustement affine
25
22
  const getAnswer = (identifiers) => {
26
23
  const { xValues, yValues } = identifiers;
27
24
  const r2 = round(rSquared(xValues, yValues), 2);
28
- const answer = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), r2.toTree()).toTex();
25
+ const answer = r2.toTree().toTex();
29
26
  return answer;
30
27
  };
31
28
  const getAffineAdjustmentRsquaredQuestion = () => {
@@ -52,7 +49,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
52
49
  const question = {
53
50
  answer: getAnswer(identifiers),
54
51
  instruction: getInstruction(identifiers),
55
- keys: ["R", "equal"],
52
+ keys: [],
56
53
  answerFormat: "tex",
57
54
  identifiers,
58
55
  style: {
@@ -71,26 +68,21 @@ const getPropositions = (n, { answer, xValues, yValues }) => {
71
68
  const propositions = [];
72
69
  const r2 = round(rSquared(xValues, yValues), 2);
73
70
  addValidProp(propositions, answer, "tex");
74
- const wrongAnswer1 = new EqualNode(new VariableNode("R"), r2.toTree()).toTex();
75
- const wrongAnswer2 = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), (r2 + 0.01).toTree()).toTex();
76
- const wrongAnswer3 = new EqualNode(new VariableNode("R"), (r2 - 0.01).toTree()).toTex();
71
+ const wrongAnswer1 = r2.toTree().toTex();
72
+ const wrongAnswer2 = (r2 + 0.01).toTree().toTex();
73
+ const wrongAnswer3 = (r2 - 0.01).toTree().toTex();
77
74
  tryToAddWrongProp(propositions, wrongAnswer1);
78
75
  tryToAddWrongProp(propositions, wrongAnswer2);
79
76
  tryToAddWrongProp(propositions, wrongAnswer3);
80
77
  propWhile(propositions, n, () => {
81
- const wrongAnswer = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(1)), round(Math.random(), 2).toTree()).toTex();
78
+ const wrongAnswer = round(Math.random(), 2).toTree().toTex();
82
79
  tryToAddWrongProp(propositions, wrongAnswer);
83
80
  });
84
81
  return shuffleProps(propositions, n);
85
82
  };
86
- const isAnswerValid = (ans, { xValues, yValues }) => {
87
- const r2 = round(rSquared(xValues, yValues), 2);
88
- const validanswer = new EqualNode(new PowerNode(new VariableNode("R"), new NumberNode(2)), r2.toTree());
89
- const latexs = validanswer.toAllValidTexs({
90
- allowRawRightChildAsSolution: true,
91
- allowFractionToDecimal: true,
92
- });
93
- return latexs.includes(ans);
83
+ const isAnswerValid = (ans, { answer }) => {
84
+ const trimed = ans.replace("R^2=", "").replace("R^{2}=", "");
85
+ return numberVEA(trimed, answer.replace("R^2=", "").replace("R^{2}=", ""));
94
86
  };
95
87
  export const affineAdjustmentRsquaredExercise = {
96
88
  id: "affineAdjustmentRsquared",
@@ -1 +1 @@
1
- {"version":3,"file":"affineMeanValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineMeanValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA6HF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,CAAC"}
1
+ {"version":3,"file":"affineMeanValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineMeanValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAgHF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
3
4
  import { Trinom } from "../../../../math/polynomials/trinom.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
5
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
@@ -73,11 +74,8 @@ const getPropositions = (n, { answer, trinomial, leftbound, rightbound }) => {
73
74
  });
74
75
  return shuffleProps(propositions, n);
75
76
  };
76
- const isAnswerValid = (ans, { trinomial, leftbound, rightbound }) => {
77
- const trinomial1 = new Trinom(trinomial[0], trinomial[1], trinomial[2]);
78
- const validanswer = new MultiplyNode(new FractionNode(new NumberNode(1), (rightbound - leftbound).toTree()), (trinomial1.calculate(rightbound) - trinomial1.calculate(leftbound)).toTree()).simplify();
79
- const latexs = validanswer.toAllValidTexs();
80
- return latexs.includes(ans);
77
+ const isAnswerValid = (ans, { answer }) => {
78
+ return rationalVEA(ans, answer);
81
79
  };
82
80
  export const affineMeanValue = {
83
81
  id: "affineMeanValue",
@@ -1 +1 @@
1
- {"version":3,"file":"findZeroesProductQuotient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/findZeroesProductQuotient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAuBrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AA6QF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAkB3D,CAAC"}
1
+ {"version":3,"file":"findZeroesProductQuotient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/findZeroesProductQuotient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAuBrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AA4QF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAkB3D,CAAC"}
@@ -166,7 +166,6 @@ const isAnswerValid = (ans, { answer, ...identifiers }) => {
166
166
  }
167
167
  };
168
168
  const isArrayOfNodesValid = (arrAns, arrAnswer) => {
169
- //tried with toAllValidTexs() but there is always an unhandled case
170
169
  function isNodesEqual(node1, node2) {
171
170
  return [1, 1_000, 1_000_000].every((factor) => substract(multiply(factor, node1), multiply(factor, node2)).evaluate() === 0);
172
171
  }
@@ -1 +1 @@
1
- {"version":3,"file":"twoFunctionsEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/twoFunctionsEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAyLF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
1
+ {"version":3,"file":"twoFunctionsEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/twoFunctionsEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AA0LF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
@@ -11,6 +11,8 @@ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
11
11
  import { random } from "../../../../utils/alea/random.js";
12
12
  import { Point } from "../../../../math/geometry/point.js";
13
13
  import { pluralize } from "../../../../utils/strings/pluralize.js";
14
+ import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
15
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
16
  const getHint = () => {
15
17
  return `Les solutions de l'équation $f(x) = g(x)$ sont les abscisses des points qui appartiennent à la fois à la courbe de $f$ et à celle de $g$.`;
16
18
  };
@@ -147,13 +149,16 @@ const getPropositions = (n, { answer }) => {
147
149
  });
148
150
  return shuffleProps(propositions, n);
149
151
  };
150
- const isAnswerValid = (ans, { fSplinePoints, yValue }) => {
151
- const xSolutions = fSplinePoints
152
- .filter((p) => p[1] === yValue)
153
- .map((p) => p[0]);
154
- const answerTree = new EquationSolutionNode(new DiscreteSetNode(xSolutions.map((sol) => new NumberNode(sol))));
155
- const texs = answerTree.toAllValidTexs();
156
- return texs.includes(ans);
152
+ const isAnswerValid = (ans, { answer }) => {
153
+ try {
154
+ const parsed = discreteSetParser(ans);
155
+ if (!parsed)
156
+ return false;
157
+ return ("S=" + parsed.simplify({ decimalToFractions: true }).toTex() === answer);
158
+ }
159
+ catch (err) {
160
+ return handleVEAError(err);
161
+ }
157
162
  };
158
163
  export const twoFunctionsEquation = {
159
164
  id: "twoFunctionsEquation",
@@ -1 +1 @@
1
- {"version":3,"file":"integralExpAxPlusB.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/integral/integralExpAxPlusB.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAwHF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAYpD,CAAC"}
1
+ {"version":3,"file":"integralExpAxPlusB.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/integral/integralExpAxPlusB.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA0IF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAYpD,CAAC"}
@@ -8,6 +8,8 @@ import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
8
8
  import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
9
9
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
10
10
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
13
  const getInstruction = (identifiers) => {
12
14
  const { a, b, aX, bX } = identifiers;
13
15
  const f = new Affine(aX, bX, "x");
@@ -53,9 +55,23 @@ const getPropositions = (n, { answer, a, b, aX, bX }) => {
53
55
  });
54
56
  return shuffleProps(propositions, n);
55
57
  };
56
- const isAnswerValid = (ans, { answer, ...identifiers }) => {
57
- const correctAns = getAnswerNode(identifiers);
58
- return correctAns.toAllValidTexs().includes(ans);
58
+ const isAnswerValid = (ans, { answer: _answer, ...identifiers }) => {
59
+ try {
60
+ const nodeAns = getAnswerNode(identifiers).simplify({
61
+ towardsDistribute: true,
62
+ forbidFactorize: true,
63
+ });
64
+ const parsed = parseAlgebraic(ans);
65
+ return (parsed
66
+ .simplify({
67
+ towardsDistribute: true,
68
+ forbidFactorize: true,
69
+ })
70
+ .toTex() === nodeAns.toTex());
71
+ }
72
+ catch (err) {
73
+ return handleVEAError(err);
74
+ }
59
75
  };
60
76
  const getAnswerNode = (identifiers) => {
61
77
  const { a, b, aX, bX } = identifiers;
@@ -1 +1 @@
1
- {"version":3,"file":"log10Simplifying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/log10Simplifying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AA8KF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB9D,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB5D,CAAC"}
1
+ {"version":3,"file":"log10Simplifying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/log10Simplifying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAuLF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB9D,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB5D,CAAC"}
@@ -8,8 +8,10 @@ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
8
8
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
9
9
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
10
10
  import { power, PowerNode } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
12
  import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
12
13
  import { random } from "../../../../utils/alea/random.js";
14
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
15
  const getStatement = (identifiers, opts) => {
14
16
  const { nb, powers, signs } = identifiers;
15
17
  const nbNode = new NumberNode(nb);
@@ -126,12 +128,24 @@ ${getStatement(identifiers, opts).toTex()} = ${getAnswer(identifiers, opts)}
126
128
  $$
127
129
  `;
128
130
  };
129
- const isAnswerValid = (ans, { answer, ...identifiers }, opts) => {
130
- const statement = getStatement(identifiers, opts);
131
- console.log(opts, identifiers);
132
- const answerNode = statement.simplify();
133
- const texs = answerNode.toAllValidTexs();
134
- return texs.includes(ans);
131
+ const isAnswerValid = (ans, { answer }) => {
132
+ try {
133
+ const rawNode = parseAlgebraic(answer);
134
+ const parsed = parseAlgebraic(ans);
135
+ return (parsed
136
+ .simplify({
137
+ forbidLogSimplify: true,
138
+ })
139
+ .toTex() ===
140
+ rawNode
141
+ .simplify({
142
+ forbidLogSimplify: true,
143
+ })
144
+ .toTex());
145
+ }
146
+ catch (err) {
147
+ return handleVEAError(err);
148
+ }
135
149
  };
136
150
  export const log10SumSimplifying = {
137
151
  id: "log10SumSimplifying",
@@ -1 +1 @@
1
- {"version":3,"file":"logSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/logSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
1
+ {"version":3,"file":"logSimplifiying.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/logarithm/logSimplifiying.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
@@ -2,14 +2,16 @@ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercis
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Rational } from "../../../../math/numbers/rationals/rational.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
- import { logn, LogNode } from "../../../../tree/nodes/functions/logNode.js";
5
+ import { isLogNode, logn, LogNode, } from "../../../../tree/nodes/functions/logNode.js";
6
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
7
7
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
8
8
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
9
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
10
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
11
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
11
12
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
12
13
  import { shuffle } from "../../../../utils/alea/shuffle.js";
14
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
15
  const getStatementNode = (identifiers) => {
14
16
  const { a, b, pm } = identifiers;
15
17
  const opts = { allowLnOfOne: true };
@@ -110,16 +112,19 @@ const getPropositions = (n, { answer, pm }) => {
110
112
  });
111
113
  return shuffle(propositions);
112
114
  };
113
- const isAnswerValid = (ans, { a, b, pm }) => {
114
- let answer;
115
- if (pm === 1) {
116
- answer = new LogNode(new NumberNode(a * b));
115
+ const isAnswerValid = (ans, { answer }) => {
116
+ try {
117
+ const parsed = parseAlgebraic(ans);
118
+ return (isLogNode(parsed) &&
119
+ parsed
120
+ .simplify({
121
+ forbidLogSimplify: true,
122
+ })
123
+ .toTex() === answer);
117
124
  }
118
- else {
119
- answer = new LogNode(new Rational(a, b).simplify().toTree({ allowFractionToDecimal: true }));
125
+ catch (err) {
126
+ return handleVEAError(err);
120
127
  }
121
- const texs = answer.toAllValidTexs();
122
- return texs.includes(ans);
123
128
  };
124
129
  export const logSimplifiying = {
125
130
  id: "logSimplifiying",
@@ -1 +1 @@
1
- {"version":3,"file":"rationalFractionForbiddenValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuGF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAchE,CAAC"}
1
+ {"version":3,"file":"rationalFractionForbiddenValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuGF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAchE,CAAC"}
@@ -1,11 +1,13 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
3
4
  import { Rational } from "../../../../math/numbers/rationals/rational.js";
4
5
  import { Affine } from "../../../../math/polynomials/affine.js";
5
6
  import { randint } from "../../../../math/utils/random/randint.js";
6
7
  import { equationResolutionTex } from "../../../../tree/nodes/equations/equalNode.js";
7
8
  import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
8
9
  import { shuffle } from "../../../../utils/alea/shuffle.js";
10
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
9
11
  const getInstruction = (identifiers) => {
10
12
  const { a, b, c, d } = identifiers;
11
13
  const affine1 = new Affine(a, b);
@@ -81,12 +83,13 @@ const getPropositions = (n, { answer, a, b, d }) => {
81
83
  });
82
84
  return shuffle(propositions);
83
85
  };
84
- const isAnswerValid = (ans, { c, d }) => {
85
- const answerTree = new Rational(-d, c)
86
- .simplify()
87
- .toTree({ allowFractionToDecimal: true });
88
- const texs = answerTree.toAllValidTexs();
89
- return texs.includes(ans);
86
+ const isAnswerValid = (ans, { answer }) => {
87
+ try {
88
+ return rationalVEA(ans, answer);
89
+ }
90
+ catch (err) {
91
+ return handleVEAError(err);
92
+ }
90
93
  };
91
94
  export const rationalFractionForbiddenValue = {
92
95
  id: "rationalFractionForbiddenValue",
@@ -1 +1 @@
1
- {"version":3,"file":"solveSecondDegreeEquationFromCano.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA4IF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAcnE,CAAC"}
1
+ {"version":3,"file":"solveSecondDegreeEquationFromCano.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA6IF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAcnE,CAAC"}
@@ -10,6 +10,8 @@ import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
10
10
  import { square } from "../../../../../tree/nodes/operators/powerNode.js";
11
11
  import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
12
12
  import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
13
+ import { discreteSetParser } from "../../../../../tree/parsers/discreteSetParser.js";
14
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
13
15
  import { alignTex } from "../../../../../utils/latex/alignTex.js";
14
16
  const getInstruction = (identifiers) => {
15
17
  const { coeffs } = identifiers;
@@ -116,14 +118,16 @@ const getPropositions = (n, { answer }) => {
116
118
  });
117
119
  return shuffleProps(propositions, n);
118
120
  };
119
- const isAnswerValid = (ans, { coeffs }) => {
120
- const trinom = TrinomConstructor.fromCoeffs(coeffs);
121
- const roots = trinom.getRootsNode();
122
- const answerTree = new EquationSolutionNode(new DiscreteSetNode(roots), {
123
- opts: { allowFractionToDecimal: true, allowRawRightChildAsSolution: true },
124
- });
125
- const texs = answerTree.toAllValidTexs();
126
- return texs.includes(ans);
121
+ const isAnswerValid = (ans, { answer }) => {
122
+ try {
123
+ const parsed = discreteSetParser(ans);
124
+ if (!parsed)
125
+ return false;
126
+ return ("S=" + parsed.simplify({ decimalToFractions: true }).toTex() === answer);
127
+ }
128
+ catch (err) {
129
+ return handleVEAError(err);
130
+ }
127
131
  };
128
132
  export const solveSecondDegreeEquationFromCano = {
129
133
  id: "solveSecondDegreeEquationFromCano",
@@ -1 +1 @@
1
- {"version":3,"file":"canonicalFromDevForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqNF,KAAK,OAAO,GAAG;IACb,cAAc,EACV,2BAA2B,GAC3B,kCAAkC,CAAC;CACxC,CAAC;AAWF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB/D,CAAC"}
1
+ {"version":3,"file":"canonicalFromDevForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqOF,KAAK,OAAO,GAAG;IACb,cAAc,EACV,2BAA2B,GAC3B,kCAAkC,CAAC;CACxC,CAAC;AAWF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB/D,CAAC"}
@@ -1,13 +1,16 @@
1
1
  import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
4
+ import { isFactorizedNode } from "../../../../../tree/nodes/algebraicNode.js";
4
5
  import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
5
6
  import { add } from "../../../../../tree/nodes/operators/addNode.js";
6
7
  import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
7
8
  import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
8
9
  import { square } from "../../../../../tree/nodes/operators/powerNode.js";
9
10
  import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
11
+ import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
10
12
  import { shuffle } from "../../../../../utils/alea/shuffle.js";
13
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
11
14
  import { alignTex } from "../../../../../utils/latex/alignTex.js";
12
15
  const getInstruction = (identifiers) => {
13
16
  const { a, b, c } = identifiers;
@@ -154,10 +157,24 @@ const getPropositions = (n, { answer, a }) => {
154
157
  return shuffle(propositions);
155
158
  };
156
159
  const isAnswerValid = (ans, { a, b, c }) => {
157
- const trinom = new Trinom(a, b, c);
158
- const node = trinom.getCanonicalForm();
159
- const texs = node.toAllValidTexs();
160
- return texs.includes(ans);
160
+ try {
161
+ const parsed = parseAlgebraic(ans);
162
+ const trinom = new Trinom(a, b, c);
163
+ const beta = trinom.getBetaNode();
164
+ const parsedWithoutBeta = substract(parsed, beta).simplify({
165
+ forbidFactorize: true,
166
+ });
167
+ return (isFactorizedNode(parsedWithoutBeta) &&
168
+ parsed
169
+ .simplify({
170
+ towardsDistribute: true,
171
+ forbidFactorize: true,
172
+ })
173
+ .toTex() === trinom.toTree().toTex());
174
+ }
175
+ catch (err) {
176
+ return handleVEAError(err);
177
+ }
161
178
  };
162
179
  const options = [
163
180
  {
@@ -1 +1 @@
1
- {"version":3,"file":"extremumFromCanonicalForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiGF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAe3D,CAAC"}
1
+ {"version":3,"file":"extremumFromCanonicalForm.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAgGF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAe3D,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { pointVEA } from "../../../../../exercises/vea/pointVEA.js";
3
4
  import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
4
5
  import { randint } from "../../../../../math/utils/random/randint.js";
5
- import { PointNode } from "../../../../../tree/nodes/geometry/pointNode.js";
6
6
  import { shuffle } from "../../../../../utils/alea/shuffle.js";
7
7
  const getHint = () => {
8
8
  return `La forme canonique d'une fonction polynôme du second degré est :
@@ -76,12 +76,9 @@ const getPropositions = (n, { answer, a, b, c }) => {
76
76
  });
77
77
  return shuffle(propositions);
78
78
  };
79
- const isAnswerValid = (ans, { a, b, c }) => {
80
- const trinom = new Trinom(a, b, c);
81
- const sommet = trinom.getSommet();
82
- const answer = new PointNode(sommet);
83
- const texs = answer.toAllValidTexs();
84
- return texs.includes(ans);
79
+ const isAnswerValid = (ans, { answer }) => {
80
+ return (pointVEA(ans, answer) ||
81
+ pointVEA(ans.replace("S", ""), answer.replace("S", "")));
85
82
  };
86
83
  export const extremumFromCanonicalForm = {
87
84
  id: "extremumFromCanonicalForm",
@@ -1 +1 @@
1
- {"version":3,"file":"trinomialMeanValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/trinoms/trinomialMeanValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA0HF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAYpD,CAAC"}
1
+ {"version":3,"file":"trinomialMeanValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/trinoms/trinomialMeanValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA6GF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAYpD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
3
4
  import { Polynomial } from "../../../../math/polynomials/polynomial.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
5
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
@@ -73,11 +74,8 @@ const getPropositions = (n, { answer, quadrinomial, leftbound, rightbound }) =>
73
74
  });
74
75
  return shuffleProps(propositions, n);
75
76
  };
76
- const isAnswerValid = (ans, { quadrinomial, leftbound, rightbound }) => {
77
- const quadrinomial1 = new Polynomial(quadrinomial);
78
- const validanswer = new MultiplyNode(new FractionNode(new NumberNode(1), (rightbound - leftbound).toTree()), (quadrinomial1.calculate(rightbound) - quadrinomial1.calculate(leftbound)).toTree()).simplify();
79
- const latexs = validanswer.toAllValidTexs();
80
- return latexs.includes(ans);
77
+ const isAnswerValid = (ans, { answer }) => {
78
+ return rationalVEA(ans, answer);
81
79
  };
82
80
  export const trinomialMeanValue = {
83
81
  id: "trinomialMeanValue",
@@ -1 +1 @@
1
- {"version":3,"file":"circleArea.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/areas/circleArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAwGF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAgB5C,CAAC"}
1
+ {"version":3,"file":"circleArea.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/areas/circleArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAyGF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAgB5C,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { addValidProp, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
3
4
  import { randint } from "../../../../math/utils/random/randint.js";
4
5
  import { round } from "../../../../math/utils/round.js";
5
6
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
@@ -85,8 +86,9 @@ const getPropositions = (n, { answer }) => {
85
86
  return shuffle(propositions);
86
87
  };
87
88
  const isAnswerValid = (ans, { answer }) => {
88
- const texs = [answer, answer.split("\\text")[0]];
89
- return texs.includes(ans);
89
+ const trimed = ans.replace("\\text{cm}^2", "").replace("\\text{cm}^{2}", "");
90
+ const nb = answer.split("\\text")[0];
91
+ return numberVEA(trimed, nb);
90
92
  };
91
93
  export const circleArea = {
92
94
  id: "circleArea",
@@ -1 +1 @@
1
- {"version":3,"file":"rectangleArea.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/areas/rectangleArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAkFF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAa/C,CAAC"}
1
+ {"version":3,"file":"rectangleArea.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/areas/rectangleArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAmFF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAa/C,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
3
4
  import { randint } from "../../../../math/utils/random/randint.js";
4
5
  import { shuffle } from "../../../../utils/alea/shuffle.js";
5
6
  const getKeys = () => ["cm", "cm2"];
@@ -56,8 +57,9 @@ const getPropositions = (n, { answer, length, width }) => {
56
57
  return shuffle(propositions);
57
58
  };
58
59
  const isAnswerValid = (ans, { answer }) => {
59
- const texs = [answer, answer.split("\\text")[0]];
60
- return texs.includes(ans);
60
+ const trimed = ans.replace("\\text{cm}^2", "").replace("\\text{cm}^{2}", "");
61
+ const nb = answer.split("\\text")[0];
62
+ return numberVEA(trimed, nb);
61
63
  };
62
64
  export const rectangleArea = {
63
65
  id: "rectangleArea",
@@ -1 +1 @@
1
- {"version":3,"file":"rightTriangleArea.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/areas/rightTriangleArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AAMnD,KAAK,WAAW,GAAG;IACjB,YAAY;IAEZ,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AA2IF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAcnD,CAAC"}
1
+ {"version":3,"file":"rightTriangleArea.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/areas/rightTriangleArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,2CAA2C,CAAC;AAOnD,KAAK,WAAW,GAAG;IACjB,YAAY;IAEZ,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AA4IF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAcnD,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
3
4
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
4
5
  import { RightTriangleConstructor } from "../../../../math/geometry/triangles/rightTriangle.js";
5
6
  import { TriangleConstructor, } from "../../../../math/geometry/triangles/triangle.js";
6
- import { Rational } from "../../../../math/numbers/rationals/rational.js";
7
7
  import { randint } from "../../../../math/utils/random/randint.js";
8
8
  import { shuffle } from "../../../../utils/alea/shuffle.js";
9
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
9
10
  import { alignTex } from "../../../../utils/latex/alignTex.js";
10
11
  const getInstruction = (identifiers) => {
11
12
  const triangle = TriangleConstructor.fromIdentifiers(identifiers.triangleIdentifiers);
@@ -98,16 +99,18 @@ const getPropositions = (n, { answer }) => {
98
99
  return shuffle(propositions);
99
100
  };
100
101
  const isAnswerValid = (ans, { answer }) => {
101
- const double = Number(answer.split("\\text")[0].replace(",", ".")) * 2;
102
- const area = new Rational(double, 2)
103
- .simplify()
104
- .toTree({ allowFractionToDecimal: true });
105
- const numberTexs = area.toAllValidTexs();
106
- const texs = [
107
- ...numberTexs,
108
- ...numberTexs.map((tex) => tex + "\\text{cm}^2"),
109
- ];
110
- return texs.includes(ans);
102
+ try {
103
+ const trimed = ans
104
+ .replace("\\text{cm}^2", "")
105
+ .replace("\\text{cm}^{2}", "");
106
+ const answerTrimed = answer
107
+ .replace("\\text{cm}^2", "")
108
+ .replace("\\text{cm}^{2}", "");
109
+ return rationalVEA(trimed, answerTrimed);
110
+ }
111
+ catch (err) {
112
+ return handleVEAError(err);
113
+ }
111
114
  };
112
115
  export const rightTriangleArea = {
113
116
  id: "rightTriangleArea",
@@ -1 +1 @@
1
- {"version":3,"file":"squareArea.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/areas/squareArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAsEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAc5C,CAAC"}
1
+ {"version":3,"file":"squareArea.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/areas/squareArea.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAuEF,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,WAAW,CAc5C,CAAC"}