math-exercises 2.2.93 → 2.2.94

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 (50) hide show
  1. package/lib/exercises/math/calcul/fractions/fractionSquare.d.ts +8 -0
  2. package/lib/exercises/math/calcul/fractions/fractionSquare.d.ts.map +1 -0
  3. package/lib/exercises/math/calcul/fractions/fractionSquare.js +106 -0
  4. package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
  5. package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/fractions/index.js +1 -0
  7. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts +9 -0
  8. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +160 -126
  10. package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
  11. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  12. package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
  13. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.d.ts.map +1 -1
  14. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq1.js +75 -41
  15. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.d.ts.map +1 -1
  16. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq2.js +70 -40
  17. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/factorisation/factoIdRmq3.js +78 -47
  19. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
  20. package/lib/exercises/math/functions/affines/affineExpressionReading.js +45 -23
  21. package/lib/exercises/math/percent/findRightCalcul.d.ts +10 -0
  22. package/lib/exercises/math/percent/findRightCalcul.d.ts.map +1 -0
  23. package/lib/exercises/math/percent/findRightCalcul.js +116 -0
  24. package/lib/exercises/math/percent/htToTTC.d.ts.map +1 -1
  25. package/lib/exercises/math/percent/htToTTC.js +34 -12
  26. package/lib/exercises/math/percent/index.d.ts +1 -0
  27. package/lib/exercises/math/percent/index.d.ts.map +1 -1
  28. package/lib/exercises/math/percent/index.js +2 -0
  29. package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
  30. package/lib/exercises/math/percent/percentToDecimal.js +6 -2
  31. package/lib/exercises/math/percent/percentWritings.d.ts +8 -0
  32. package/lib/exercises/math/percent/percentWritings.d.ts.map +1 -0
  33. package/lib/exercises/math/percent/percentWritings.js +136 -0
  34. package/lib/exercises/math/percent/ttcToHT.d.ts.map +1 -1
  35. package/lib/exercises/math/percent/ttcToHT.js +33 -12
  36. package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.d.ts.map +1 -1
  37. package/lib/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.js +54 -23
  38. package/lib/index.d.ts +13 -0
  39. package/lib/index.d.ts.map +1 -1
  40. package/lib/playground.d.ts.map +1 -1
  41. package/lib/playground.js +1 -12
  42. package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
  43. package/lib/tree/nodes/functions/oppositeNode.js +1 -1
  44. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  45. package/lib/tree/nodes/operators/fractionNode.js +2 -1
  46. package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
  47. package/lib/tree/parsers/discreteSetParser.js +0 -2
  48. package/lib/tree/parsers/latexParser.d.ts.map +1 -1
  49. package/lib/tree/parsers/latexParser.js +12 -0
  50. package/package.json +1 -1
