math-exercises 2.2.41 → 2.2.42

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 (39) hide show
  1. package/lib/exercises/exercise.d.ts +42 -36
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts +4 -1
  4. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/fractionsSum.js +23 -4
  6. package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
  7. package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.d.ts.map +1 -1
  8. package/lib/exercises/math/calculLitteral/distributivity/firstIdentity.js +3 -0
  9. package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
  10. package/lib/exercises/math/functions/logarithm/logPowerEquation.d.ts.map +1 -1
  11. package/lib/exercises/math/percent/evolutionRateFromValues.d.ts.map +1 -1
  12. package/lib/exercises/math/percent/evolutionRateFromValues.js +2 -2
  13. package/lib/exercises/math/percent/evolutionToCM.d.ts.map +1 -1
  14. package/lib/exercises/math/percent/evolutionToCM.js +3 -1
  15. package/lib/exercises/math/powers/powersDivision.d.ts.map +1 -1
  16. package/lib/exercises/math/powers/powersPower.d.ts.map +1 -1
  17. package/lib/exercises/math/powers/powersProduct.d.ts.map +1 -1
  18. package/lib/exercises/math/sequences/arithmetic/arithmeticReasonUsage.d.ts.map +1 -1
  19. package/lib/exercises/math/sequences/arithmetic/arithmeticReasonUsage.js +1 -0
  20. package/lib/exercises/math/trigonometry/mainAngleMeasure.d.ts.map +1 -1
  21. package/lib/exercises/math/trigonometry/mainAngleMeasure.js +0 -3
  22. package/lib/exercises/utils/getDistinctQuestions.d.ts +1 -1
  23. package/lib/exercises/utils/getDistinctQuestions.d.ts.map +1 -1
  24. package/lib/index.d.ts +512 -510
  25. package/lib/index.d.ts.map +1 -1
  26. package/lib/math/sets/intervals/intervals.js +1 -1
  27. package/lib/math/systems/system.d.ts.map +1 -1
  28. package/lib/math/systems/system.js +29 -7
  29. package/lib/playground.d.ts.map +1 -1
  30. package/lib/playground.js +7 -1
  31. package/lib/server.js +9 -2
  32. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  33. package/lib/tree/nodes/operators/addNode.js +41 -0
  34. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  35. package/lib/tree/nodes/operators/fractionNode.js +2 -2
  36. package/lib/tree/parsers/rationalParser.d.ts +1 -0
  37. package/lib/tree/parsers/rationalParser.d.ts.map +1 -0
  38. package/lib/tree/parsers/rationalParser.js +9 -0
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC"}
@@ -98,7 +98,7 @@ class Interval {
98
98
  : interval.rightBracket;
99
99
  let unionLeftBracket = this.min < interval.min
100
100
  ? this.leftBracket
101
- : this.max === interval.max
101
+ : this.min === interval.min
102
102
  ? this.leftBracket === "[" || interval.leftBracket === "["
103
103
  ? "["
104
104
  : "]"
@@ -1 +1 @@
1
- {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../src/math/systems/system.ts"],"names":[],"mappings":"AASA,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM;IAeb,MAAM,CAAC,UAAU;CAiBlB;AACD,qBAAa,MAAM;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;gBAEP,MAAM,EAAE,MAAM,EAAE,EAAE;IAG9B,KAAK;;;;IAuCL,KAAK;CAcN"}
1
+ {"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../src/math/systems/system.ts"],"names":[],"mappings":"AASA,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM;IAeb,MAAM,CAAC,UAAU;CAiBlB;AACD,qBAAa,MAAM;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;gBAEP,MAAM,EAAE,MAAM,EAAE,EAAE;IAG9B,KAAK;;;;IA4CL,KAAK;CAcN"}
@@ -45,14 +45,36 @@ class System {
45
45
  solve() {
46
46
  if (this.coeffs.length !== 2)
47
47
  throw Error("General system resolution not implemented yet");
48
- //x = (c'-b'c/b)/(a'-b'a/b)
49
- if (!this.coeffs[0][1] ||
50
- this.coeffs[1][0] ===
51
- (this.coeffs[1][1] * this.coeffs[0][0]) / this.coeffs[0][1])
48
+ const [a, b, c] = this.coeffs[0];
49
+ const [d, e, f] = this.coeffs[1];
50
+ if (!b || d * b === e * a)
52
51
  throw Error("No solution");
53
- const x = new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(this.coeffs[1][2].toTree(), new fractionNode_1.FractionNode((this.coeffs[1][1] * this.coeffs[0][2]).toTree(), this.coeffs[0][1].toTree())), new substractNode_1.SubstractNode(this.coeffs[1][0].toTree(), new fractionNode_1.FractionNode((this.coeffs[1][1] * this.coeffs[0][0]).toTree(), this.coeffs[0][1].toTree()))).simplify();
54
- //y = c-ax/b
55
- const y = new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(this.coeffs[0][2].toTree(), new multiplyNode_1.MultiplyNode(this.coeffs[0][0].toTree(), x)), this.coeffs[0][1].toTree()).simplify();
52
+ const x = new fractionNode_1.FractionNode((b * f - e * c).toTree(), (d * b - e * a).toTree()).simplify();
53
+ const y = new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(c.toTree(), new multiplyNode_1.MultiplyNode(a.toTree(), x)), b.toTree()).simplify();
54
+ // const x = new FractionNode(
55
+ // new SubstractNode(
56
+ // this.coeffs[1][2].toTree(),
57
+ // new FractionNode(
58
+ // (this.coeffs[1][1] * this.coeffs[0][2]).toTree(),
59
+ // this.coeffs[0][1].toTree(),
60
+ // ).simplify(),
61
+ // ).simplify(),
62
+ // new SubstractNode(
63
+ // this.coeffs[1][0].toTree(),
64
+ // new FractionNode(
65
+ // (this.coeffs[1][1] * this.coeffs[0][0]).toTree(),
66
+ // this.coeffs[0][1].toTree(),
67
+ // ).simplify(),
68
+ // ).simplify(),
69
+ // ).simplify();
70
+ // //y = c-ax/b
71
+ // const y = new FractionNode(
72
+ // new SubstractNode(
73
+ // this.coeffs[0][2].toTree(),
74
+ // new MultiplyNode(this.coeffs[0][0].toTree(), x).simplify(),
75
+ // ).simplify(),
76
+ // this.coeffs[0][1].toTree(),
77
+ // ).simplify();
56
78
  return {
57
79
  x,
58
80
  y,
@@ -1 +1 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,UAAU,YAAW,CAAC"}
1
+ {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,UAAU,YAMtB,CAAC"}
package/lib/playground.js CHANGED
@@ -1,5 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.playground = void 0;
4
- const playground = () => { };
4
+ const playground = () => {
5
+ // const frac = new AddNode(
6
+ // (3).toTree(),
7
+ // new OppositeNode(new FractionNode((1).toTree(), (2).toTree())),
8
+ // ).simplify();
9
+ // console.log(frac.toTex());
10
+ };
5
11
  exports.playground = playground;
package/lib/server.js CHANGED
@@ -58,11 +58,14 @@ const runServer = () => {
58
58
  });
59
59
  app.get("/exo", (req, res) => {
60
60
  const exoId = req.query.exoId;
61
+ const options = req.query.options
62
+ ? JSON.parse(req.query.options)
63
+ : undefined;
61
64
  const exoIndex = allExercises.findIndex((exo) => exo.id == exoId);
62
65
  const exo = allExercises[exoIndex];
63
66
  if (!exo)
64
67
  res.send("Exo not found");
65
- const questions = exo?.generator(10);
68
+ const questions = exo?.generator(10, options);
66
69
  res.json({
67
70
  exercise: exo,
68
71
  questions,
@@ -97,6 +100,10 @@ const runServer = () => {
97
100
  });
98
101
  app.post("/vea", jsonParser, (req, res) => {
99
102
  const exoId = req.query.exoId;
103
+ const options = req.query.options
104
+ ? JSON.parse(req.query.options)
105
+ : undefined;
106
+ console.log("vea opts", options);
100
107
  const { ans, veaProps } = req.body;
101
108
  const exoIndex = allExercises.findIndex((exo) => exo.id == exoId);
102
109
  const exo = allExercises[exoIndex];
@@ -108,7 +115,7 @@ const runServer = () => {
108
115
  res.send("No VEA implemented");
109
116
  return;
110
117
  }
111
- const result = exo.isAnswerValid(ans, veaProps) ?? false;
118
+ const result = exo.isAnswerValid(ans, veaProps, options) ?? false;
112
119
  res.json({
113
120
  result,
114
121
  });
@@ -1 +1 @@
1
- {"version":3,"file":"addNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/addNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,WAAW,EAGZ,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQlE,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,OAAO,CAE/C;AAED,qBAAa,OAAQ,YAAW,uBAAuB;IACrD,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IASpB,OAAO,aAGL;IAEF,YAAY,IAAI,MAAM;IAItB,iBAAiB,CAAC,IA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Ac,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAK5C,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;IAerC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAgP/C,aAAa;;;;;;;;;IAOb,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAUrC"}
@@ -131,18 +131,59 @@ class AddNode {
131
131
  const f = b.rightChild;
132
132
  return new fractionNode_1.FractionNode(new AddNode(new multiplyNode_1.MultiplyNode(c, f), new multiplyNode_1.MultiplyNode(e, d)), new multiplyNode_1.MultiplyNode(d, f)).simplify(opts);
133
133
  }
134
+ if ((0, oppositeNode_1.isOppositeNode)(a) && (0, fractionNode_1.isFractionNode)(a.child) && (0, fractionNode_1.isFractionNode)(b)) {
135
+ //-(c/d) + e/f = -cf+ed / df
136
+ const c = a.child.leftChild;
137
+ const d = a.child.rightChild;
138
+ const e = b.leftChild;
139
+ const f = b.rightChild;
140
+ return new fractionNode_1.FractionNode(new AddNode(new multiplyNode_1.MultiplyNode(new oppositeNode_1.OppositeNode(c), f), new multiplyNode_1.MultiplyNode(e, d)), new multiplyNode_1.MultiplyNode(d, f)).simplify(opts);
141
+ }
142
+ if ((0, oppositeNode_1.isOppositeNode)(b) && (0, fractionNode_1.isFractionNode)(b.child) && (0, fractionNode_1.isFractionNode)(a)) {
143
+ //(c/d) + (-e/f) = cf-ed / df
144
+ const c = a.leftChild;
145
+ const d = a.rightChild;
146
+ const e = b.child.leftChild;
147
+ const f = b.child.rightChild;
148
+ return new fractionNode_1.FractionNode(new AddNode(new multiplyNode_1.MultiplyNode(c, f), new multiplyNode_1.MultiplyNode(new oppositeNode_1.OppositeNode(e), d)), new multiplyNode_1.MultiplyNode(d, f)).simplify(opts);
149
+ }
150
+ if ((0, oppositeNode_1.isOppositeNode)(b) &&
151
+ (0, fractionNode_1.isFractionNode)(b.child) &&
152
+ (0, oppositeNode_1.isOppositeNode)(a) &&
153
+ (0, fractionNode_1.isFractionNode)(a.child)) {
154
+ //-(c/d) + (-e/f) = -cf-ed / df
155
+ const c = a.child.leftChild;
156
+ const d = a.child.rightChild;
157
+ const e = b.child.leftChild;
158
+ const f = b.child.rightChild;
159
+ return new fractionNode_1.FractionNode(new AddNode(new multiplyNode_1.MultiplyNode(new oppositeNode_1.OppositeNode(c), f), new multiplyNode_1.MultiplyNode(new oppositeNode_1.OppositeNode(e), d)), new multiplyNode_1.MultiplyNode(d, f)).simplify(opts);
160
+ }
134
161
  if ((0, fractionNode_1.isFractionNode)(a)) {
135
162
  //c/d + b
136
163
  const c = a.leftChild;
137
164
  const d = a.rightChild;
138
165
  return new fractionNode_1.FractionNode(new AddNode(c, new multiplyNode_1.MultiplyNode(d, b)), d).simplify(opts);
139
166
  }
167
+ if ((0, oppositeNode_1.isOppositeNode)(a) && (0, fractionNode_1.isFractionNode)(a.child)) {
168
+ //-(c/d) + b = (-c+bd)/d
169
+ const c = a.child.leftChild;
170
+ const d = a.child.rightChild;
171
+ return new fractionNode_1.FractionNode(new AddNode(new oppositeNode_1.OppositeNode(c), new multiplyNode_1.MultiplyNode(d, b)), d).simplify(opts);
172
+ }
140
173
  if ((0, fractionNode_1.isFractionNode)(b) && !opts?.forceDistributeFractions) {
141
174
  //a+c/d
142
175
  const c = b.leftChild;
143
176
  const d = b.rightChild;
144
177
  return new fractionNode_1.FractionNode(new AddNode(c, new multiplyNode_1.MultiplyNode(d, a)), d).simplify(opts);
145
178
  }
179
+ if ((0, oppositeNode_1.isOppositeNode)(b) &&
180
+ (0, fractionNode_1.isFractionNode)(b.child) &&
181
+ !opts?.forceDistributeFractions) {
182
+ //a+-(c/d) = (da-c)/d
183
+ const c = b.child.leftChild;
184
+ const d = b.child.rightChild;
185
+ return new fractionNode_1.FractionNode(new AddNode(new oppositeNode_1.OppositeNode(c), new multiplyNode_1.MultiplyNode(d, a)), d).simplify(opts);
186
+ }
146
187
  if ((0, numberNode_1.isNumberNode)(a) && (0, numberNode_1.isNumberNode)(b)) {
147
188
  return new numberNode_1.NumberNode(a.value + b.value);
148
189
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AACD,qBAAa,YAAa,YAAW,YAAY;IAC/C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAItB,aAAa;;;;;;;;;IAQb,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA+BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,KAAK,IAAI,MAAM;IAcf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IA0J/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
1
+ {"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAK3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AACD,qBAAa,YAAa,YAAW,YAAY;IAC/C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAItB,aAAa;;;;;;;;;IAQb,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA+BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,KAAK,IAAI,MAAM;IAcf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IA2J/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
@@ -122,11 +122,11 @@ class FractionNode {
122
122
  }
123
123
  else if ((0, oppositeNode_1.isOppositeNode)(node)) {
124
124
  oppositesCount++;
125
- recursiveNums(node.child);
125
+ recursiveDenums(node.child);
126
126
  }
127
127
  else if ((0, numberNode_1.isNumberNode)(node) && node.value < 0) {
128
128
  oppositesCount++;
129
- externalsNums.push(new numberNode_1.NumberNode(Math.abs(node.value)));
129
+ externalsDenums.push(new numberNode_1.NumberNode(Math.abs(node.value)));
130
130
  }
131
131
  else {
132
132
  externalsDenums.push(node);
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=rationalParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rationalParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/rationalParser.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ // export const rationalParser = (ans: string) => {
3
+ // if(ans.startsWith("\\frac")){
4
+ // const num
5
+ // }
6
+ // const nb = ans.unfrenchify();
7
+ // if (isNaN(nb)) return false;
8
+ // return nb.frenchify();
9
+ // };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.2.41",
3
+ "version": "2.2.42",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [