math-exercises 2.0.21 → 2.0.22

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 (49) hide show
  1. package/lib/exercises/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
  2. package/lib/exercises/calculLitteral/equation/equationType3Exercise.js +8 -7
  3. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.d.ts.map +1 -1
  4. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.js +2 -1
  5. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.js +1 -0
  6. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.d.ts.map +1 -1
  7. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.js +1 -0
  8. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
  9. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.js +1 -0
  10. package/lib/exercises/geometry/vectors/alignementViaColinearity.d.ts.map +1 -1
  11. package/lib/exercises/geometry/vectors/alignementViaColinearity.js +10 -7
  12. package/lib/exercises/geometry/vectors/fourthParallelogramPoint.d.ts +14 -0
  13. package/lib/exercises/geometry/vectors/fourthParallelogramPoint.d.ts.map +1 -0
  14. package/lib/exercises/geometry/vectors/fourthParallelogramPoint.js +65 -0
  15. package/lib/exercises/geometry/vectors/index.d.ts +4 -0
  16. package/lib/exercises/geometry/vectors/index.d.ts.map +1 -1
  17. package/lib/exercises/geometry/vectors/index.js +4 -1
  18. package/lib/exercises/geometry/vectors/paralellismViaColinearity.d.ts +14 -0
  19. package/lib/exercises/geometry/vectors/paralellismViaColinearity.d.ts.map +1 -0
  20. package/lib/exercises/geometry/vectors/paralellismViaColinearity.js +75 -0
  21. package/lib/exercises/geometry/vectors/parallelogramViaEqualVectors.d.ts +14 -0
  22. package/lib/exercises/geometry/vectors/parallelogramViaEqualVectors.d.ts.map +1 -0
  23. package/lib/exercises/geometry/vectors/parallelogramViaEqualVectors.js +67 -0
  24. package/lib/exercises/geometry/vectors/vectorCoordinatesFromTwoPoints.d.ts.map +1 -1
  25. package/lib/exercises/geometry/vectors/vectorCoordinatesFromTwoPoints.js +1 -1
  26. package/lib/exercises/sequences/arithmetic/arithmeticFindExplicitFormula.js +1 -1
  27. package/lib/exercises/sequences/geometric/geometricFindExplicitFormula.js +1 -1
  28. package/lib/exercises/utils/keys/coordinatesKeys.d.ts +3 -0
  29. package/lib/exercises/utils/keys/coordinatesKeys.d.ts.map +1 -0
  30. package/lib/exercises/utils/keys/coordinatesKeys.js +4 -0
  31. package/lib/index.d.ts +34 -0
  32. package/lib/index.d.ts.map +1 -1
  33. package/lib/math/geometry/line.d.ts +1 -0
  34. package/lib/math/geometry/line.d.ts.map +1 -1
  35. package/lib/math/geometry/line.js +12 -0
  36. package/lib/math/geometry/point.d.ts.map +1 -1
  37. package/lib/math/geometry/point.js +1 -0
  38. package/lib/math/geometry/vector.d.ts +2 -0
  39. package/lib/math/geometry/vector.d.ts.map +1 -1
  40. package/lib/math/geometry/vector.js +8 -0
  41. package/lib/math/numbers/reals/extendedRingElement.d.ts +2 -1
  42. package/lib/math/numbers/reals/extendedRingElement.d.ts.map +1 -1
  43. package/lib/server.js +0 -29
  44. package/lib/tree/nodes/functions/oppositeNode.d.ts +2 -1
  45. package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
  46. package/lib/tree/nodes/functions/oppositeNode.js +2 -0
  47. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  48. package/lib/tree/nodes/operators/fractionNode.js +6 -0
  49. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"equationType3Exercise.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/equation/equationType3Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAgBlC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsDF,eAAO,MAAM,qBAAqB,EAAE,YAAY,CAAC,WAAW,CAc3D,CAAC"}
1
+ {"version":3,"file":"equationType3Exercise.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/equation/equationType3Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAiBlC;;GAEG;AACH,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsDF,eAAO,MAAM,qBAAqB,EAAE,YAAY,CAAC,WAAW,CAc3D,CAAC"}
@@ -15,15 +15,16 @@ const equalNode_1 = require("../../../tree/nodes/equations/equalNode");
15
15
  const discreteSetNode_1 = require("../../../tree/nodes/sets/discreteSetNode");
16
16
  const variableNode_1 = require("../../../tree/nodes/variables/variableNode");
17
17
  const shuffle_1 = require("../../../utils/shuffle");
18
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
18
19
  const getEquationType3ExerciseQuestion = () => {
19
20
  const interval = new intervals_1.Interval("[[-10; 10]]");
20
21
  const intervalStar = new intervals_1.Interval("[[-10; 10]]").difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(0)]));
21
- const b = intervalStar.getRandomElement();
22
- const a = intervalStar.getRandomElement();
23
- const c = interval.getRandomElement();
24
- const affine = new affine_1.Affine(a.value, b.value).toTree();
25
- const solution = new rational_1.Rational(c.value - b.value, a.value).simplify();
26
- const statementTree = new equalNode_1.EqualNode(affine, c.toTree());
22
+ const b = (0, randint_1.randint)(-10, 11, [0]);
23
+ const a = (0, randint_1.randint)(-10, 11, [0, 1]);
24
+ const c = (0, randint_1.randint)(-10, 11);
25
+ const affine = new affine_1.Affine(a, b).toTree();
26
+ const solution = new rational_1.Rational(c - b, a).simplify();
27
+ const statementTree = new equalNode_1.EqualNode(affine, new numberNode_1.NumberNode(c));
27
28
  const answerTree = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), solution.toTree());
28
29
  const answer = answerTree.toTex();
29
30
  const question = {
@@ -32,7 +33,7 @@ const getEquationType3ExerciseQuestion = () => {
32
33
  answer,
33
34
  keys: equationKeys_1.equationKeys,
34
35
  answerFormat: "tex",
35
- identifiers: { a: a.value, b: b.value, c: c.value },
36
+ identifiers: { a, b, c },
36
37
  };
37
38
  return question;
38
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType0.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA6DF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType0.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA8DF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
@@ -13,8 +13,9 @@ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
13
13
  const variableNode_1 = require("../../../tree/nodes/variables/variableNode");
14
14
  const coinFlip_1 = require("../../../utils/coinFlip");
15
15
  const shuffle_1 = require("../../../utils/shuffle");
16
+ /**x +b < c */
16
17
  const getFirstDegreeInequationsQuestion = () => {
17
- const affine = new affine_1.Affine(1, (0, randint_1.randint)(-10, 11));
18
+ const affine = new affine_1.Affine(1, (0, randint_1.randint)(-10, 11, [0]));
18
19
  const c = (0, randint_1.randint)(-10, 11);
19
20
  const result = c - affine.b;
20
21
  const ineqType = inequation_1.InequationSymbolConstructor.random();
@@ -13,6 +13,7 @@ const inequationSolutionNode_1 = require("../../../tree/nodes/inequations/inequa
13
13
  const variableNode_1 = require("../../../tree/nodes/variables/variableNode");
14
14
  const coinFlip_1 = require("../../../utils/coinFlip");
15
15
  const shuffle_1 = require("../../../utils/shuffle");
16
+ /**ax<b */
16
17
  const getFirstDegreeInequationsQuestion = () => {
17
18
  const affine = new affine_1.Affine((0, randint_1.randint)(-10, 10, [0, 1]), 0);
18
19
  const b = (0, randint_1.randint)(-10, 11);
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType2.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAc3C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwEF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType2.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAc3C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAyEF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
@@ -13,6 +13,7 @@ const inequationSolutionNode_1 = require("../../../tree/nodes/inequations/inequa
13
13
  const variableNode_1 = require("../../../tree/nodes/variables/variableNode");
14
14
  const coinFlip_1 = require("../../../utils/coinFlip");
15
15
  const shuffle_1 = require("../../../utils/shuffle");
16
+ /**ax+b<c */
16
17
  const getFirstDegreeInequationsQuestion = () => {
17
18
  const affine = new affine_1.Affine((0, randint_1.randint)(-10, 10, [0, 1]), (0, randint_1.randint)(-10, 10, [0]));
18
19
  const c = (0, randint_1.randint)(-10, 11);
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoFF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqFF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
@@ -13,6 +13,7 @@ const inequationSolutionNode_1 = require("../../../tree/nodes/inequations/inequa
13
13
  const variableNode_1 = require("../../../tree/nodes/variables/variableNode");
14
14
  const coinFlip_1 = require("../../../utils/coinFlip");
15
15
  const shuffle_1 = require("../../../utils/shuffle");
16
+ /**ax+b<cx+d */
16
17
  const getFirstDegreeInequationsQuestion = () => {
17
18
  const affine1 = new affine_1.Affine((0, randint_1.randint)(-10, 10, [0]), (0, randint_1.randint)(-10, 10));
18
19
  const affine2 = new affine_1.Affine((0, randint_1.randint)(-10, 10, [0, affine1.a]), (0, randint_1.randint)(-10, 10));
@@ -1 +1 @@
1
- {"version":3,"file":"alignementViaColinearity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/alignementViaColinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA8CF,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,WAAW,CAY9D,CAAC"}
1
+ {"version":3,"file":"alignementViaColinearity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/alignementViaColinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAkDF,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,WAAW,CAY9D,CAAC"}
@@ -3,24 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.alignementViaColinearity = void 0;
4
4
  const exercise_1 = require("../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
- const line_1 = require("../../../math/geometry/line");
7
6
  const point_1 = require("../../../math/geometry/point");
7
+ const vector_1 = require("../../../math/geometry/vector");
8
+ const randint_1 = require("../../../math/utils/random/randint");
9
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
8
10
  const coinFlip_1 = require("../../../utils/coinFlip");
9
11
  const shuffle_1 = require("../../../utils/shuffle");
10
12
  const getAlignementViaColinearityQuestion = () => {
11
13
  const points = point_1.PointConstructor.randomDifferent(["A", "B"]);
12
- const line = new line_1.Line(points[0], points[1]);
14
+ const AB = vector_1.VectorConstructor.fromPoints(points[0], points[1]);
13
15
  let C;
14
16
  const isAligned = (0, coinFlip_1.coinFlip)();
17
+ const coeff = new numberNode_1.NumberNode((0, randint_1.randint)(-4, 4, [0, 1]));
15
18
  if (isAligned) {
16
- do {
17
- C = line.getRandomPoint("C");
18
- } while (C.equals(points[0]) || C.equals(points[1]));
19
+ console.log("1");
20
+ C = AB.times(coeff).getEndPoint(points[0], "C");
19
21
  }
20
22
  else {
21
23
  do {
24
+ console.log(`2 : ${AB.x.toTex()} et ${AB.y.toTex()}`);
22
25
  C = point_1.PointConstructor.random("C");
23
- } while (C.equals(points[0]) || C.equals(points[1]) || line.includes(C));
26
+ } while (AB.isColinear(vector_1.VectorConstructor.fromPoints(points[0], C)));
24
27
  }
25
28
  const answer = isAligned ? "Oui" : "Non";
26
29
  const question = {
@@ -49,7 +52,7 @@ const getPropositions = (n, { answer }) => {
49
52
  };
50
53
  exports.alignementViaColinearity = {
51
54
  id: "alignementViaColinearity",
52
- label: "",
55
+ label: "Utiliser la colinéarité pour déterminer un alignement",
53
56
  levels: ["2nde", "1reSpé"],
54
57
  isSingleStep: true,
55
58
  sections: ["Vecteurs", "Droites"],
@@ -0,0 +1,14 @@
1
+ import { MathExercise } from "../../../exercises/exercise";
2
+ type Identifiers = {
3
+ xA: number;
4
+ xB: number;
5
+ xC: number;
6
+ xD: number;
7
+ yA: number;
8
+ yB: number;
9
+ yC: number;
10
+ yD: number;
11
+ };
12
+ export declare const fourthParallelogramPoint: MathExercise<Identifiers>;
13
+ export {};
14
+ //# sourceMappingURL=fourthParallelogramPoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fourthParallelogramPoint.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/fourthParallelogramPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAwDF,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,WAAW,CAY9D,CAAC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fourthParallelogramPoint = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const coordinatesKeys_1 = require("../../../exercises/utils/keys/coordinatesKeys");
7
+ const point_1 = require("../../../math/geometry/point");
8
+ const vector_1 = require("../../../math/geometry/vector");
9
+ const randint_1 = require("../../../math/utils/random/randint");
10
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
11
+ const shuffle_1 = require("../../../utils/shuffle");
12
+ const getFourthParallelogramPointQuestion = () => {
13
+ const points = point_1.PointConstructor.randomDifferent(["A", "B"]);
14
+ const AB = vector_1.VectorConstructor.fromPoints(points[0], points[1]);
15
+ let D;
16
+ do {
17
+ D = point_1.PointConstructor.random("D");
18
+ } while (AB.isColinear(vector_1.VectorConstructor.fromPoints(D, points[0])));
19
+ const C = AB.getEndPoint(D, "C");
20
+ const answer = D.toCoords();
21
+ const question = {
22
+ answer,
23
+ instruction: `Soient les points $${points[0].toTexWithCoords()}$, $${points[1].toTexWithCoords()}$, et $${C.toTexWithCoords()}$. Quelles sont les coordonnées du point $D$ tel que $ABCD$ soit un parallélogramme ?`,
24
+ keys: coordinatesKeys_1.coordinatesKeys,
25
+ answerFormat: "tex",
26
+ identifiers: {
27
+ xA: points[0].x.evaluate({}),
28
+ xB: points[1].x.evaluate({}),
29
+ xC: C.x.evaluate({}),
30
+ xD: D.x.evaluate({}),
31
+ yA: points[0].y.evaluate({}),
32
+ yB: points[1].y.evaluate({}),
33
+ yC: C.y.evaluate({}),
34
+ yD: D.y.evaluate({}),
35
+ },
36
+ };
37
+ return question;
38
+ };
39
+ const getPropositions = (n, { answer, xA, xB, xC, yA, yB, yC, yD }) => {
40
+ const propositions = [];
41
+ (0, exercise_1.addValidProp)(propositions, answer, "tex");
42
+ const AB = new vector_1.Vector("u", new numberNode_1.NumberNode(xB - xA), new numberNode_1.NumberNode(yB - yA));
43
+ const C = new point_1.Point("C", new numberNode_1.NumberNode(xC), new numberNode_1.NumberNode(yC));
44
+ const fakeD = AB.getEndPoint(C);
45
+ (0, exercise_1.tryToAddWrongProp)(propositions, fakeD.toCoords());
46
+ while (propositions.length < n) {
47
+ (0, exercise_1.tryToAddWrongProp)(propositions, `\\left(${(0, randint_1.randint)(-10, 10)};${(0, randint_1.randint)(-10, 10)}\\right)`);
48
+ }
49
+ return (0, shuffle_1.shuffle)(propositions);
50
+ };
51
+ const isAnswerValid = (ans, { answer }) => {
52
+ return [ans, ans.replace(",", ";"), "\\left(" + ans + "\\right)"].includes(answer);
53
+ };
54
+ exports.fourthParallelogramPoint = {
55
+ id: "fourthParallelogramPoint",
56
+ label: "Déterminer les coordonnées du quatrième point d'un parallélogramme",
57
+ levels: ["2nde", "1reSpé"],
58
+ isSingleStep: true,
59
+ sections: ["Vecteurs", "Droites"],
60
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getFourthParallelogramPointQuestion, nb),
61
+ qcmTimer: 60,
62
+ freeTimer: 60,
63
+ getPropositions,
64
+ isAnswerValid,
65
+ };
@@ -5,4 +5,8 @@ export * from "./scalarProductViaCoords";
5
5
  export * from "./vectorCoordinatesFromTwoPoints";
6
6
  export * from "./scalarProductViaCos";
7
7
  export * from "./colinearity";
8
+ export * from "./alignementViaColinearity";
9
+ export * from "./paralellismViaColinearity";
10
+ export * from "./parallelogramViaEqualVectors";
11
+ export * from "./fourthParallelogramPoint";
8
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC"}
@@ -21,4 +21,7 @@ __exportStar(require("./scalarProductViaCoords"), exports);
21
21
  __exportStar(require("./vectorCoordinatesFromTwoPoints"), exports);
22
22
  __exportStar(require("./scalarProductViaCos"), exports);
23
23
  __exportStar(require("./colinearity"), exports);
24
- // export * from "./alignementViaColinearity";
24
+ __exportStar(require("./alignementViaColinearity"), exports);
25
+ __exportStar(require("./paralellismViaColinearity"), exports);
26
+ __exportStar(require("./parallelogramViaEqualVectors"), exports);
27
+ __exportStar(require("./fourthParallelogramPoint"), exports);
@@ -0,0 +1,14 @@
1
+ import { MathExercise } from "../../../exercises/exercise";
2
+ type Identifiers = {
3
+ xA: number;
4
+ xB: number;
5
+ xC: number;
6
+ xD: number;
7
+ yA: number;
8
+ yB: number;
9
+ yC: number;
10
+ yD: number;
11
+ };
12
+ export declare const paralellismViaColinearity: MathExercise<Identifiers>;
13
+ export {};
14
+ //# sourceMappingURL=paralellismViaColinearity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paralellismViaColinearity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/paralellismViaColinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAalC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA2DF,eAAO,MAAM,yBAAyB,EAAE,YAAY,CAAC,WAAW,CAY/D,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paralellismViaColinearity = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const line_1 = require("../../../math/geometry/line");
7
+ const point_1 = require("../../../math/geometry/point");
8
+ const vector_1 = require("../../../math/geometry/vector");
9
+ const randint_1 = require("../../../math/utils/random/randint");
10
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
11
+ const coinFlip_1 = require("../../../utils/coinFlip");
12
+ const shuffle_1 = require("../../../utils/shuffle");
13
+ const getParalellismViaColinearityQuestion = () => {
14
+ let points = [];
15
+ do {
16
+ points = point_1.PointConstructor.randomDifferent(["A", "B"]);
17
+ } while (points[0].x.equals(points[1].x));
18
+ const line = new line_1.Line(points[0], points[1]);
19
+ let C;
20
+ do {
21
+ C = point_1.PointConstructor.random("C");
22
+ } while (line.includes(C));
23
+ let D;
24
+ const coeff = new numberNode_1.NumberNode((0, randint_1.randint)(-4, 4, [0]));
25
+ const parallele = line.getParallele(C);
26
+ const isParallele = (0, coinFlip_1.coinFlip)();
27
+ if (isParallele) {
28
+ D = vector_1.VectorConstructor.fromPoints(points[0], points[1])
29
+ .times(coeff)
30
+ .getEndPoint(C, "D");
31
+ }
32
+ else {
33
+ do {
34
+ D = point_1.PointConstructor.random("D");
35
+ } while (parallele.includes(D));
36
+ }
37
+ const answer = isParallele ? "Oui" : "Non";
38
+ const question = {
39
+ answer,
40
+ instruction: `Soient les points $${points[0].toTexWithCoords()}$, $${points[1].toTexWithCoords()}$, $${C.toTexWithCoords()}$ et $${D.toTexWithCoords()}$. Les droites $(AB)$ et $(CD)$ sont-elles parallèles ?`,
41
+ keys: [],
42
+ answerFormat: "raw",
43
+ identifiers: {
44
+ xA: points[0].x.evaluate({}),
45
+ xB: points[1].x.evaluate({}),
46
+ xC: C.x.evaluate({}),
47
+ xD: D.x.evaluate({}),
48
+ yA: points[0].y.evaluate({}),
49
+ yB: points[1].y.evaluate({}),
50
+ yC: C.y.evaluate({}),
51
+ yD: D.y.evaluate({}),
52
+ },
53
+ };
54
+ return question;
55
+ };
56
+ const getPropositions = (n, { answer }) => {
57
+ const propositions = [];
58
+ (0, exercise_1.addValidProp)(propositions, answer, "raw");
59
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
60
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
61
+ (0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
62
+ return (0, shuffle_1.shuffle)(propositions);
63
+ };
64
+ exports.paralellismViaColinearity = {
65
+ id: "paralellismViaColinearity",
66
+ label: "Utiliser la colinéarité pour déterminer un parallélisme",
67
+ levels: ["2nde", "1reSpé"],
68
+ isSingleStep: true,
69
+ sections: ["Vecteurs", "Droites"],
70
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getParalellismViaColinearityQuestion, nb),
71
+ qcmTimer: 60,
72
+ freeTimer: 60,
73
+ getPropositions,
74
+ answerType: "QCM",
75
+ };
@@ -0,0 +1,14 @@
1
+ import { MathExercise } from "../../../exercises/exercise";
2
+ type Identifiers = {
3
+ xA: number;
4
+ xB: number;
5
+ xC: number;
6
+ xD: number;
7
+ yA: number;
8
+ yB: number;
9
+ yC: number;
10
+ yD: number;
11
+ };
12
+ export declare const parallelogramViaEqualVectors: MathExercise<Identifiers>;
13
+ export {};
14
+ //# sourceMappingURL=parallelogramViaEqualVectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parallelogramViaEqualVectors.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/parallelogramViaEqualVectors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAyDF,eAAO,MAAM,4BAA4B,EAAE,YAAY,CAAC,WAAW,CAYlE,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parallelogramViaEqualVectors = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const point_1 = require("../../../math/geometry/point");
7
+ const vector_1 = require("../../../math/geometry/vector");
8
+ const coinFlip_1 = require("../../../utils/coinFlip");
9
+ const shuffle_1 = require("../../../utils/shuffle");
10
+ const getParallelogramViaEqualVectorsQuestion = () => {
11
+ const points = point_1.PointConstructor.randomDifferent(["A", "B"]);
12
+ const AB = vector_1.VectorConstructor.fromPoints(points[0], points[1]);
13
+ let D;
14
+ do {
15
+ console.log(`1 : points: ${points.map((p) => p.toCoords())}, vec : ${AB.x.toTex()} et ${AB.y.toTex()}`);
16
+ D = point_1.PointConstructor.random("D");
17
+ } while (AB.isColinear(vector_1.VectorConstructor.fromPoints(D, points[0])));
18
+ let C;
19
+ const isParallelogram = (0, coinFlip_1.coinFlip)();
20
+ if (isParallelogram) {
21
+ C = AB.getEndPoint(D, "C");
22
+ }
23
+ else {
24
+ do {
25
+ console.log("2");
26
+ C = point_1.PointConstructor.random("C");
27
+ } while (AB.equals(vector_1.VectorConstructor.fromPoints(D, C)));
28
+ }
29
+ const answer = isParallelogram ? "Oui" : "Non";
30
+ const question = {
31
+ answer,
32
+ instruction: `Soient les points $${points[0].toTexWithCoords()}$, $${points[1].toTexWithCoords()}$, $${C.toTexWithCoords()}$ et $${D.toTexWithCoords()}$. $ABCD$ est-il un parallélogramme ?`,
33
+ keys: [],
34
+ answerFormat: "raw",
35
+ identifiers: {
36
+ xA: points[0].x.evaluate({}),
37
+ xB: points[1].x.evaluate({}),
38
+ xC: C.x.evaluate({}),
39
+ xD: D.x.evaluate({}),
40
+ yA: points[0].y.evaluate({}),
41
+ yB: points[1].y.evaluate({}),
42
+ yC: C.y.evaluate({}),
43
+ yD: D.y.evaluate({}),
44
+ },
45
+ };
46
+ return question;
47
+ };
48
+ const getPropositions = (n, { answer }) => {
49
+ const propositions = [];
50
+ (0, exercise_1.addValidProp)(propositions, answer, "raw");
51
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
52
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
53
+ (0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
54
+ return (0, shuffle_1.shuffle)(propositions);
55
+ };
56
+ exports.parallelogramViaEqualVectors = {
57
+ id: "parallelogramViaEqualVectors",
58
+ label: "Utiliser les vecteurs pour reconnaître un parallélogramme",
59
+ levels: ["2nde", "1reSpé"],
60
+ isSingleStep: true,
61
+ sections: ["Vecteurs", "Droites"],
62
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getParallelogramViaEqualVectorsQuestion, nb),
63
+ qcmTimer: 60,
64
+ freeTimer: 60,
65
+ getPropositions,
66
+ answerType: "QCM",
67
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"vectorCoordinatesFromTwoPoints.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/vectorCoordinatesFromTwoPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAKlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,CAAC,EAAE,MAAM,EAAE,CAAC;CACb,CAAC;AAuDF,eAAO,MAAM,8BAA8B,EAAE,YAAY,CAAC,WAAW,CAapE,CAAC"}
1
+ {"version":3,"file":"vectorCoordinatesFromTwoPoints.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/vectorCoordinatesFromTwoPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAKlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,CAAC,EAAE,MAAM,EAAE,CAAC;CACb,CAAC;AAyDF,eAAO,MAAM,8BAA8B,EAAE,YAAY,CAAC,WAAW,CAapE,CAAC"}
@@ -35,7 +35,7 @@ const getPropositions = (n, { answer, A, B }) => {
35
35
  return (0, exercise_1.shuffleProps)(propositions, n);
36
36
  };
37
37
  const isAnswerValid = (ans, { answer }) => {
38
- return ans === answer;
38
+ return [ans, ans.replace(",", ";"), "\\left(" + ans + "\\right)"].includes(answer);
39
39
  };
40
40
  exports.vectorCoordinatesFromTwoPoints = {
41
41
  id: "vectorCoordinatesFromTwoPoints",
@@ -17,7 +17,7 @@ const getArithmeticFindExplicitFormula = () => {
17
17
  const question = {
18
18
  instruction: `$(u_n)$ est une suite arithmétique de premier terme $u_{${firstRank}} = ${firstValue}$ et de raison $r = ${reason}$. $\\\\$ Donner l'expression de $u_n$ en fonction de $n$.`,
19
19
  answer,
20
- keys: ["un", "equal", "r", "n", "u", "underscore"],
20
+ keys: ["un", "equal", "n"],
21
21
  answerFormat: "tex",
22
22
  identifiers: { firstValue, reason },
23
23
  };
@@ -19,7 +19,7 @@ const getGeometricFindExplicitFormula = () => {
19
19
  const question = {
20
20
  instruction: `$(u_n)$ est une suite géométrique de premier terme $u_{${firstRank}} = ${firstValue}$ et de raison $q = ${reason}$. $\\\\$ Donner l'expression de $u_n$ en fonction de $n$.`,
21
21
  answer,
22
- keys: ["un", "equal", "q", "n", "u", "underscore"],
22
+ keys: ["un", "equal", "n"],
23
23
  answerFormat: "tex",
24
24
  identifiers: { reason, firstValue },
25
25
  };
@@ -0,0 +1,3 @@
1
+ import { KeyId } from "../../../types/keyIds";
2
+ export declare const coordinatesKeys: KeyId[];
3
+ //# sourceMappingURL=coordinatesKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinatesKeys.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/keys/coordinatesKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,eAAO,MAAM,eAAe,EAAE,KAAK,EAAsC,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coordinatesKeys = void 0;
4
+ exports.coordinatesKeys = ["lbrace", "semicolon", "rbrace"];
package/lib/index.d.ts CHANGED
@@ -515,6 +515,40 @@ declare const mathExercises: (import("./exercises/exercise").MathExercise<{
515
515
  yu: number;
516
516
  xv: number;
517
517
  yv: number;
518
+ }> | import("./exercises/exercise").MathExercise<{
519
+ xA: number;
520
+ xB: number;
521
+ xC: number;
522
+ yA: number;
523
+ yB: number;
524
+ yC: number;
525
+ }> | import("./exercises/exercise").MathExercise<{
526
+ xA: number;
527
+ xB: number;
528
+ xC: number;
529
+ xD: number;
530
+ yA: number;
531
+ yB: number;
532
+ yC: number;
533
+ yD: number;
534
+ }> | import("./exercises/exercise").MathExercise<{
535
+ xA: number;
536
+ xB: number;
537
+ xC: number;
538
+ xD: number;
539
+ yA: number;
540
+ yB: number;
541
+ yC: number;
542
+ yD: number;
543
+ }> | import("./exercises/exercise").MathExercise<{
544
+ xA: number;
545
+ xB: number;
546
+ xC: number;
547
+ xD: number;
548
+ yA: number;
549
+ yB: number;
550
+ yC: number;
551
+ yD: number;
518
552
  }> | import("./exercises/exercise").MathExercise<{
519
553
  coeffs: number[];
520
554
  to: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA2B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA2B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -7,6 +7,7 @@ export declare class Line {
7
7
  a: AlgebraicNode | undefined;
8
8
  b: AlgebraicNode | undefined;
9
9
  constructor(pointA: Point, pointB: Point);
10
+ getParallele(point: Point): Line;
10
11
  includes(point: Point): boolean;
11
12
  getRandomPoint(name?: string): Point;
12
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO/D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,IAAI;IACf,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;gBACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAkBxC,QAAQ,CAAC,KAAK,EAAE,KAAK;IAWrB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;CAY7B"}
1
+ {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO/D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,IAAI;IACf,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;gBACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAkBxC,YAAY,CAAC,KAAK,EAAE,KAAK;IAUzB,QAAQ,CAAC,KAAK,EAAE,KAAK;IAarB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;CAa7B"}
@@ -22,18 +22,30 @@ class Line {
22
22
  this.b = new substractNode_1.SubstractNode(this.pointA.y, new multiplyNode_1.MultiplyNode(this.a, this.pointA.x)).simplify();
23
23
  }
24
24
  }
25
+ getParallele(point) {
26
+ if (this.isVertical) {
27
+ console.log(this.pointA.toTexWithCoords(), this.pointB.toTexWithCoords());
28
+ throw Error("Parallel vertical lines not implemented");
29
+ }
30
+ const x = new addNode_1.AddNode(point.x, new numberNode_1.NumberNode(1)).simplify();
31
+ const y = new addNode_1.AddNode(point.y, this.a).simplify();
32
+ const secondPoint = new point_1.Point("D", x, y);
33
+ return new Line(point, secondPoint);
34
+ }
25
35
  includes(point) {
26
36
  if (this.isVertical) {
27
37
  return point.x.equals(this.pointA.x);
28
38
  }
29
39
  return (new substractNode_1.SubstractNode(point.y, new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, point.x), this.b)).evaluate({}) === 0);
30
40
  }
41
+ //! caution: simplify ne gère pas bien ici
31
42
  getRandomPoint(name) {
32
43
  if (this.isVertical) {
33
44
  return new point_1.Point(name ?? "A", this.pointA.x, new numberNode_1.NumberNode((0, randint_1.randint)(-10, 10)));
34
45
  }
35
46
  const x = new numberNode_1.NumberNode((0, randint_1.randint)(-10, 10));
36
47
  const y = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, x), this.b).simplify();
48
+ console.log(y.toTex(), this.a.toTex(), x.toTex(), this.b?.toTex());
37
49
  return new point_1.Point(name ?? "A", x, y);
38
50
  }
39
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAKlC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;CAevC;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAM5D,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAGzB,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,SAAM,GAAG,KAAK;IAiBrC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM;IAM5B,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;CAK7B"}
1
+ {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAMlC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;CAevC;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAM5D,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAGzB,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,SAAM,GAAG,KAAK;IAiBrC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM;IAM5B,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;CAK7B"}
@@ -22,6 +22,7 @@ class PointConstructor {
22
22
  x = (0, randint_1.randint)(-10, 11);
23
23
  y = (0, randint_1.randint)(-10, 11);
24
24
  } while (points.some((point) => point[0] === x && point[1] === y));
25
+ points.push([x, y]);
25
26
  res.push(new Point(names[i], new numberNode_1.NumberNode(x), new numberNode_1.NumberNode(y)));
26
27
  }
27
28
  return res;
@@ -17,5 +17,7 @@ export declare class Vector {
17
17
  determinant(v: Vector): AlgebraicNode;
18
18
  times(k: AlgebraicNode, name?: string): Vector;
19
19
  scalarProduct(v: Vector): Node;
20
+ getEndPoint(startPoint: Point, name?: string): Point;
21
+ equals(v: Vector): boolean;
20
22
  }
21
23
  //# sourceMappingURL=vector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;AAKvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM;IAOpD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM;CAOtD;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAO5D,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAMzB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa;IAcrC,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAOrC,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;CAa/B"}
1
+ {"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM;IAOpD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM;CAOtD;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAO5D,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAMzB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa;IAcrC,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAOrC,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAc9B,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAO5C,MAAM,CAAC,CAAC,EAAE,MAAM;CAGjB"}
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Vector = exports.VectorConstructor = void 0;
4
4
  const node_1 = require("../../tree/nodes/node");
5
5
  const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
6
+ const addNode_1 = require("../../tree/nodes/operators/addNode");
6
7
  const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
7
8
  const substractNode_1 = require("../../tree/nodes/operators/substractNode");
8
9
  const randint_1 = require("../utils/random/randint");
10
+ const point_1 = require("./point");
9
11
  class VectorConstructor {
10
12
  static fromPoints(origin, end) {
11
13
  return new Vector(`${origin.name}${end.name}`, new substractNode_1.SubstractNode(end.x, origin.x).simplify(), new substractNode_1.SubstractNode(end.y, origin.y).simplify());
@@ -55,5 +57,11 @@ class Vector {
55
57
  const vyValue = v.y.value;
56
58
  return new numberNode_1.NumberNode(xValue * vxValue + yValue * vyValue);
57
59
  }
60
+ getEndPoint(startPoint, name) {
61
+ return new point_1.Point(name ?? "B", new addNode_1.AddNode(startPoint.x, this.x).simplify(), new addNode_1.AddNode(startPoint.y, this.y).simplify());
62
+ }
63
+ equals(v) {
64
+ return this.x.equals(v.x) && this.y.equals(v.y);
65
+ }
58
66
  }
59
67
  exports.Vector = Vector;
@@ -1,3 +1,4 @@
1
+ import { OppositeNode } from '../../../tree/nodes/functions/oppositeNode';
1
2
  import { NumberNode } from '../../../tree/nodes/numbers/numberNode';
2
3
  import { MultiplyNode } from '../../../tree/nodes/operators/multiplyNode';
3
4
  import { SubstractNode } from '../../../tree/nodes/operators/substractNode';
@@ -11,6 +12,6 @@ export declare class ExtendedRingElement {
11
12
  b: number;
12
13
  algebraicElement: Nombre;
13
14
  constructor(a: number, b: number, algebraicElement: Nombre);
14
- toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode | MultiplyNode | SubstractNode;
15
+ toTree(): import("../../../tree/nodes/algebraicNode").AlgebraicNode | NumberNode | MultiplyNode | OppositeNode | SubstractNode;
15
16
  }
16
17
  //# sourceMappingURL=extendedRingElement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extendedRingElement.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/reals/extendedRingElement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;GAGG;AACH,qBAAa,mBAAmB;IAM9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,gBAAgB,EAAE,MAAM,CAAC;gBACb,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAM1D,MAAM;CAeP"}
1
+ {"version":3,"file":"extendedRingElement.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/reals/extendedRingElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;GAGG;AACH,qBAAa,mBAAmB;IAM9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,gBAAgB,EAAE,MAAM,CAAC;gBACb,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAM1D,MAAM;CAeP"}
package/lib/server.js CHANGED
@@ -35,41 +35,12 @@ const express_1 = __importDefault(require("express"));
35
35
  const body_parser_1 = __importDefault(require("body-parser"));
36
36
  const dotenv_1 = __importDefault(require("dotenv"));
37
37
  const cors_1 = __importDefault(require("cors"));
38
- const decimal_1 = require("./math/numbers/decimals/decimal");
39
38
  const jsonParser = body_parser_1.default.json();
40
39
  const allExercises = [...exercises];
41
40
  const runServer = () => {
42
41
  dotenv_1.default.config();
43
42
  const app = (0, express_1.default)();
44
43
  app.use((0, cors_1.default)());
45
- // const string = "\\frac{9}{12}";
46
- // const a = string.match(/^[0-9]+,?[0-9]*/);
47
- // const before = Date.now();
48
- // const parsed = parseLatex(string);
49
- // console.log("res", parsed);
50
- // console.log(parsed?.toTex());
51
- // console.log(parsed?.simplify().toTex());
52
- // console.log(parsed?.evaluate({ x: 1 }));
53
- // console.log("time", Date.now() - before);
54
- // tokenize(string);
55
- // const a = DecimalConstructor.random(-4, 8);
56
- // const a = new Decimal(-0.0009343);
57
- // console.log(a.value, a.multiplyByPowerOfTen(-2).toTree().toTex());
58
- // const b = new Decimal(0.0009343);
59
- // console.log(b.value, b.multiplyByPowerOfTen(-2).toTree().toTex());
60
- // const c = new Decimal(-2.00009343);
61
- // console.log(c.value, c.multiplyByPowerOfTen(-2).toTree().toTex());
62
- // const d = new Decimal(2.009343);
63
- // console.log(d.value, d.multiplyByPowerOfTen(-2).toTree().toTex());
64
- const power = 1;
65
- const a = new decimal_1.Decimal(-0.00400250009343);
66
- console.log(a.value, a.multiplyByPowerOfTen(power).toTree().toTex());
67
- const b = new decimal_1.Decimal(0.04010009343);
68
- console.log(b.value, b.multiplyByPowerOfTen(power).toTree().toTex());
69
- const c = new decimal_1.Decimal(-23.00009343);
70
- console.log(c.value, c.multiplyByPowerOfTen(power).toTree().toTex());
71
- const d = new decimal_1.Decimal(20.4009343);
72
- console.log(d.value, d.multiplyByPowerOfTen(power).toTree().toTex());
73
44
  app.get("/", (req, res) => {
74
45
  res.json(allExercises);
75
46
  });
@@ -1,5 +1,6 @@
1
1
  import { Node, NodeOptions, NodeType } from "../node";
2
2
  import { FunctionNode, FunctionsIds } from "./functionNode";
3
+ import { NumberNode } from "../numbers/numberNode";
3
4
  import { AlgebraicNode, SimplifyOptions } from "../algebraicNode";
4
5
  export declare function isOppositeNode(a: Node): a is OppositeNode;
5
6
  export declare class OppositeNode implements FunctionNode {
@@ -19,7 +20,7 @@ export declare class OppositeNode implements FunctionNode {
19
20
  */
20
21
  toAllValidTexs(opts?: NodeOptions): string[];
21
22
  evaluate(vars: Record<string, number>): number;
22
- simplify(opts?: SimplifyOptions): AlgebraicNode;
23
+ simplify(opts?: SimplifyOptions): AlgebraicNode | NumberNode;
23
24
  equals(node: AlgebraicNode): boolean;
24
25
  }
25
26
  //# sourceMappingURL=oppositeNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAGD,qBAAa,YAAa,YAAW,YAAY;IAC/C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAef,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAgCtD;;;;OAIG;IACH,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAQ5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAG/B,MAAM,CAAC,IAAI,EAAE,aAAa;CAG3B"}
1
+ {"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAgB,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAGD,qBAAa,YAAa,YAAW,YAAY;IAC/C,EAAE,EAAE,YAAY,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;gBACP,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;IAOpD,YAAY,IAAI,MAAM;IAGtB,KAAK,IAAI,MAAM;IAef,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,EAAE;IAgCtD;;;;OAIG;IACH,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAQ5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAGrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe;IAI/B,MAAM,CAAC,IAAI,EAAE,aAAa;CAG3B"}
@@ -71,6 +71,8 @@ class OppositeNode {
71
71
  return -this.child.evaluate(vars);
72
72
  }
73
73
  simplify(opts) {
74
+ if ((0, numberNode_1.isNumberNode)(this.child))
75
+ return new numberNode_1.NumberNode(-this.child.value);
74
76
  return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(-1), this.child).simplify(opts);
75
77
  }
76
78
  equals(node) {
@@ -1 +1 @@
1
- {"version":3,"file":"fractionNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/fractionNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,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,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA2BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,KAAK,IAAI,MAAM;IAaf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAmF/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,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,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,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA2BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAI5C,KAAK,IAAI,MAAM;IAaf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMrC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAyF/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;CAOrC"}
@@ -78,6 +78,12 @@ class FractionNode {
78
78
  const simplifiedNum = this.leftChild.simplify(opts);
79
79
  const simplifiedDenum = this.rightChild.simplify(opts);
80
80
  const copy = new FractionNode(simplifiedNum, simplifiedDenum, this.opts);
81
+ if ((0, numberNode_1.isNumberNode)(simplifiedDenum) && simplifiedDenum.value === 1) {
82
+ return simplifiedNum;
83
+ }
84
+ if ((0, numberNode_1.isNumberNode)(simplifiedDenum) && simplifiedDenum.value === -1) {
85
+ return new oppositeNode_1.OppositeNode(simplifiedNum).simplify(opts);
86
+ }
81
87
  const externalsNums = [];
82
88
  const externalsDenums = [];
83
89
  const recursiveNums = (node) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [