math-exercises 2.2.4 → 2.2.6

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 (235) hide show
  1. package/lib/exercises/exercise.d.ts +1 -1
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/digitDecimalRank.js +4 -4
  4. package/lib/exercises/math/calcul/digitDecimalRankNumber.d.ts +8 -0
  5. package/lib/exercises/math/calcul/digitDecimalRankNumber.d.ts.map +1 -0
  6. package/lib/exercises/math/calcul/digitDecimalRankNumber.js +60 -0
  7. package/lib/exercises/math/calcul/digitRank.js +4 -4
  8. package/lib/exercises/math/calcul/digitRankNumber.d.ts +8 -0
  9. package/lib/exercises/math/calcul/digitRankNumber.d.ts.map +1 -0
  10. package/lib/exercises/math/calcul/digitRankNumber.js +56 -0
  11. package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.d.ts.map +1 -1
  12. package/lib/exercises/math/calcul/fractions/fractionAndIntegerDivision.js +34 -0
  13. package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.d.ts.map +1 -1
  14. package/lib/exercises/math/calcul/fractions/fractionAndIntegerProduct.js +17 -0
  15. package/lib/exercises/math/calcul/fractions/fractionsDivision.d.ts.map +1 -1
  16. package/lib/exercises/math/calcul/fractions/fractionsDivision.js +23 -0
  17. package/lib/exercises/math/calcul/fractions/fractionsProduct.d.ts.map +1 -1
  18. package/lib/exercises/math/calcul/fractions/fractionsProduct.js +15 -0
  19. package/lib/exercises/math/calcul/index.d.ts +2 -0
  20. package/lib/exercises/math/calcul/index.d.ts.map +1 -1
  21. package/lib/exercises/math/calcul/index.js +2 -0
  22. package/lib/exercises/math/calcul/proportionality/scaleUsage.js +1 -1
  23. package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
  24. package/lib/exercises/math/calcul/rounding/rounding.js +18 -0
  25. package/lib/exercises/math/calculLitteral/distributivity/allIdentities.d.ts.map +1 -1
  26. package/lib/exercises/math/calculLitteral/distributivity/allIdentities.js +1 -0
  27. package/lib/exercises/math/calculLitteral/distributivity/canonicalFormDevelopment.d.ts.map +1 -1
  28. package/lib/exercises/math/calculLitteral/distributivity/canonicalFormDevelopment.js +1 -0
  29. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivity.d.ts.map +1 -1
  30. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivity.js +31 -1
  31. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.d.ts.map +1 -1
  32. package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivityWithCoeff.js +11 -2
  33. package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.d.ts.map +1 -1
  34. package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.js +21 -2
  35. package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.d.ts.map +1 -1
  36. package/lib/exercises/math/calculLitteral/distributivity/secondIdentity.js +23 -2
  37. package/lib/exercises/math/calculLitteral/distributivity/simpleDistributivity.d.ts.map +1 -1
  38. package/lib/exercises/math/calculLitteral/distributivity/simpleDistributivity.js +17 -2
  39. package/lib/exercises/math/calculLitteral/distributivity/thirdIdentity.d.ts.map +1 -1
  40. package/lib/exercises/math/calculLitteral/distributivity/thirdIdentity.js +21 -2
  41. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
  42. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +26 -1
  43. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
  44. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.js +18 -2
  45. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
  46. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +19 -2
  47. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
  48. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.js +15 -2
  49. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
  50. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +20 -5
  51. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.d.ts.map +1 -1
  52. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.js +24 -1
  53. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.d.ts.map +1 -1
  54. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +20 -1
  55. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.d.ts.map +1 -1
  56. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.js +19 -3
  57. package/lib/exercises/math/calculLitteral/equation/fractionEquation.d.ts.map +1 -1
  58. package/lib/exercises/math/calculLitteral/equation/fractionEquation.js +24 -8
  59. package/lib/exercises/math/calculLitteral/equation/multiplicationEquation.d.ts.map +1 -1
  60. package/lib/exercises/math/calculLitteral/equation/multiplicationEquation.js +21 -2
  61. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -1
  62. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.js +24 -4
  63. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -1
  64. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.js +25 -5
  65. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
  66. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.js +19 -0
  67. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  68. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +1 -0
  69. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalForm.d.ts +8 -0
  70. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalForm.d.ts.map +1 -0
  71. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalForm.js +77 -0
  72. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.d.ts +8 -0
  73. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.d.ts.map +1 -0
  74. package/lib/exercises/math/calculLitteral/factorisation/factorizeCanonicalFormWithSqrt.js +80 -0
  75. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +2 -0
  76. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
  77. package/lib/exercises/math/calculLitteral/factorisation/index.js +2 -0
  78. package/lib/exercises/math/equaDiff/equaDiffGeneralForme.d.ts.map +1 -1
  79. package/lib/exercises/math/equaDiff/equaDiffGeneralForme.js +1 -0
  80. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts +2 -0
  81. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts.map +1 -1
  82. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.js +46 -66
  83. package/lib/exercises/math/functions/logarithm/log10PowerSimplifying.d.ts.map +1 -1
  84. package/lib/exercises/math/functions/logarithm/log10PowerSimplifying.js +12 -2
  85. package/lib/exercises/math/functions/trinoms/index.d.ts +2 -0
  86. package/lib/exercises/math/functions/trinoms/index.d.ts.map +1 -1
  87. package/lib/exercises/math/functions/trinoms/index.js +2 -0
  88. package/lib/exercises/math/functions/trinoms/solveEquationByFactorisation.d.ts +5 -0
  89. package/lib/exercises/math/functions/trinoms/solveEquationByFactorisation.d.ts.map +1 -0
  90. package/lib/exercises/math/functions/trinoms/solveEquationByFactorisation.js +44 -0
  91. package/lib/exercises/math/functions/trinoms/solveSecondDegreeEquationByFactorisation.d.ts +9 -0
  92. package/lib/exercises/math/functions/trinoms/solveSecondDegreeEquationByFactorisation.d.ts.map +1 -0
  93. package/lib/exercises/math/functions/trinoms/solveSecondDegreeEquationByFactorisation.js +134 -0
  94. package/lib/exercises/math/functions/trinoms/solveSecondDegreeEquationFromCano.d.ts +7 -0
  95. package/lib/exercises/math/functions/trinoms/solveSecondDegreeEquationFromCano.d.ts.map +1 -0
  96. package/lib/exercises/math/functions/trinoms/solveSecondDegreeEquationFromCano.js +59 -0
  97. package/lib/exercises/math/geometry/vectors/scalarProductViaCoords.d.ts.map +1 -1
  98. package/lib/exercises/math/geometry/vectors/scalarProductViaCoords.js +1 -0
  99. package/lib/exercises/math/index.d.ts +1 -0
  100. package/lib/exercises/math/index.d.ts.map +1 -1
  101. package/lib/exercises/math/index.js +1 -0
  102. package/lib/exercises/math/percent/applyPercent.d.ts.map +1 -1
  103. package/lib/exercises/math/percent/applyPercent.js +20 -2
  104. package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
  105. package/lib/exercises/math/probaStat/probaFromTableNoContext.js +5 -4
  106. package/lib/exercises/math/sequences/arithmetic/arithmeticFindRandomTermFromTwoTerms.d.ts +11 -0
  107. package/lib/exercises/math/sequences/arithmetic/arithmeticFindRandomTermFromTwoTerms.d.ts.map +1 -0
  108. package/lib/exercises/math/sequences/arithmetic/arithmeticFindRandomTermFromTwoTerms.js +49 -0
  109. package/lib/exercises/math/sequences/arithmetic/index.d.ts +1 -0
  110. package/lib/exercises/math/sequences/arithmetic/index.d.ts.map +1 -1
  111. package/lib/exercises/math/sequences/arithmetic/index.js +1 -0
  112. package/lib/exercises/math/spaceGeometry/index.d.ts +2 -0
  113. package/lib/exercises/math/spaceGeometry/index.d.ts.map +1 -0
  114. package/lib/exercises/math/spaceGeometry/index.js +17 -0
  115. package/lib/exercises/math/spaceGeometry/vectors/index.d.ts +4 -0
  116. package/lib/exercises/math/spaceGeometry/vectors/index.d.ts.map +1 -0
  117. package/lib/exercises/math/spaceGeometry/vectors/index.js +19 -0
  118. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.d.ts +5 -0
  119. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.d.ts.map +1 -0
  120. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorCoordinatesFromPoints.js +52 -0
  121. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.d.ts +5 -0
  122. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.d.ts.map +1 -0
  123. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorLinearCombinationCoords.js +62 -0
  124. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts +9 -0
  125. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.d.ts.map +1 -0
  126. package/lib/exercises/math/spaceGeometry/vectors/spaceVectorNormCalculation.js +54 -0
  127. package/lib/exercises/math/squareRoots/squareRootIdentities.js +3 -3
  128. package/lib/exercises/math/suites/sequencePlot.d.ts.map +1 -1
  129. package/lib/exercises/math/suites/sequencePlot.js +1 -2
  130. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts.map +1 -1
  131. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.js +1 -0
  132. package/lib/exercises/pc/calibrationCurveOfSolution.d.ts.map +1 -1
  133. package/lib/exercises/pc/calibrationCurveOfSolution.js +1 -0
  134. package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.d.ts.map +1 -1
  135. package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.js +1 -0
  136. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.d.ts.map +1 -1
  137. package/lib/exercises/pc/chemicalElements/massOrVolumeProportion.js +1 -0
  138. package/lib/exercises/pc/chemicalReactions/calculateSynthesisEfficiency.d.ts.map +1 -1
  139. package/lib/exercises/pc/chemicalReactions/calculateSynthesisEfficiency.js +1 -0
  140. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.d.ts.map +1 -1
  141. package/lib/exercises/pc/chemicalReactions/titrationEquivalenceRelation.js +1 -0
  142. package/lib/exercises/pc/dosage/beerLambertRandomValue.d.ts.map +1 -1
  143. package/lib/exercises/pc/dosage/beerLambertRandomValue.js +1 -0
  144. package/lib/exercises/pc/dosage/concentrationCalculation.d.ts.map +1 -1
  145. package/lib/exercises/pc/dosage/concentrationCalculation.js +1 -0
  146. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.d.ts.map +1 -1
  147. package/lib/exercises/pc/dosage/concentrationFromMassCalculation.js +1 -0
  148. package/lib/exercises/pc/electricity/calculateIntensity.js +1 -1
  149. package/lib/exercises/pc/electricity/calculateVoltage.d.ts.map +1 -1
  150. package/lib/exercises/pc/electricity/calculateVoltage.js +1 -0
  151. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.d.ts.map +1 -1
  152. package/lib/exercises/pc/electricity/electricPowerOrEnergyCalculation.js +1 -0
  153. package/lib/exercises/pc/electricity/ohmLaw.d.ts.map +1 -1
  154. package/lib/exercises/pc/electricity/ohmLaw.js +1 -0
  155. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.d.ts.map +1 -1
  156. package/lib/exercises/pc/electricity/ohmicConductorOrGenerator.js +1 -0
  157. package/lib/exercises/pc/energy/calorificValue.d.ts.map +1 -1
  158. package/lib/exercises/pc/energy/calorificValue.js +1 -0
  159. package/lib/exercises/pc/energy/combustionTransferEnergy.d.ts.map +1 -1
  160. package/lib/exercises/pc/energy/combustionTransferEnergy.js +1 -0
  161. package/lib/exercises/pc/energy/combustionTransferEnergy2.d.ts.map +1 -1
  162. package/lib/exercises/pc/energy/combustionTransferEnergy2.js +1 -0
  163. package/lib/exercises/pc/energy/efficencyOfConverter.d.ts.map +1 -1
  164. package/lib/exercises/pc/energy/efficencyOfConverter.js +1 -0
  165. package/lib/exercises/pc/energy/efficiencyCalculation.d.ts.map +1 -1
  166. package/lib/exercises/pc/energy/efficiencyCalculation.js +1 -0
  167. package/lib/exercises/pc/energy/kineticEnergyOrMassOrSpeed.d.ts.map +1 -1
  168. package/lib/exercises/pc/energy/kineticEnergyOrMassOrSpeed.js +1 -0
  169. package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.d.ts.map +1 -1
  170. package/lib/exercises/pc/energy/thermalEnergyTransferCalculation.js +1 -0
  171. package/lib/exercises/pc/forces/calculateNormalOrFrictionForce.d.ts.map +1 -1
  172. package/lib/exercises/pc/forces/calculateNormalOrFrictionForce.js +1 -0
  173. package/lib/exercises/pc/forces/electroStaticForce.d.ts.map +1 -1
  174. package/lib/exercises/pc/forces/electroStaticForce.js +1 -0
  175. package/lib/exercises/pc/forces/gravitationalAttractionObjectHeight.d.ts.map +1 -1
  176. package/lib/exercises/pc/forces/gravitationalAttractionObjectHeight.js +1 -0
  177. package/lib/exercises/pc/forces/gravitationalForcePlanets.d.ts.map +1 -1
  178. package/lib/exercises/pc/forces/gravitationalForcePlanets.js +1 -0
  179. package/lib/exercises/pc/forces/massWeight.d.ts.map +1 -1
  180. package/lib/exercises/pc/forces/massWeight.js +1 -0
  181. package/lib/exercises/pc/motion/averageSpeed.d.ts.map +1 -1
  182. package/lib/exercises/pc/motion/averageSpeed.js +1 -0
  183. package/lib/exercises/pc/motion/averageSpeedCalculation.d.ts.map +1 -1
  184. package/lib/exercises/pc/motion/averageSpeedCalculation.js +1 -0
  185. package/lib/exercises/pc/motion/motionReference.d.ts.map +1 -1
  186. package/lib/exercises/pc/motion/motionReference.js +1 -0
  187. package/lib/exercises/pc/pH.d.ts.map +1 -1
  188. package/lib/exercises/pc/pH.js +1 -0
  189. package/lib/exercises/pc/power/calculatePowerOfLight.d.ts.map +1 -1
  190. package/lib/exercises/pc/power/calculatePowerOfLight.js +1 -0
  191. package/lib/exercises/pc/spectral/spectralEnergy.d.ts.map +1 -1
  192. package/lib/exercises/pc/spectral/spectralEnergy.js +1 -0
  193. package/lib/exercises/pc/waves/lightDistanceConversion.d.ts.map +1 -1
  194. package/lib/exercises/pc/waves/lightDistanceConversion.js +1 -0
  195. package/lib/exercises/pc/waves/periodicWaveCelerity.d.ts.map +1 -1
  196. package/lib/exercises/pc/waves/periodicWaveCelerity.js +1 -0
  197. package/lib/exercises/pc/weight/calculateWeight.d.ts.map +1 -1
  198. package/lib/exercises/pc/weight/calculateWeight.js +1 -0
  199. package/lib/exercises/pc/weight/weightOnTheMoon.d.ts.map +1 -1
  200. package/lib/exercises/pc/weight/weightOnTheMoon.js +1 -0
  201. package/lib/index.d.ts +33 -64
  202. package/lib/index.d.ts.map +1 -1
  203. package/lib/index.js +4 -0
  204. package/lib/math/geometry/spacePoint.d.ts +27 -0
  205. package/lib/math/geometry/spacePoint.d.ts.map +1 -0
  206. package/lib/math/geometry/spacePoint.js +80 -0
  207. package/lib/math/geometry/spaceVector.d.ts +28 -0
  208. package/lib/math/geometry/spaceVector.d.ts.map +1 -0
  209. package/lib/math/geometry/spaceVector.js +83 -0
  210. package/lib/math/numbers/decimals/decimal.d.ts +1 -0
  211. package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
  212. package/lib/math/numbers/decimals/decimal.js +8 -0
  213. package/lib/math/numbers/rationals/rational.d.ts +1 -0
  214. package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
  215. package/lib/math/numbers/rationals/rational.js +4 -0
  216. package/lib/math/utils/random/randTupleInt.d.ts +1 -0
  217. package/lib/math/utils/random/randTupleInt.d.ts.map +1 -1
  218. package/lib/math/utils/random/randTupleInt.js +5 -1
  219. package/lib/playground.d.ts +2 -0
  220. package/lib/playground.d.ts.map +1 -0
  221. package/lib/playground.js +20 -0
  222. package/lib/server.d.ts +3 -0
  223. package/lib/server.d.ts.map +1 -1
  224. package/lib/server.js +7 -0
  225. package/lib/tree/nodes/equations/equationSolutionNode.d.ts.map +1 -1
  226. package/lib/tree/nodes/equations/equationSolutionNode.js +8 -0
  227. package/lib/tree/nodes/node.d.ts +1 -0
  228. package/lib/tree/nodes/node.d.ts.map +1 -1
  229. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  230. package/lib/tree/nodes/operators/multiplyNode.js +8 -2
  231. package/lib/tree/nodes/operators/powerNode.js +1 -1
  232. package/lib/utils/alignTex.d.ts +2 -0
  233. package/lib/utils/alignTex.d.ts.map +1 -0
  234. package/lib/utils/alignTex.js +18 -0
  235. package/package.json +1 -1
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpaceVector = exports.SpaceVectorConstructor = void 0;
4
+ const sqrtNode_1 = require("../../tree/nodes/functions/sqrtNode");
5
+ const addNode_1 = require("../../tree/nodes/operators/addNode");
6
+ const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
7
+ const powerNode_1 = require("../../tree/nodes/operators/powerNode");
8
+ const substractNode_1 = require("../../tree/nodes/operators/substractNode");
9
+ const randint_1 = require("../utils/random/randint");
10
+ const spacePoint_1 = require("./spacePoint");
11
+ class SpaceVectorConstructor {
12
+ static fromPoints(origin, end) {
13
+ return new SpaceVector(`${origin.name}${end.name}`, new substractNode_1.SubstractNode(end.x, origin.x).simplify(), new substractNode_1.SubstractNode(end.y, origin.y).simplify(), new substractNode_1.SubstractNode(end.z, origin.z).simplify());
14
+ }
15
+ static random(name, allowNull = true) {
16
+ let x;
17
+ let y;
18
+ let z;
19
+ do {
20
+ x = (0, randint_1.randint)(-10, 11);
21
+ y = (0, randint_1.randint)(-10, 11);
22
+ z = (0, randint_1.randint)(-10, 11);
23
+ } while (!allowNull && x === 0 && y === 0 && z === 0);
24
+ return new SpaceVector(name, x.toTree(), y.toTree(), z.toTree());
25
+ }
26
+ static randomDifferents(names, allowNull = true) {
27
+ const res = [];
28
+ for (let i = 0; i < names.length; i++) {
29
+ let vec;
30
+ do {
31
+ vec = SpaceVectorConstructor.random(names[i], allowNull);
32
+ } while (res.some((v) => v.equals(vec)));
33
+ res.push(vec);
34
+ }
35
+ return res;
36
+ }
37
+ }
38
+ exports.SpaceVectorConstructor = SpaceVectorConstructor;
39
+ class SpaceVector {
40
+ constructor(name, x, y, z) {
41
+ this.name = name;
42
+ this.tex = `\\overrightarrow{${name}}`;
43
+ this.x = x;
44
+ this.y = y;
45
+ this.z = z;
46
+ }
47
+ toTex() {
48
+ return `\\overrightarrow{${this.name}}`;
49
+ }
50
+ toInlineCoordsTex() {
51
+ return `\\left(${this.x.simplify().toTex()};${this.y
52
+ .simplify()
53
+ .toTex()};${this.z.simplify().toTex()}\\right)`;
54
+ }
55
+ toTexWithCoords() {
56
+ return `\\overrightarrow{${this.name}}\\begin{pmatrix}${this.x.toTex()} \\\\ ${this.y.toTex()} \\\\ ${this.z.toTex()} \\end{pmatrix}`;
57
+ }
58
+ isColinear(v) {
59
+ throw Error("unimplemented");
60
+ }
61
+ determinant(v) {
62
+ throw Error("unimplemented");
63
+ }
64
+ times(k, name) {
65
+ return new SpaceVector(name ?? "v", new multiplyNode_1.MultiplyNode(this.x, k).simplify(), new multiplyNode_1.MultiplyNode(this.y, k).simplify(), new multiplyNode_1.MultiplyNode(this.z, k).simplify());
66
+ }
67
+ scalarProduct(v) {
68
+ throw Error("unimplemented");
69
+ }
70
+ add(v) {
71
+ return new SpaceVector(`${this.name}+${v.name}`, new addNode_1.AddNode(this.x, v.x).simplify(), new addNode_1.AddNode(this.y, v.y).simplify(), new addNode_1.AddNode(this.z, v.z).simplify());
72
+ }
73
+ getNorm() {
74
+ return new sqrtNode_1.SqrtNode(new addNode_1.AddNode(new powerNode_1.SquareNode(this.x), new addNode_1.AddNode(new powerNode_1.SquareNode(this.y), new powerNode_1.SquareNode(this.z)))).simplify();
75
+ }
76
+ getEndPoint(startPoint, name) {
77
+ return new spacePoint_1.SpacePoint(name ?? "B", new addNode_1.AddNode(startPoint.x, this.x).simplify(), new addNode_1.AddNode(startPoint.y, this.y).simplify(), new addNode_1.AddNode(startPoint.z, this.z).simplify());
78
+ }
79
+ equals(v) {
80
+ return this.x.equals(v.x) && this.y.equals(v.y) && this.z.equals(v.z);
81
+ }
82
+ }
83
+ exports.SpaceVector = SpaceVector;
@@ -28,6 +28,7 @@ export declare class Decimal implements Nombre {
28
28
  multiplyByPowerOfTen(power: number): Decimal;
29
29
  toScientificPart(): number;
30
30
  toScientificNotation(decimals?: number): NumberNode | MultiplyNode;
31
+ getDigitAtRank(rank: number): number;
31
32
  toRational(): Rational | import("../integer/integer").Integer;
32
33
  toTree(): NumberNode;
33
34
  toPercentNode(): PercentNode;
@@ -1 +1 @@
1
- {"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAAyC,CAAC;AACxE,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAY1E,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAK/D,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;CAMrD;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,aAAsB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;gBACR,KAAK,EAAE,MAAM,GAAG,MAAM;IASlC,MAAM,CAAC,CAAC,EAAE,MAAM;IAIhB;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIhC,oBAAoB,CAAC,KAAK,EAAE,MAA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C,oBAAoB,CAAC,KAAK,EAAE,MAAM;IAkClC,gBAAgB;IA6BhB,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM;IAwCtC,cAAc,CAAC,IAAI,EAAE,MAAM;IAS3B,UAAU;IAMV,MAAM;IAIN,aAAa;CAGd"}
@@ -154,6 +154,14 @@ class Decimal {
154
154
  return new multiplyNode_1.MultiplyNode(decNode, new numberNode_1.NumberNode(10));
155
155
  return new multiplyNode_1.MultiplyNode(decNode, new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(power)));
156
156
  }