@@ -23,7 +23,11 @@ const getInstruction = ({ isPercentToDecimal, nb, }) => {
23
23
  const instru = isPercentToDecimal ? percentTex : tex;
24
24
  return `Ecrire le nombre suivant ${isPercentToDecimal
25
25
  ? "sous forme de nombre décimal"
26
- : "sous forme de pourcentage"} : $${instru}$`;
26
+ : "sous forme de pourcentage"} :
27
+
28
+ $$
29
+ ${instru}
30
+ $$`;
27
31
  };
28
32
  const getHint = ({ isPercentToDecimal }) => {
29
33
  return `${isPercentToDecimal
@@ -64,7 +68,7 @@ const getPercentToDecimalQuestion = () => {
64
68
  const nb = percentNb.times(0.01);
65
69
  const identifiers = {
66
70
  isPercentToDecimal,
67
- nb: nb.value,
71
+ nb: (0, round_1.round)(nb.value, 10),
68
72
  };
69
73
  const question = {
70
74
  answer: getAnswer(identifiers),
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise";
2
+ type Identifiers = {
3
+ percent: number;
4
+ target: "decimalToPercent" | "fractionToPercent" | "percentToDecimal" | "percentToFraction";
5
+ };
6
+ export declare const percentWritings: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=percentWritings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percentWritings.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/percentWritings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EACF,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,GAClB,mBAAmB,CAAC;CACzB,CAAC;AA0IF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAgBjD,CAAC"}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.percentWritings = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const numberVEA_1 = require("../../../exercises/vea/numberVEA");
7
+ const rationalVEA_1 = require("../../../exercises/vea/rationalVEA");
8
+ const rational_1 = require("../../../math/numbers/rationals/rational");
9
+ const randint_1 = require("../../../math/utils/random/randint");
10
+ const round_1 = require("../../../math/utils/round");
11
+ const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
12
+ const percentParser_1 = require("../../../tree/parsers/percentParser");
13
+ const random_1 = require("../../../utils/alea/random");
14
+ const getPropositions = (n, { answer, percent, target }) => {
15
+ const propositions = [];
16
+ (0, exercise_1.addValidProp)(propositions, answer);
17
+ switch (target) {
18
+ case "decimalToPercent":
19
+ break;
20
+ case "fractionToPercent":
21
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, round_1.round)(percent / 10, 5).frenchify() + "\\%");
22
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, round_1.round)(percent / 100, 5).frenchify() + "\\%");
23
+ break;
24
+ case "percentToDecimal":
25
+ break;
26
+ case "percentToFraction":
27
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, fractionNode_1.frac)(100, percent).toTex());
28
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, fractionNode_1.frac)(percent, 10).toTex());
29
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, fractionNode_1.frac)((0, round_1.round)(percent / 100, 5), 100).toTex());
30
+ break;
31
+ }
32
+ while (propositions.length < n) {
33
+ switch (target) {
34
+ case "decimalToPercent":
35
+ break;
36
+ case "fractionToPercent":
37
+ break;
38
+ case "percentToDecimal":
39
+ break;
40
+ case "percentToFraction":
41
+ (0, exercise_1.tryToAddWrongProp)(propositions, rational_1.RationalConstructor.randomIrreductible().toTree().toTex());
42
+ break;
43
+ }
44
+ }
45
+ return (0, exercise_1.shuffleProps)(propositions, n);
46
+ };
47
+ const getAnswer = (identifiers) => {
48
+ const { percent, target } = identifiers;
49
+ const dec = (0, round_1.round)(percent / 100, 4).frenchify();
50
+ const fraction = (0, fractionNode_1.frac)(percent, 100).toTex();
51
+ switch (target) {
52
+ case "decimalToPercent":
53
+ case "fractionToPercent":
54
+ return percent + "\\%";
55
+ case "percentToDecimal":
56
+ return dec;
57
+ case "percentToFraction":
58
+ return fraction;
59
+ }
60
+ };
61
+ const getInstruction = (identifiers) => {
62
+ const { percent, target } = identifiers;
63
+ const dec = (0, round_1.round)(percent / 100, 4).frenchify();
64
+ const fraction = (0, fractionNode_1.frac)(percent, 100).toTex();
65
+ const nb = target === "decimalToPercent"
66
+ ? dec
67
+ : target === "fractionToPercent"
68
+ ? fraction
69
+ : percent + "\\%";
70
+ const targetType = target === "percentToDecimal"
71
+ ? "nombre décimal"
72
+ : target === "percentToFraction"
73
+ ? "fraction"
74
+ : "pourcentage";
75
+ return `Écrire le nombre $${nb}$ sous forme de ${targetType}.`;
76
+ };
77
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
78
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
79
+ const getKeys = (identifiers) => {
80
+ return ["percent"];
81
+ };
82
+ const isAnswerValid = (ans, { answer, percent, target }) => {
83
+ try {
84
+ switch (target) {
85
+ case "decimalToPercent":
86
+ case "fractionToPercent":
87
+ return (0, percentParser_1.percentParser)(ans) === answer;
88
+ case "percentToDecimal":
89
+ return (0, numberVEA_1.numberVEA)(ans, answer);
90
+ case "percentToFraction":
91
+ return (0, rationalVEA_1.rationalVEA)(ans, answer);
92
+ }
93
+ }
94
+ catch (err) {
95
+ return false;
96
+ }
97
+ };
98
+ const getPercentWritingsQuestion = (ops) => {
99
+ const percent = (0, randint_1.randint)(1, 150);
100
+ const target = (0, random_1.random)([
101
+ "decimalToPercent",
102
+ "fractionToPercent",
103
+ "percentToDecimal",
104
+ "percentToFraction",
105
+ ]);
106
+ const identifiers = {
107
+ percent,
108
+ target,
109
+ };
110
+ const question = {
111
+ answer: getAnswer(identifiers),
112
+ instruction: getInstruction(identifiers),
113
+ keys: getKeys(identifiers),
114
+ answerFormat: "tex",
115
+ identifiers,
116
+ // hint: getHint(identifiers),
117
+ // correction: getCorrection(identifiers),
118
+ };
119
+ return question;
120
+ };
121
+ exports.percentWritings = {
122
+ id: "percentWritings",
123
+ connector: "=",
124
+ label: "Passer d'une écriture de pourcentage à une autre",
125
+ isSingleStep: true,
126
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getPercentWritingsQuestion(opts), nb),
127
+ qcmTimer: 60,
128
+ freeTimer: 60,
129
+ getPropositions,
130
+ isAnswerValid,
131
+ subject: "Mathématiques",
132
+ getInstruction,
133
+ // getHint,
134
+ // getCorrection,
135
+ getAnswer,
136
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"ttcToHT.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/ttcToHT.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAuDF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAczC,CAAC"}
1
+ {"version":3,"file":"ttcToHT.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/ttcToHT.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AA6EF,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,WAAW,CAkBzC,CAAC"}
@@ -9,18 +9,22 @@ const round_1 = require("../../../math/utils/round");
9
9
  const numberParser_1 = require("../../../tree/parsers/numberParser");
10
10
  const coinFlip_1 = require("../../../utils/alea/coinFlip");
11
11
  const random_1 = require("../../../utils/alea/random");
12
- const getTtcToHtQuestion = () => {
13
- const TVA = (0, random_1.random)([20, 5.5]);
14
- const TTC = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(50, 1000) : (0, randfloat_1.randfloat)(20, 200, 2);
12
+ const getInstruction = (identifiers) => {
13
+ const { TVA, TTC } = identifiers;
14
+ return `Un objet coûte $${TTC.frenchify()}€$ en TTC. Quel est son prix HT, sachant que la TVA est de $${TVA.frenchify()}\\%$ ? (arrondir au centième)`;
15
+ };
16
+ const getAnswer = (identifiers) => {
17
+ const { TVA, TTC } = identifiers;
15
18
  const answer = (0, round_1.round)(TTC / (1 + TVA / 100), 2).frenchify();
16
- const question = {
17
- answer,
18
- instruction: `Un objet coûte $${TTC.frenchify()}€$ en TTC. Quel est son prix HT, sachant que la TVA est de $${TVA.frenchify()}\\%$ ? (arrondir au centième)`,
19
- keys: [],
20
- answerFormat: "tex",
21
- identifiers: { TTC, TVA },
22
- hint: `Pour retrouver le prix HT d'un objet après une hausse de $t\\%$, on divise le prix TTC par $1 + \\frac{t}{100}$.`,
23
- correction: `Pour retrouver le prix HT après une hausse de $${TVA.frenchify()}\\%$, on divise le prix TTC par :
19
+ return answer;
20
+ };
21
+ const getHint = (identifiers) => {
22
+ return `Pour retrouver le prix HT d'un objet après une hausse de $t\\%$, on divise le prix TTC par $1 + \\frac{t}{100}$.`;
23
+ };
24
+ const getCorrection = (identifiers) => {
25
+ const { TVA, TTC } = identifiers;
26
+ const answer = getAnswer(identifiers);
27
+ return `Pour retrouver le prix HT après une hausse de $${TVA.frenchify()}\\%$, on divise le prix TTC par :
24
28
 
25
29
  $$
26
30
  1 + \\frac{${TVA.frenchify()}}{100} = ${(0, round_1.round)(1 + TVA / 100, 3).frenchify()}
@@ -31,7 +35,20 @@ Le prix HT est donc :
31
35
  $$
32
36
  ${TTC.frenchify()} \\div ${(0, round_1.round)(1 + TVA / 100, 3).frenchify()} \\approx ${answer}
33
37
  $$
34
- `,
38
+ `;
39
+ };
40
+ const getTtcToHtQuestion = () => {
41
+ const TVA = (0, random_1.random)([20, 5.5]);
42
+ const TTC = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(50, 1000) : (0, randfloat_1.randfloat)(20, 200, 2);
43
+ const identifiers = { TTC, TVA };
44
+ const question = {
45
+ answer: getAnswer(identifiers),
46
+ instruction: getInstruction(identifiers),
47
+ keys: [],
48
+ answerFormat: "tex",
49
+ identifiers,
50
+ hint: getHint(identifiers),
51
+ correction: getCorrection(identifiers),
35
52
  };
36
53
  return question;
37
54
  };
@@ -62,4 +79,8 @@ exports.ttcToHT = {
62
79
  isAnswerValid,
63
80
  subject: "Mathématiques",
64
81
  hasHintAndCorrection: true,
82
+ getInstruction,
83
+ getCorrection,
84
+ getHint,
85
+ getAnswer,
65
86
  };
@@ -1 +1 @@
1
- {"version":3,"file":"geometricExplicitFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA8DF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAe/D,CAAC"}
1
+ {"version":3,"file":"geometricExplicitFormulaUsage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricExplicitFormulaUsage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAyFF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAoB/D,CAAC"}
@@ -10,40 +10,66 @@ const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
10
10
  const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
11
11
  const alignTex_1 = require("../../../../utils/latex/alignTex");
12
12
  const shuffle_1 = require("../../../../utils/alea/shuffle");
13
+ const latexParser_1 = require("../../../../tree/parsers/latexParser");
14
+ const getInstruction = (identifiers) => {
15
+ const { firstValue, reason, askedRank } = identifiers;
16
+ const formula = new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(firstValue), new powerNode_1.PowerNode(new numberNode_1.NumberNode(reason), new variableNode_1.VariableNode("n")));
17
+ const formulaTex = formula.toTex();
18
+ return `$(u_n)$ est une suite géométrique définie par $u_n = ${formulaTex}$. Calculer : $u_{${askedRank}}$`;
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { firstValue, reason, askedRank } = identifiers;
22
+ const answer = (firstValue * Math.pow(reason, askedRank)).toString();
23
+ return answer;
24
+ };
25
+ const getHint = (identifiers) => {
26
+ const { askedRank } = identifiers;
27
+ return `Il suffit de remplacer $n$ par $${askedRank}$ dans la formule donnée.`;
28
+ };
29
+ const getCorrection = (identifiers) => {
30
+ const { firstValue, reason, askedRank } = identifiers;
31
+ const answer = getAnswer(identifiers);
32
+ return `On remplace $n$ par $${askedRank}$ dans la formule donnée :
33
+
34
+ ${(0, alignTex_1.alignTex)([
35
+ [
36
+ `u_{${askedRank}}`,
37
+ "=",
38
+ new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(firstValue), new powerNode_1.PowerNode(new numberNode_1.NumberNode(reason), askedRank.toTree())).toTex(),
39
+ ],
40
+ ["", "=", answer],
41
+ ])}`;
42
+ };
43
+ const getKeys = () => {
44
+ return [];
45
+ };
13
46
  const getGeometricExplicitFormulaUsage = () => {
14
47
  const askedRank = (0, randint_1.randint)(0, 10);
15
48
  const firstValue = (0, randint_1.randint)(-5, 10, [0]);
16
49
  const reason = (0, randint_1.randint)(2, 10);
17
- const formula = new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(firstValue), new powerNode_1.PowerNode(new numberNode_1.NumberNode(reason), new variableNode_1.VariableNode("n")));
18
- const formulaTex = formula.toTex();
19
- const answer = (firstValue * Math.pow(reason, askedRank)).toString();
50
+ const identifiers = { firstValue, reason, askedRank };
20
51
  const question = {
21
- instruction: `$(u_n)$ est une suite géométrique définie par $u_n = ${formulaTex}$. Calculer : $u_{${askedRank}}$`,
52
+ instruction: getInstruction(identifiers),
22
53
  startStatement: `u_{${askedRank}}`,
23
- answer,
24
- keys: ["u", "underscore", "equal"],
54
+ answer: getAnswer(identifiers),
55
+ keys: getKeys(identifiers),
25
56
  answerFormat: "tex",
26
- identifiers: { firstValue, reason, askedRank },
27
- hint: `Il suffit de remplacer $n$ par $${askedRank}$ dans la formule donnée.`,
28
- correction: `On remplace $n$ par $${askedRank}$ dans la formule donnée :
29
-
30
- ${(0, alignTex_1.alignTex)([
31
- [
32
- `u_{${askedRank}}`,
33
- "=",
34
- new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(firstValue), new powerNode_1.PowerNode(new numberNode_1.NumberNode(reason), askedRank.toTree())).toTex(),
35
- ],
36
- ["", "=", answer],
37
- ])}`,
57
+ identifiers,
58
+ hint: getHint(identifiers),
59
+ correction: getCorrection(identifiers),
38
60
  };
39
61
  return question;
40
62
  };
41
63
  const isAnswerValid = (ans, { answer, askedRank }) => {
42
- return [
43
- answer,
44
- `u_{${askedRank}}=${answer}`,
45
- `u_${askedRank}=${answer}`,
46
- ].includes(ans);
64
+ try {
65
+ const parsed = (0, latexParser_1.parseAlgebraic)(ans);
66
+ if (!parsed)
67
+ return false;
68
+ return parsed.simplify().toTex() === answer;
69
+ }
70
+ catch (err) {
71
+ return false;
72
+ }
47
73
  };
48
74
  const getPropositions = (n, { answer, firstValue, reason, askedRank }) => {
49
75
  const propositions = [];
@@ -67,4 +93,9 @@ exports.geometricExplicitFormulaUsage = {
67
93
  isAnswerValid,
68
94
  subject: "Mathématiques",
69
95
  hasHintAndCorrection: true,
96
+ getInstruction,
97
+ getAnswer,
98
+ getHint,
99
+ getCorrection,
100
+ getKeys,
70
101
  };
package/lib/index.d.ts CHANGED
@@ -80,6 +80,9 @@ declare const mathExercises: (Exercise<{
80
80
  denom2: number;
81
81
  }, {}> | Exercise<{
82
82
  statementIdentifiers: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
83
+ }, {}> | Exercise<{
84
+ num: number;
85
+ denum: number;
83
86
  }, {}> | Exercise<{
84
87
  numbers: number[];
85
88
  }, {}> | Exercise<{
@@ -313,6 +316,11 @@ declare const mathExercises: (Exercise<{
313
316
  }> | Exercise<{
314
317
  a: number;
315
318
  b: number;
319
+ c?: number | undefined;
320
+ type: number;
321
+ }, {}> | Exercise<{
322
+ a: number;
323
+ b: number;
316
324
  }, {}> | Exercise<{
317
325
  a: number;
318
326
  b: number;
@@ -1323,6 +1331,11 @@ declare const mathExercises: (Exercise<{
1323
1331
  }, {}> | Exercise<{
1324
1332
  vd: number;
1325
1333
  percentRate: number;
1334
+ }, {}> | Exercise<{
1335
+ type: number;
1336
+ price: number;
1337
+ evolution: number;
1338
+ askingFinalPrice: boolean;
1326
1339
  }, {}> | Exercise<{
1327
1340
  int: number;
1328
1341
  power: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AA0DA,eAAO,MAAM,UAAU,YAWtB,CAAC"}
1
+ {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AA0DA,eAAO,MAAM,UAAU,YAAW,CAAC"}
package/lib/playground.js CHANGED
@@ -2,18 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.playground = void 0;
4
4
  const nodeConstructor_1 = require("./tree/nodes/nodeConstructor");
5
- const playground = () => {
6
- // const formated = "\\sqrt{5;4}";
7
- // const elements = formated.split(";").map((e) => {
8
- // console.log(e);
9
- // const r = parseAlgebraic(e);
10
- // console.log(r.toTex());
11
- // return r;
12
- // });
13
- // console.log(elements.map((e) => e.toTex()));
14
- // const p = parseAlgebraic("\\sqrt{3");
15
- // console.log(p.toTex());
16
- };
5
+ const playground = () => { };
17
6
  exports.playground = playground;
18
7
  const logIdentifiers = () => {
19
8
  const ids = '{"xA":-3,"yA":-2,"yPrimeA":{"id":31,"child":{"id":3,"leftChild":{"id":7,"value":3},"rightChild":{"id":7,"value":2}}},"trinomCoeffs":[0.3888888888888889,0.833333333333333,-3]}';
@@ -1 +1 @@
1
- {"version":3,"file":"oppositeNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/functions/oppositeNode.ts"],"names":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CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAGxD"}
@@ -82,7 +82,7 @@ class OppositeNode {
82
82
  }
83
83
  simplify(opts) {
84
84
  if ((0, numberNode_1.isNumberNode)(this.child))
85
- return new numberNode_1.NumberNode(-this.child.value);
85
+ return new numberNode_1.NumberNode(-this.child.value).simplify(opts);
86
86
  return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(-1), this.child).simplify(opts);
87
87
  }
88
88
  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,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,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAKrD,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,IAAI,MACZ,aAAa,GAAG,MAAM,GAAG,MAAM,KAC/B,aAAa,GAAG,MAAM,GAAG,MAAM,SAC3B,WAAW,iBAOnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC;AACF,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,SA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uBAAuB,GAAG;IACpC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC;AACF,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;IAiBpB,YAAY,IAAI,MAAM;IAItB,aAAa,IAAI,uBAAuB;IAQxC,UAAU;IAGV,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IA+BpC,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAG5C,SAAS;IAUT,KAAK,IAAI,MAAM;IA2Bf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAkN/C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAOxD,sBAAsB;IAQtB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAGxD"}
@@ -218,7 +218,8 @@ class FractionNode {
218
218
  }
219
219
  if (opts?.forceIsolateMonomCoeffs && (0, numberNode_1.isNumberNode)(denum)) {
220
220
  if ((0, variableNode_1.isVariableNode)(num)) {
221
- return new multiplyNode_1.MultiplyNode(new FractionNode(new numberNode_1.NumberNode(1), denum), num).simplify(opts);
221
+ //!do not simplify elsewise infinite loop
222
+ return new multiplyNode_1.MultiplyNode(new FractionNode(new numberNode_1.NumberNode(1), denum), num);
222
223
  }
223
224
  // if (isMultiplyNode(num)) {
224
225
  // if (isVariableNode(num.leftChild)) {
@@ -1 +1 @@
1
- {"version":3,"file":"discreteSetParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/discreteSetParser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAY,MAAM,+BAA+B,CAAC;AAI1E,eAAO,MAAM,iBAAiB,QAAS,MAAM,4BAqB5C,CAAC"}
1
+ {"version":3,"file":"discreteSetParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/discreteSetParser.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAY,MAAM,+BAA+B,CAAC;AAI1E,eAAO,MAAM,iBAAiB,QAAS,MAAM,4BAmB5C,CAAC"}
@@ -15,9 +15,7 @@ const discreteSetParser = (str) => {
15
15
  if (formated === "\\varnothing") {
16
16
  return discreteSetNode_1.EmptySet;
17
17
  }
18
- console.log(formated);
19
18
  const elements = formated.split(";").map((e) => (0, latexParser_1.parseAlgebraic)(e));
20
- console.log(elements.map((e) => e.toTex()));
21
19
  if (elements.some((e) => !e))
22
20
  return false;
23
21
  return new discreteSetNode_1.DiscreteSetNode(elements);
@@ -1 +1 @@
1
- {"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAMzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AA6DrE,eAAO,MAAM,QAAQ,UAAW,MAAM,aA2CrC,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AACF,eAAO,MAAM,cAAc,UAAW,MAAM,SAAS,aAAa,kBAyBjE,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,+CA2CvC,CAAC"}
1
+ {"version":3,"file":"latexParser.d.ts","sourceRoot":"","sources":["../../../src/tree/parsers/latexParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAMzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAgErE,eAAO,MAAM,QAAQ,UAAW,MAAM,aA2CrC,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AACF,eAAO,MAAM,cAAc,UAAW,MAAM,SAAS,aAAa,kBA0BjE,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,MAAM,+CA6CvC,CAAC"}
@@ -41,7 +41,11 @@ const separators = ["=", "<", ">", "\\leq", "\\geq"];
41
41
  //le nombre de parentheses est il respecté
42
42
  const isDyck = (tokens) => {
43
43
  const brackets = tokens.filter((el) => el === "(" || el === ")");
44
+ let counter = 0;
44
45
  while (brackets.length) {
46
+ counter++;
47
+ if (counter > 1000)
48
+ throw Error("Too many iterations");
45
49
  const rightIndex = brackets.findIndex((el) => el == ")");
46
50
  if (rightIndex === -1 || rightIndex === 0)
47
51
  return false;
@@ -103,6 +107,7 @@ const tokenize = (latex) => {
103
107
  };
104
108
  exports.tokenize = tokenize;
105
109
  const parseAlgebraic = (latex, opts) => {
110
+ // console.log("parsingAlg ", latex);
106
111
  let formatedLatex = latex;
107
112
  if (!opts?.allowStartingPower && latex.startsWith("^")) {
108
113
  if (latex[1] === "{") {
@@ -133,6 +138,7 @@ const parseAlgebraic = (latex, opts) => {
133
138
  };
134
139
  exports.parseAlgebraic = parseAlgebraic;
135
140
  const parseLatex = (latex) => {
141
+ // console.log("parsingLatex ", latex);
136
142
  const formattedLatex = latex
137
143
  .replaceAll("\\left", "")
138
144
  .replaceAll("\\right", "");
@@ -204,12 +210,18 @@ const buildTree = (tokens) => {
204
210
  //? -> itération 1 : [{3, 0}, {exp, 0}, {x, 1}, {^, 1}, {NumberNode(2), 1}]
205
211
  //? -> itération 2 : [{3, 0}, {exp, 0}, {SquareNode(x), 1}]
206
212
  //? -> itération 3 : Multiply(3, ExpNode(SquareNode(x)))
213
+ let counter = 0;
207
214
  while (true) {
215
+ counter++;
216
+ if (counter > 1000)
217
+ throw Error("Too many iterations");
208
218
  if (maxDepth === 0) {
209
219
  const tree = buildTreeForSameDepthTokens(depthedTokens.map((el) => el.token));
210
220
  return tree;
211
221
  }
212
222
  for (let i = 0; i < depthedTokens.length; i++) {
223
+ if (i > 1000)
224
+ throw Error("Too many iterations");
213
225
  const token = depthedTokens[i];
214
226
  //? on commence par les tokens de depth max
215
227
  if (token.depth < maxDepth)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.2.93",
3
+ "version": "2.2.94",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [