math-exercises 3.0.217 → 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 (180) 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/fractionEquation.d.ts.map +1 -1
  47. package/lib/exercises/math/calculLitteral/equation/fractionEquation.js +10 -10
  48. package/lib/exercises/math/calculLitteral/factorisation/factoByXK.d.ts +0 -8
  49. package/lib/exercises/math/calculLitteral/factorisation/factoByXK.d.ts.map +1 -1
  50. package/lib/exercises/math/calculLitteral/factorisation/factoByXK.js +223 -190
  51. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.d.ts.map +1 -1
  52. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.js +22 -9
  53. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +0 -1
  54. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
  55. package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -1
  56. package/lib/exercises/math/complex/argumentFromAlgebraicComplex.d.ts.map +1 -1
  57. package/lib/exercises/math/complex/argumentFromAlgebraicComplex.js +10 -4
  58. package/lib/exercises/math/functions/absolute/absoluteValueEquations.js +12 -12
  59. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -1
  60. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +10 -18
  61. package/lib/exercises/math/functions/affines/affineMeanValue.d.ts.map +1 -1
  62. package/lib/exercises/math/functions/affines/affineMeanValue.js +3 -5
  63. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -1
  64. package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +0 -1
  65. package/lib/exercises/math/functions/basics/twoFunctionsEquation.d.ts.map +1 -1
  66. package/lib/exercises/math/functions/basics/twoFunctionsEquation.js +12 -7
  67. package/lib/exercises/math/functions/integral/integralExpAxPlusB.d.ts.map +1 -1
  68. package/lib/exercises/math/functions/integral/integralExpAxPlusB.js +19 -3
  69. package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
  70. package/lib/exercises/math/functions/logarithm/log10Simplifying.js +20 -6
  71. package/lib/exercises/math/functions/logarithm/logSimplifiying.d.ts.map +1 -1
  72. package/lib/exercises/math/functions/logarithm/logSimplifiying.js +14 -9
  73. package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.d.ts.map +1 -1
  74. package/lib/exercises/math/functions/rationalFraction/rationalFractionForbiddenValue.js +9 -6
  75. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.d.ts.map +1 -1
  76. package/lib/exercises/math/functions/trinoms/equation/solveSecondDegreeEquationFromCano.js +12 -8
  77. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.d.ts.map +1 -1
  78. package/lib/exercises/math/functions/trinoms/summitAndCanonical/canonicalFromDevForm.js +21 -4
  79. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.d.ts.map +1 -1
  80. package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumFromCanonicalForm.js +4 -7
  81. package/lib/exercises/math/functions/trinoms/trinomialMeanValue.d.ts.map +1 -1
  82. package/lib/exercises/math/functions/trinoms/trinomialMeanValue.js +3 -5
  83. package/lib/exercises/math/geometry/areas/circleArea.d.ts.map +1 -1
  84. package/lib/exercises/math/geometry/areas/circleArea.js +4 -2
  85. package/lib/exercises/math/geometry/areas/rectangleArea.d.ts.map +1 -1
  86. package/lib/exercises/math/geometry/areas/rectangleArea.js +4 -2
  87. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
  88. package/lib/exercises/math/geometry/areas/rightTriangleArea.js +14 -11
  89. package/lib/exercises/math/geometry/areas/squareArea.d.ts.map +1 -1
  90. package/lib/exercises/math/geometry/areas/squareArea.js +4 -2
  91. package/lib/exercises/math/geometry/areas/squareSideFromArea.d.ts.map +1 -1
  92. package/lib/exercises/math/geometry/areas/squareSideFromArea.js +6 -4
  93. package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
  94. package/lib/exercises/math/geometry/areas/triangleArea.js +3 -1
  95. package/lib/exercises/math/geometry/areas/triangleAreaV2.d.ts.map +1 -1
  96. package/lib/exercises/math/geometry/areas/triangleAreaV2.js +4 -2
  97. package/lib/exercises/math/geometry/cartesian/midpoint.d.ts.map +1 -1
  98. package/lib/exercises/math/geometry/cartesian/midpoint.js +6 -11
  99. package/lib/exercises/math/geometry/perimeters/rectangleSideFromPerimeter.d.ts.map +1 -1
  100. package/lib/exercises/math/geometry/perimeters/rectangleSideFromPerimeter.js +3 -3
  101. package/lib/exercises/math/geometry/perimeters/squareSideFromPerimeter.d.ts.map +1 -1
  102. package/lib/exercises/math/geometry/perimeters/squareSideFromPerimeter.js +3 -3
  103. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.d.ts.map +1 -1
  104. package/lib/exercises/math/geometry/vectors/vectorNormCalculation.js +3 -5
  105. package/lib/exercises/math/geometry/volumes/parallelepipedVolume.d.ts.map +1 -1
  106. package/lib/exercises/math/geometry/volumes/parallelepipedVolume.js +3 -4
  107. package/lib/exercises/math/geometry/volumes/sphereVolume.d.ts.map +1 -1
  108. package/lib/exercises/math/geometry/volumes/sphereVolume.js +3 -4
  109. package/lib/exercises/math/geometry/volumes/volumeOfCube.d.ts.map +1 -1
  110. package/lib/exercises/math/geometry/volumes/volumeOfCube.js +3 -4
  111. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.d.ts.map +1 -1
  112. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.js +3 -6
  113. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.d.ts.map +1 -1
  114. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.js +3 -6
  115. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.d.ts.map +1 -1
  116. package/lib/exercises/math/graphs/graphsChainOrPathOfLengthN.js +3 -1
  117. package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.d.ts.map +1 -1
  118. package/lib/exercises/math/graphs/graphsCheckIsConnectedGraph.js +19 -42
  119. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts +0 -2
  120. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.d.ts.map +1 -1
  121. package/lib/exercises/math/graphs/graphsCheckIsSameGraph.js +4 -14
  122. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.d.ts.map +1 -1
  123. package/lib/exercises/math/graphs/graphsCheckIsVerticesAdjacent.js +3 -1
  124. package/lib/exercises/math/graphs/graphsDegreeOfVertex.d.ts.map +1 -1
  125. package/lib/exercises/math/graphs/graphsDegreeOfVertex.js +3 -1
  126. package/lib/exercises/math/graphs/graphsOrderOfGraph.d.ts.map +1 -1
  127. package/lib/exercises/math/graphs/graphsOrderOfGraph.js +3 -1
  128. package/lib/exercises/math/limits/rationalFracLimit.d.ts.map +1 -1
  129. package/lib/exercises/math/limits/rationalFracLimit.js +9 -20
  130. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.d.ts.map +1 -1
  131. package/lib/exercises/math/limits/sequences/sequenceRationalFracLimit.js +9 -20
  132. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
  133. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +11 -28
  134. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.d.ts.map +1 -1
  135. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFirstRankOne.js +12 -27
  136. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -1
  137. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +3 -5
  138. package/lib/exercises/math/squareRoots/simpifySquareRoot.d.ts.map +1 -1
  139. package/lib/exercises/math/squareRoots/simpifySquareRoot.js +5 -4
  140. package/lib/exercises/math/squareRoots/squareRootEquation.d.ts.map +1 -1
  141. package/lib/exercises/math/squareRoots/squareRootEquation.js +9 -8
  142. package/lib/exercises/math/squareRoots/squareRootIdentities.d.ts.map +1 -1
  143. package/lib/exercises/math/squareRoots/squareRootIdentities.js +7 -4
  144. package/lib/exercises/math/squareRoots/squareRootsDistributivity.d.ts.map +1 -1
  145. package/lib/exercises/math/squareRoots/squareRootsDistributivity.js +7 -8
  146. package/lib/exercises/math/trigonometry/arcLength.d.ts.map +1 -1
  147. package/lib/exercises/math/trigonometry/arcLength.js +3 -8
  148. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.d.ts.map +1 -1
  149. package/lib/exercises/pc/chemicalElements/findAtomEntitiesNumberFromMass.js +0 -6
  150. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts.map +1 -1
  151. package/lib/exercises/pc/dosage/beerLambertRandomValue.js +3 -4
  152. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.d.ts.map +1 -1
  153. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.js +3 -18
  154. package/lib/exercises/pc/energy/energyTransfer.d.ts.map +1 -1
  155. package/lib/exercises/pc/energy/energyTransfer.js +3 -8
  156. package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.d.ts.map +1 -1
  157. package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.js +3 -24
  158. package/lib/exercises/pc/math/proportionnalityCoeffFromLine.d.ts.map +1 -1
  159. package/lib/exercises/pc/math/proportionnalityCoeffFromLine.js +9 -6
  160. package/lib/exercises/vea/equationVEA.d.ts.map +1 -1
  161. package/lib/exercises/vea/equationVEA.js +2 -0
  162. package/lib/exercises/vea/rationalVEA.d.ts +2 -1
  163. package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
  164. package/lib/exercises/vea/rationalVEA.js +36 -2
  165. package/lib/index.d.ts +3 -8
  166. package/lib/index.d.ts.map +1 -1
  167. package/lib/math/utils/graphs/graphRenderer.d.ts +7 -9
  168. package/lib/math/utils/graphs/graphRenderer.d.ts.map +1 -1
  169. package/lib/math/utils/graphs/graphRenderer.js +25 -117
  170. package/lib/tree/nodes/algebraicNode.d.ts +2 -0
  171. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  172. package/lib/tree/nodes/algebraicNode.js +11 -0
  173. package/lib/tree/nodes/functions/log10Node.d.ts +2 -2
  174. package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
  175. package/lib/tree/nodes/functions/log10Node.js +3 -1
  176. package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
  177. package/lib/tree/nodes/functions/logNode.js +2 -0
  178. package/lib/tree/nodes/operators/addNode.js +1 -1
  179. package/lib/tree/nodes/operators/fractionNode.js +1 -1
  180. package/package.json +1 -7
@@ -1 +1 @@
1
- {"version":3,"file":"commonDivisorsList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/commonDivisorsList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA6GF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
1
+ {"version":3,"file":"commonDivisorsList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/commonDivisorsList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8GF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
@@ -85,6 +85,7 @@ const isAnswerValid = (ans, { answer }) => {
85
85
  const values = ans
86
86
  .replaceAll(",", ";")
87
87
  .split(";")
88
+ .filter(Boolean)
88
89
  .map((v) => Number(v));
89
90
  if (values.some((v) => isNaN(v)))
90
91
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"fractionAndIntegerDivision.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionAndIntegerDivision.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAsKF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAc5D,CAAC"}
1
+ {"version":3,"file":"fractionAndIntegerDivision.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionAndIntegerDivision.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AA+JF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAc5D,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 { Integer } from "../../../../math/numbers/integer/integer.js";
4
5
  import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
5
6
  import { randint } from "../../../../math/utils/random/randint.js";
@@ -124,14 +125,10 @@ const getPropositions = (n, { answer, integerFirst, integer, rational }) => {
124
125
  });
125
126
  return shuffleProps(propositions, n);
126
127
  };
127
- const isAnswerValid = (ans, { integer, integerFirst, rational }) => {
128
- const integerObj = new Integer(integer);
129
- const rationalObj = new Rational(rational[0], rational[1]);
130
- const answerTree = integerFirst
131
- ? integerObj.divide(rationalObj).toTree({ allowFractionToDecimal: true })
132
- : rationalObj.divide(integerObj).toTree({ allowFractionToDecimal: true });
133
- const texs = answerTree.toAllValidTexs();
134
- return texs.includes(ans);
128
+ const isAnswerValid = (ans, { answer }) => {
129
+ return rationalVEA(ans, answer, {
130
+ allowNonIrreductible: false,
131
+ });
135
132
  };
136
133
  export const fractionAndIntegerDivision = {
137
134
  id: "fractionAndIntegerDivision",
@@ -1 +1 @@
1
- {"version":3,"file":"fractionAndIntegerProduct.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionAndIntegerProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAiJF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAepE,CAAC"}
1
+ {"version":3,"file":"fractionAndIntegerProduct.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionAndIntegerProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAqIF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAepE,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { allowNonIrreductibleOption } from "../../../../exercises/options/allowNonIrreductibleFractions.js";
3
3
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
4
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
5
  import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
5
6
  import { randint } from "../../../../math/utils/random/randint.js";
6
7
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
8
  import { MultiplyNode, multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
8
- import { rationalParser } from "../../../../tree/parsers/rationalParser.js";
9
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
10
  import { shuffle } from "../../../../utils/alea/shuffle.js";
11
11
  const options = [allowNonIrreductibleOption];
@@ -97,22 +97,12 @@ const getPropositions = (n, { answer, integer, rational }) => {
97
97
  });
98
98
  return shuffle(propositions);
99
99
  };
100
- const isAnswerValid = (ans, { integer, rational, integerFirst }, opts) => {
101
- const answerTree = getStatement({
102
- integer,
103
- rational,
104
- integerFirst,
105
- }).simplify();
106
- const texs = answerTree.toAllValidTexs({ allowFractionToDecimal: true });
107
- if (opts?.allowNonIrreductible) {
108
- const parsed = rationalParser(ans);
109
- if (!parsed)
110
- return false;
111
- return texs.includes(parsed.simplify().toTex());
112
- }
113
- else {
114
- return texs.includes(ans);
115
- }
100
+ const isAnswerValid = (ans, { answer }, opts) => {
101
+ const allowNonIrr = opts?.allowNonIrreductible ?? false;
102
+ return rationalVEA(ans, answer, {
103
+ allowNonIrreductible: allowNonIrr,
104
+ allowDecimalApprox: false,
105
+ });
116
106
  };
117
107
  export const fractionAndIntegerProduct = {
118
108
  id: "fractionAndIntegerProduct",
@@ -1 +1 @@
1
- {"version":3,"file":"fractionForbiddenValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionForbiddenValue.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;AAsGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
1
+ {"version":3,"file":"fractionForbiddenValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionForbiddenValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,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;AAoGF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,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 { 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";
@@ -81,12 +82,10 @@ const getPropositions = (n, { answer, a, b, d }) => {
81
82
  });
82
83
  return shuffle(propositions);
83
84
  };
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);
85
+ const isAnswerValid = (ans, { answer }) => {
86
+ return rationalVEA(ans, answer, {
87
+ allowDecimalApprox: false,
88
+ });
90
89
  };
91
90
  export const fractionForbiddenValue = {
92
91
  id: "fractionForbiddenValue",
@@ -1 +1 @@
1
- {"version":3,"file":"fractionsDivision.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsDivision.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAiKF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAe5D,CAAC"}
1
+ {"version":3,"file":"fractionsDivision.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsDivision.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAmJF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAe5D,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { allowNonIrreductibleOption } from "../../../../exercises/options/allowNonIrreductibleFractions.js";
3
3
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
4
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
5
  import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
5
6
  import { DivideNode } from "../../../../tree/nodes/operators/divideNode.js";
6
- import { rationalParser } from "../../../../tree/parsers/rationalParser.js";
7
7
  import { shuffle } from "../../../../utils/alea/shuffle.js";
8
8
  const options = [allowNonIrreductibleOption];
9
9
  const getInstruction = (identifiers, opts) => {
@@ -106,22 +106,12 @@ const getPropositions = (n, { answer, rationalNum, rationalDenum }) => {
106
106
  });
107
107
  return shuffle(propositions);
108
108
  };
109
- const isAnswerValid = (ans, { rationalDenum, rationalNum }, opts) => {
110
- const rational = new Rational(rationalNum[0], rationalNum[1]);
111
- const rational2 = new Rational(rationalDenum[0], rationalDenum[1]);
112
- const answerTree = rational
113
- .divide(rational2)
114
- .toTree({ allowFractionToDecimal: true });
115
- const texs = answerTree.toAllValidTexs();
116
- if (opts?.allowNonIrreductible) {
117
- const parsed = rationalParser(ans);
118
- if (!parsed)
119
- return false;
120
- return texs.includes(parsed.simplify().toTex());
121
- }
122
- else {
123
- return texs.includes(ans);
124
- }
109
+ const isAnswerValid = (ans, { answer }, opts) => {
110
+ const allowNonIrr = opts?.allowNonIrreductible ?? false;
111
+ return rationalVEA(ans, answer, {
112
+ allowNonIrreductible: allowNonIrr,
113
+ allowDecimalApprox: false,
114
+ });
125
115
  };
126
116
  export const fractionsDivision = {
127
117
  id: "fractionsDivision",
@@ -1 +1 @@
1
- {"version":3,"file":"fractionsSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAuSF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAevD,CAAC"}
1
+ {"version":3,"file":"fractionsSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAuRF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAevD,CAAC"}
@@ -1,13 +1,12 @@
1
1
  import { GeneratorOptionTarget, GeneratorOptionType, 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, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
5
  import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
5
6
  import { add, AddNode } 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
- import { rationalParser } from "../../../../tree/parsers/rationalParser.js";
9
9
  import { shuffle } from "../../../../utils/alea/shuffle.js";
10
- import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
10
  const getInstruction = (identifiers, opts) => {
12
11
  const { rational, rational2 } = identifiers;
13
12
  const rationalObj = new Rational(rational[0], rational[1]);
@@ -208,26 +207,12 @@ const getPropositions = (n, { answer, rational, rational2 }) => {
208
207
  });
209
208
  return shuffle(propositions);
210
209
  };
211
- const isAnswerValid = (ans, { rational, rational2 }, opts) => {
212
- const rationalA = new Rational(rational[0], rational[1]);
213
- const rationalB = new Rational(rational2[0], rational2[1]);
214
- const allow = opts?.allowNonIrreductible;
215
- const answerTree = rationalA
216
- .add(rationalB)
217
- .toTree({ allowFractionToDecimal: true });
218
- const texs = answerTree.toAllValidTexs();
219
- if (allow)
220
- try {
221
- const parsed = rationalParser(ans);
222
- if (!parsed)
223
- return false;
224
- return texs.includes(parsed.simplify().toTex());
225
- }
226
- catch (err) {
227
- return handleVEAError(err);
228
- }
229
- else
230
- return texs.includes(ans);
210
+ const isAnswerValid = (ans, { answer }, opts) => {
211
+ const allowNonIrr = opts?.allowNonIrreductible ?? false;
212
+ return rationalVEA(ans, answer, {
213
+ allowNonIrreductible: allowNonIrr,
214
+ allowDecimalApprox: false,
215
+ });
231
216
  };
232
217
  const options = [
233
218
  {
@@ -1 +1 @@
1
- {"version":3,"file":"fractionsSumFillInTheBlank.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumFillInTheBlank.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAkBrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA8RF,KAAK,OAAO,GAAG;IACb,oBAAoB,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAiCF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAerE,CAAC"}
1
+ {"version":3,"file":"fractionsSumFillInTheBlank.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumFillInTheBlank.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAiRF,KAAK,OAAO,GAAG;IACb,oBAAoB,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAiCF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAerE,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionTarget, GeneratorOptionType, propWhile, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
4
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
5
  import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
5
6
  import { randint } from "../../../../math/utils/random/randint.js";
6
7
  import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
@@ -8,9 +9,7 @@ import { add } from "../../../../tree/nodes/operators/addNode.js";
8
9
  import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
9
10
  import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
11
  import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
11
- import { rationalParser } from "../../../../tree/parsers/rationalParser.js";
12
12
  import { random } from "../../../../utils/alea/random.js";
13
- import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
13
  import { alignTex } from "../../../../utils/latex/alignTex.js";
15
14
  const getHydrated = (identifiers) => {
16
15
  const { numSum, numOperand, denom, indexBlank } = identifiers;
@@ -146,23 +145,12 @@ const getPropositions = (n, { answer, ...identifiers }) => {
146
145
  });
147
146
  return shuffleProps(propositions, n);
148
147
  };
149
- const isAnswerValid = (ans, { answer, ...identifiers }, opts) => {
150
- const { nodeAnswer } = getHydrated(identifiers);
151
- const texs = nodeAnswer.toAllValidTexs();
152
- if (opts?.allowNonIrreductible) {
153
- try {
154
- const parsed = rationalParser(ans);
155
- if (!parsed)
156
- return false;
157
- return texs.includes(parsed.simplify().toTex());
158
- }
159
- catch (err) {
160
- return handleVEAError(err);
161
- }
162
- }
163
- else {
164
- return texs.includes(ans);
165
- }
148
+ const isAnswerValid = (ans, { answer }, opts) => {
149
+ const allowNonIrr = opts?.allowNonIrreductible ?? false;
150
+ return rationalVEA(ans, answer, {
151
+ allowNonIrreductible: allowNonIrr,
152
+ allowDecimalApprox: false,
153
+ });
166
154
  };
167
155
  const createRandomIdentifiers = (opts) => {
168
156
  const denomSrc = parseInt(opts.denom);
@@ -1 +1 @@
1
- {"version":3,"file":"fractionsSumsMultiplesDenominators.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAkKF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CACvD,WAAW,EACX,OAAO,CAmBR,CAAC"}
1
+ {"version":3,"file":"fractionsSumsMultiplesDenominators.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAiJF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CACvD,WAAW,EACX,OAAO,CAmBR,CAAC"}
@@ -1,14 +1,13 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionTarget, GeneratorOptionType, propWhile, } 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, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
5
  import { randint } from "../../../../math/utils/random/randint.js";
5
6
  import { round } from "../../../../math/utils/round.js";
6
7
  import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
8
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
9
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
- import { rationalParser } from "../../../../tree/parsers/rationalParser.js";
10
10
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
11
- import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
11
  import { alignTex } from "../../../../utils/latex/alignTex.js";
13
12
  const getInstruction = (identifiers, opts) => {
14
13
  const { num1, num2, denom1, denom2 } = identifiers;
@@ -96,26 +95,12 @@ const getPropositions = (n, { answer, num1, num2, denom1, denom2 }) => {
96
95
  });
97
96
  return shuffleProps(propositions, n);
98
97
  };
99
- const isAnswerValid = (ans, { denom1, denom2, num1, num2 }, opts) => {
100
- const rationalA = new Rational(num1, denom1);
101
- const rationalB = new Rational(num2, denom2);
102
- const answerTree = rationalA
103
- .add(rationalB)
104
- .toTree({ allowFractionToDecimal: true });
105
- const texs = answerTree.toAllValidTexs();
106
- if (opts?.allowNonIrreductible) {
107
- try {
108
- const parsed = rationalParser(ans);
109
- if (!parsed)
110
- return false;
111
- return texs.includes(parsed.simplify().toTex());
112
- }
113
- catch (err) {
114
- return handleVEAError(err);
115
- }
116
- }
117
- else
118
- return texs.includes(ans);
98
+ const isAnswerValid = (ans, { answer }, opts) => {
99
+ const allowNonIrr = opts?.allowNonIrreductible ?? false;
100
+ return rationalVEA(ans, answer, {
101
+ allowNonIrreductible: allowNonIrr,
102
+ allowDecimalApprox: false,
103
+ });
119
104
  };
120
105
  const options = [
121
106
  {
@@ -1 +1 @@
1
- {"version":3,"file":"fractionsSumsPrimeDenominators.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAyLF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAkBhE,CAAC"}
1
+ {"version":3,"file":"fractionsSumsPrimeDenominators.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAwKF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAkBhE,CAAC"}
@@ -1,13 +1,12 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionTarget, GeneratorOptionType, propWhile, } 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, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
5
  import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
5
6
  import { randint } from "../../../../math/utils/random/randint.js";
6
7
  import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
8
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
9
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
- import { rationalParser } from "../../../../tree/parsers/rationalParser.js";
10
- import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
10
  const getInstruction = (identifiers, opts) => {
12
11
  const { num1, num2, denom1, denom2 } = identifiers;
13
12
  const ratio1 = new Rational(num1, denom1);
@@ -120,26 +119,12 @@ const getPropositions = (n, { answer, num1, denom1, denom2, num2 }) => {
120
119
  });
121
120
  return shuffleProps(propositions, n);
122
121
  };
123
- const isAnswerValid = (ans, { denom1, denom2, num1, num2 }, opts) => {
124
- const rationalA = new Rational(num1, denom1);
125
- const rationalB = new Rational(num2, denom2);
126
- const answerTree = rationalA
127
- .add(rationalB)
128
- .toTree({ allowFractionToDecimal: true });
129
- const texs = answerTree.toAllValidTexs();
130
- if (opts?.allowNonIrreductible) {
131
- try {
132
- const parsed = rationalParser(ans);
133
- if (!parsed)
134
- return false;
135
- return texs.includes(parsed.simplify().toTex());
136
- }
137
- catch (err) {
138
- return handleVEAError(err);
139
- }
140
- }
141
- else
142
- return texs.includes(ans);
122
+ const isAnswerValid = (ans, { answer }, opts) => {
123
+ const allowNonIrr = opts?.allowNonIrreductible ?? false;
124
+ return rationalVEA(ans, answer, {
125
+ allowNonIrreductible: allowNonIrr,
126
+ allowDecimalApprox: false,
127
+ });
143
128
  };
144
129
  const options = [
145
130
  {
@@ -4,6 +4,9 @@ type Identifiers = {
4
4
  num1: number;
5
5
  num2: number;
6
6
  };
7
- export declare const fractionsSumsSameDenominators: Exercise<Identifiers>;
7
+ type Options = {
8
+ allowNonIrreductible?: boolean;
9
+ };
10
+ export declare const fractionsSumsSameDenominators: Exercise<Identifiers, Options>;
8
11
  export {};
9
12
  //# sourceMappingURL=fractionsSumsSameDenominators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fractionsSumsSameDenominators.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumsSameDenominators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAgBrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAgKF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAkB/D,CAAC"}
1
+ {"version":3,"file":"fractionsSumsSameDenominators.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionsSumsSameDenominators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AA0IF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBxE,CAAC"}
@@ -1,14 +1,13 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, GeneratorOptionTarget, GeneratorOptionType, propWhile, } 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, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
5
  import { primeFactors } from "../../../../math/utils/arithmetic/primeFactors.js";
5
6
  import { randint } from "../../../../math/utils/random/randint.js";
6
7
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
8
  import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
8
9
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
9
- import { rationalParser } from "../../../../tree/parsers/rationalParser.js";
10
10
  import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
11
- import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
11
  import { alignTex } from "../../../../utils/latex/alignTex.js";
13
12
  const getInstruction = (identifiers, opts) => {
14
13
  const { denom, num1, num2 } = identifiers;
@@ -92,27 +91,12 @@ const getPropositions = (n, { answer, denom, num1, num2 }) => {
92
91
  });
93
92
  return shuffleProps(propositions, n);
94
93
  };
95
- const isAnswerValid = (ans, { denom, num1, num2 }, opts) => {
96
- const rationalA = new Rational(num1, denom);
97
- const rationalB = new Rational(num2, denom);
98
- const answerTree = rationalA
99
- .add(rationalB)
100
- .toTree({ allowFractionToDecimal: true });
101
- const texs = answerTree.toAllValidTexs();
102
- if (opts?.allowNonIrreductible) {
103
- try {
104
- const parsed = rationalParser(ans);
105
- if (!parsed)
106
- return false;
107
- return texs.includes(parsed.simplify().toTex());
108
- }
109
- catch (err) {
110
- return handleVEAError(err);
111
- }
112
- }
113
- else {
114
- return texs.includes(ans);
115
- }
94
+ const isAnswerValid = (ans, { answer }, opts) => {
95
+ const allowNonIrr = opts?.allowNonIrreductible ?? false;
96
+ return rationalVEA(ans, answer, {
97
+ allowNonIrreductible: allowNonIrr,
98
+ allowDecimalApprox: false,
99
+ });
116
100
  };
117
101
  const options = [
118
102
  {
@@ -1 +1 @@
1
- {"version":3,"file":"periodicWritingToFraction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/periodicWritingToFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAqGF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAa3D,CAAC"}
1
+ {"version":3,"file":"periodicWritingToFraction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/periodicWritingToFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAgGF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAa3D,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { addValidProp, 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 { Decimal, DecimalConstructor, } from "../../../../math/numbers/decimals/decimal.js";
4
5
  import { Rational } from "../../../../math/numbers/rationals/rational.js";
5
6
  import { randint } from "../../../../math/utils/random/randint.js";
@@ -76,13 +77,8 @@ const getPropositions = (n, { answer, num, denum, leadingPart }) => {
76
77
  }
77
78
  return shuffleProps(propositions, n);
78
79
  };
79
- const isAnswerValid = (ans, { denum, leadingPart, num }) => {
80
- const leadingPartDec = new Decimal(leadingPart);
81
- const answer = new Rational(num, denum * 10 ** leadingPartDec.precision)
82
- .add(leadingPartDec.toRational(true))
83
- .toTree();
84
- const texs = answer.toAllValidTexs();
85
- return texs.includes(ans);
80
+ const isAnswerValid = (ans, { answer }) => {
81
+ return rationalVEA(ans, answer);
86
82
  };
87
83
  export const periodicWritingToFraction = {
88
84
  id: "periodicWritingToFraction",
@@ -1 +1 @@
1
- {"version":3,"file":"simplifyFraction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/simplifyFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAsGF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
1
+ {"version":3,"file":"simplifyFraction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/simplifyFraction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAkGF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,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 { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
3
4
  import { Rational, RationalConstructor, } from "../../../../math/numbers/rationals/rational.js";
4
5
  import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
5
6
  import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
@@ -81,13 +82,11 @@ const getPropositions = (n, { answer }) => {
81
82
  });
82
83
  return shuffle(propositions);
83
84
  };
84
- const isAnswerValid = (ans, { num, denum }) => {
85
- const rational = new Rational(num, denum);
86
- const answerTree = rational
87
- .simplify()
88
- .toTree({ allowFractionToDecimal: true });
89
- const texs = answerTree.toAllValidTexs();
90
- return texs.includes(ans);
85
+ const isAnswerValid = (ans, { answer }) => {
86
+ return rationalVEA(ans, answer, {
87
+ allowNonIrreductible: false,
88
+ allowDecimal: false,
89
+ });
91
90
  };
92
91
  export const simplifyFraction = {
93
92
  id: "simplifyFrac",
@@ -1 +1 @@
1
- {"version":3,"file":"mentalDivisions.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalDivisions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuHF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,CAAC"}
1
+ {"version":3,"file":"mentalDivisions.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalDivisions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqHF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAYjD,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 { round } from "../../../../math/utils/round.js";
5
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
@@ -86,10 +87,8 @@ const getPropositions = (n, { answer }) => {
86
87
  });
87
88
  return shuffle(propositions);
88
89
  };
89
- const isAnswerValid = (studentAns, { answer }) => {
90
- const answerTree = new NumberNode(Number(answer.replace(",", ".")));
91
- const texs = answerTree.toAllValidTexs();
92
- return texs.includes(studentAns);
90
+ const isAnswerValid = (ans, { answer }) => {
91
+ return numberVEA(ans, answer);
93
92
  };
94
93
  export const mentalDivisions = {
95
94
  id: "mentalDivisions",
@@ -1 +1 @@
1
- {"version":3,"file":"mentalMultiplication101AndFriends.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalMultiplication101AndFriends.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAmRF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAuBF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqB1E,CAAC"}
1
+ {"version":3,"file":"mentalMultiplication101AndFriends.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalMultiplication101AndFriends.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAiRF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAuBF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqB1E,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
4
- import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
4
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
5
5
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
6
6
  import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
7
7
  import { random } from "../../../../utils/alea/random.js";
@@ -205,9 +205,7 @@ const getPropositions = (n, { answer, ...identifiers }) => {
205
205
  return shuffleProps(propositions, n);
206
206
  };
207
207
  const isAnswerValid = (studentAns, { answer }) => {
208
- const answerTree = new NumberNode(Number(answer.replace(",", ".")));
209
- const texs = answerTree.toAllValidTexs();
210
- return texs.includes(studentAns);
208
+ return numberVEA(studentAns, answer);
211
209
  };
212
210
  const getMentalMultiplication101AndFriendsQuestion = (optsIn) => {
213
211
  const arrayedOptions = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
@@ -1 +1 @@
1
- {"version":3,"file":"mentalMultiplication11AndFriends.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalMultiplication11AndFriends.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAmRF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAuBF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqBzE,CAAC"}
1
+ {"version":3,"file":"mentalMultiplication11AndFriends.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalMultiplication11AndFriends.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAiRF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAuBF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAqBzE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
4
- import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
4
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
5
5
  import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
6
6
  import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
7
7
  import { random } from "../../../../utils/alea/random.js";
@@ -205,9 +205,7 @@ const getPropositions = (n, { answer, ...identifiers }) => {
205
205
  return shuffleProps(propositions, n);
206
206
  };
207
207
  const isAnswerValid = (studentAns, { answer }) => {
208
- const answerTree = new NumberNode(Number(answer.replace(",", ".")));
209
- const texs = answerTree.toAllValidTexs();
210
- return texs.includes(studentAns);
208
+ return numberVEA(studentAns, answer);
211
209
  };
212
210
  const getMentalMultiplication11AndFriendsQuestion = (optsIn) => {
213
211
  const arrayedOptions = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
@@ -1 +1 @@
1
- {"version":3,"file":"mentalMultiplicationTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalMultiplicationTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAkIF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAgCF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBpE,CAAC"}
1
+ {"version":3,"file":"mentalMultiplicationTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalMultiplicationTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAgIF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAgCF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBpE,CAAC"}