157
+ getDigitAtRank(rank) {
158
+ if (rank >= 0) {
159
+ return Number(this.intPart.toString()[this.intPart.toString().length - 1 - rank]);
160
+ }
161
+ else {
162
+ return Number(this.decimalPart[-rank - 1]);
163
+ }
164
+ }
157
165
  toRational() {
158
166
  return new rational_1.Rational(this.multiplyByPowerOfTen(this.precision).value, 10 ** this.precision).simplify();
159
167
  }
@@ -23,6 +23,7 @@ export declare class Rational implements Nombre {
23
23
  toTex(): string;
24
24
  add(nb: Nombre): Nombre;
25
25
  multiply(nb: Nombre): Rational | Integer;
26
+ reverse(shouldSimplify: boolean): Nombre;
26
27
  divide(nb: Nombre): Nombre;
27
28
  opposite(): Rational;
28
29
  toTree(opts?: NodeOptions): FractionNode | OppositeNode;
@@ -1 +1 @@
1
- {"version":3,"file":"rational.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/rationals/rational.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAQ,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAIvE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/C,8BAAsB,mBAAmB;IACvC;;OAEG;IACH,MAAM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AAE,MAAW;IAO1C,MAAM,CAAC,0BAA0B,CAAC,GAAG,GAAE,MAAW;CAQnD;AAED,qBAAa,QAAS,YAAW,MAAM;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;gBAEL,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAYlD,MAAM,CAAC,CAAC,EAAE,MAAM;IAGhB,KAAK;IAML,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAkBvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO;IAgBxC,OAAO,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM;IAIxC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB1B,QAAQ,IAAI,QAAQ;IAIpB,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW;IAgBzB,cAAc;IAId,QAAQ,IAAI,OAAO,GAAG,QAAQ;CAS/B"}
@@ -96,6 +96,10 @@ class Rational {
96
96
  }
97
97
  throw Error("not implemented yet");
98
98
  }
99
+ reverse(shouldSimplify) {
100
+ const frac = new Rational(this.denum, this.num);
101
+ return shouldSimplify ? frac.simplify() : frac;
102
+ }
99
103
  divide(nb) {
100
104
  switch (nb.type) {
101
105
  case nombre_1.NumberType.Integer: {
@@ -2,6 +2,7 @@ interface randTupleIntOptions {
2
2
  from: number;
3
3
  to?: number;
4
4
  excludes?: number[];
5
+ allDifferent?: boolean;
5
6
  }
6
7
  /**
7
8
  * @param size tuple length
@@ -1 +1 @@
1
- {"version":3,"file":"randTupleInt.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/random/randTupleInt.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,WAAW,mBAAmB,KAAG,MAAM,EAM/E,CAAC;AAEF,eAAO,MAAM,oBAAoB,OAAQ,MAAM,QAAQ,MAAM,WAAW,mBAAmB,KAAG,MAAM,EAAE,EAUrG,CAAC"}
1
+ {"version":3,"file":"randTupleInt.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/random/randTupleInt.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,SACjB,MAAM,WACH,mBAAmB,KAC3B,MAAM,EAUR,CAAC;AAEF,eAAO,MAAM,oBAAoB,OAC3B,MAAM,QACJ,MAAM,WACH,mBAAmB,KAC3B,MAAM,EAAE,EAUV,CAAC"}
@@ -11,7 +11,11 @@ const randint_1 = require("./randint");
11
11
  const randTupleInt = (size, options) => {
12
12
  const res = [];
13
13
  for (let i = 0; i < size; i++) {
14
- res.push((0, randint_1.randint)(options.from, options.to, options.excludes));
14
+ let x;
15
+ do {
16
+ x = (0, randint_1.randint)(options.from, options.to, options.excludes);
17
+ } while (options.allDifferent && res.includes(x));
18
+ res.push(x);
15
19
  }
16
20
  return res;
17
21
  };
@@ -0,0 +1,2 @@
1
+ export declare const playground: () => void;
2
+ //# sourceMappingURL=playground.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,YAgBtB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.playground = void 0;
4
+ const affine_1 = require("./math/polynomials/affine");
5
+ const randTupleInt_1 = require("./math/utils/random/randTupleInt");
6
+ const addNode_1 = require("./tree/nodes/operators/addNode");
7
+ const multiplyNode_1 = require("./tree/nodes/operators/multiplyNode");
8
+ const random_1 = require("./utils/random");
9
+ const shuffle_1 = require("./utils/shuffle");
10
+ const playground = () => {
11
+ const affines = affine_1.AffineConstructor.differentRandoms(3);
12
+ const permut = [
13
+ (0, shuffle_1.shuffle)([affines[0], affines[1]]),
14
+ (0, shuffle_1.shuffle)([affines[0], affines[2]]),
15
+ ];
16
+ const operation = (0, random_1.random)(["add", "substract"]);
17
+ const statementTree = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(permut[0][0].toTree(), permut[0][1].toTree()), new multiplyNode_1.MultiplyNode(permut[1][0].toTree(), permut[1][1].toTree()));
18
+ console.log((0, randTupleInt_1.distinctRandTupleInt)(3, 2, { from: 1, to: 10 }));
19
+ };
20
+ exports.playground = playground;
package/lib/server.d.ts CHANGED
@@ -5,5 +5,8 @@ declare global {
5
5
  frenchify: () => string;
6
6
  toScientific: (decimals?: number) => AlgebraicNode;
7
7
  }
8
+ interface String {
9
+ toTree: () => AlgebraicNode;
10
+ }
8
11
  }
9
12
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAkC3D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,aAAa,CAAC;QAC5B,SAAS,EAAE,MAAM,MAAM,CAAC;QACxB,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;KACpD;CACF"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAuC3D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,aAAa,CAAC;QAC5B,SAAS,EAAE,MAAM,MAAM,CAAC;QACxB,YAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,aAAa,CAAC;KACpD;IACD,UAAU,MAAM;QACd,MAAM,EAAE,MAAM,aAAa,CAAC;KAC7B;CACF"}
package/lib/server.js CHANGED
@@ -36,10 +36,15 @@ const cors_1 = __importDefault(require("cors"));
36
36
  const numberNode_1 = require("./tree/nodes/numbers/numberNode");
37
37
  const infiniteNode_1 = require("./tree/nodes/numbers/infiniteNode");
38
38
  const toScientific_1 = require("./utils/numberPrototype/toScientific");
39
+ const variableNode_1 = require("./tree/nodes/variables/variableNode");
40
+ const playground_1 = require("./playground");
39
41
  const jsonParser = body_parser_1.default.json();
40
42
  const mathExercises = Object.values(MathExercises);
41
43
  const pcExercises = Object.values(PCExercises);
42
44
  const allExercises = [...mathExercises, ...pcExercises];
45
+ String.prototype.toTree = function () {
46
+ return new variableNode_1.VariableNode(this.valueOf());
47
+ };
43
48
  Number.prototype.toTree = function () {
44
49
  const value = this.valueOf();
45
50
  if (value === Infinity)
@@ -59,7 +64,9 @@ const runServer = () => {
59
64
  const app = (0, express_1.default)();
60
65
  app.use((0, cors_1.default)());
61
66
  console.log("math exos", mathExercises.length);
67
+ console.log("math hints", mathExercises.filter((exo) => exo.hasHintAndCorrection).length);
62
68
  console.log("pc exos", pcExercises.length);
69
+ (0, playground_1.playground)();
63
70
  app.get("/", (req, res) => {
64
71
  res.json(allExercises);
65
72
  });
@@ -1 +1 @@
1
- {"version":3,"file":"equationSolutionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/equations/equationSolutionNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,KAAK,2BAA2B,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAC7E,qBAAa,oBAAqB,YAAW,IAAI;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,eAAe,CAAC;IAC9B,IAAI,CAAC,EAAE,WAAW,CAAC;gBAEjB,YAAY,EAAE,eAAe,EAC7B,MAAM,CAAC,EAAE,2BAA2B;IActC,cAAc;IAId,SAAS;IAUT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAQpC,YAAY;IAGZ,QAAQ;IAGR,KAAK;CAGN"}
1
+ {"version":3,"file":"equationSolutionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/equations/equationSolutionNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,KAAK,2BAA2B,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAC7E,qBAAa,oBAAqB,YAAW,IAAI;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,eAAe,CAAC;IAC9B,IAAI,CAAC,EAAE,WAAW,CAAC;gBAEjB,YAAY,EAAE,eAAe,EAC7B,MAAM,CAAC,EAAE,2BAA2B;IActC,cAAc;IAId,SAAS;IAiBT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAQpC,YAAY;IAGZ,QAAQ;IAGR,KAAK;CAGN"}
@@ -25,6 +25,14 @@ class EquationSolutionNode {
25
25
  if (this.opts?.allowRawRightChildAsSolution)
26
26
  res.push(solTex);
27
27
  }
28
+ else {
29
+ const solTex = this.solutionsSet.elements.map((e) => e.toTex());
30
+ res.push(solTex.map((e) => `${this.variable}=${e}`).join("\\text{ ou }"));
31
+ if (this.opts?.allowRawRightChildAsSolution) {
32
+ res.push(solTex.join(";"));
33
+ res.push(solTex.join("\\text{ ou }"));
34
+ }
35
+ }
28
36
  return res;
29
37
  }
30
38
  toEquivalentNodes(opts) {
@@ -29,6 +29,7 @@ export type ToTexOptions = {
29
29
  scientific?: number;
30
30
  hideUnit?: boolean;
31
31
  notScientific?: boolean;
32
+ forceNoSimplification?: boolean;
32
33
  };
33
34
  export interface Node {
34
35
  type: NodeType;
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/tree/nodes/node.ts"],"names":[],"mappings":"AAIA,oBAAY,QAAQ;IAClB,MAAM,IAAA;IACN,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,QAAQ,IAAA;IACR,GAAG,IAAA;IACH,UAAU,IAAA;IACV,KAAK,IAAA;IACL,MAAM,IAAA;IACN,QAAQ,IAAA;IACR,OAAO,KAAA;IACP,MAAM,KAAA;CACP;AACD,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,UAAU,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E,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,OAAO,aAGL;IAEF,YAAY,IAAI,MAAM;IAItB,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM;IA4DlC,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAwFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAQ5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIrC,IAAI;IAGJ,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IA0H/C,MAAM,CAAC,IAAI,EAAE,aAAa;CAU3B"}
@@ -52,7 +52,8 @@ class MultiplyNode {
52
52
  toTex(opts) {
53
53
  let leftTex = this.leftChild.toTex(opts);
54
54
  let rightTex = this.rightChild.toTex(opts);
55
- if ((0, numberNode_1.isNumberNode)(this.leftChild) &&
55
+ if (!opts?.forceNoSimplification &&
56
+ (0, numberNode_1.isNumberNode)(this.leftChild) &&
56
57
  this.leftChild.value === 1 &&
57
58
  opts?.scientific === undefined) {
58
59
  return rightTex;
@@ -68,7 +69,7 @@ class MultiplyNode {
68
69
  }
69
70
  if (needBrackets)
70
71
  rightTex = `\\left(${rightTex}\\right)`;
71
- if (leftTex === "-1") {
72
+ if (leftTex === "-1" && !opts?.forceNoSimplification) {
72
73
  // if (!isNumberNode(this.rightChild)) {
73
74
  return "-" + rightTex;
74
75
  // }
@@ -271,6 +272,11 @@ class MultiplyNode {
271
272
  return new fractionNode_1.FractionNode(numNode, denumNode).simplify(opts);
272
273
  }
273
274
  const simplifyExternalNodes = (a, b) => {
275
+ if ((0, variableNode_1.isVariableNode)(a) && (0, variableNode_1.isVariableNode)(b)) {
276
+ if (a.name === b.name) {
277
+ return new powerNode_1.SquareNode(a);
278
+ }
279
+ }
274
280
  if ((0, numberNode_1.isNumberNode)(a) && (0, numberNode_1.isNumberNode)(b)) {
275
281
  return new numberNode_1.NumberNode((0, round_1.round)(a.value * b.value, 12));
276
282
  }
@@ -171,7 +171,7 @@ class PowerNode {
171
171
  return new PowerNode(leftSimplified.leftChild, new multiplyNode_1.MultiplyNode(rightSimplified, leftSimplified.rightChild).simplify(opts)).simplify(opts);
172
172
  }
173
173
  if ((0, multiplyNode_1.isMultiplyNode)(leftSimplified)) {
174
- return new multiplyNode_1.MultiplyNode(new PowerNode(leftSimplified.leftChild, rightSimplified), new PowerNode(leftSimplified.rightChild, rightSimplified));
174
+ return new multiplyNode_1.MultiplyNode(new PowerNode(leftSimplified.leftChild, rightSimplified), new PowerNode(leftSimplified.rightChild, rightSimplified)).simplify(opts);
175
175
  }
176
176
  if (!opts?.keepPowers &&
177
177
  (0, numberNode_1.isNumberNode)(copy.rightChild) &&
@@ -0,0 +1,2 @@
1
+ export declare function alignTex(arr: string[][] | string): string;
2
+ //# sourceMappingURL=alignTex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alignTex.d.ts","sourceRoot":"","sources":["../../src/utils/alignTex.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,UAehD"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alignTex = void 0;
4
+ function alignTex(arr) {
5
+ //! le "&" avant les join sert à aligner à gauche
6
+ //! mais ca crée un manque d'espace moche
7
+ //! je pense qu'il faut changer d'environnement (align)
8
+ //! utiliser un autre genre array ou equation je sais pas
9
+ const aligned = `$$
10
+ \\begin{align*}
11
+ ${typeof arr === "string"
12
+ ? arr
13
+ : arr.map((el) => "&" + el.join("&")).join(` \\\\`)}
14
+ \\end{align*}
15
+ $$`;
16
+ return aligned;
17
+ }
18
+ exports.alignTex = alignTex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.2.4",
3
+ "version": "2.2.6",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [