math-exercises 2.2.89 → 2.2.91

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 (77) hide show
  1. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +13 -6
  2. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
  3. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +68 -68
  4. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
  5. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.js +59 -22
  6. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
  7. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +65 -34
  8. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
  9. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.js +54 -22
  10. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
  11. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +35 -15
  12. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.d.ts.map +1 -1
  13. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquation.js +51 -29
  14. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.d.ts.map +1 -1
  15. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.js +48 -21
  16. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.d.ts.map +1 -1
  17. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.js +44 -22
  18. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.d.ts.map +1 -1
  19. package/lib/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.js +22 -8
  20. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  21. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +27 -16
  22. package/lib/exercises/math/combinatory/ballsCounting.d.ts.map +1 -1
  23. package/lib/exercises/math/combinatory/ballsCounting.js +44 -18
  24. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts +0 -4
  25. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -1
  26. package/lib/exercises/math/functions/affines/affineAdjustment.js +27 -27
  27. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts +0 -5
  28. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -1
  29. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +45 -62
  30. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts +0 -1
  31. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -1
  32. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +32 -48
  33. package/lib/exercises/math/functions/affines/signFunction.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/affines/signFunction.js +3 -0
  35. package/lib/exercises/math/matrices/productCell.js +1 -1
  36. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  37. package/lib/exercises/math/probaStat/stats1var/interquartilesList.js +1 -1
  38. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +1 -1
  39. package/lib/exercises/math/probaStat/stats1var/standardDeviationList.js +2 -2
  40. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +2 -2
  41. package/lib/exercises/math/probaStat/stats1var/varianceList.js +1 -1
  42. package/lib/exercises/math/probaStat/stats1var/varianceTable.js +1 -1
  43. package/lib/index.d.ts +0 -10
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/math/geometry/CloudPoints.js +2 -2
  46. package/lib/math/probability/binomial.js +1 -1
  47. package/lib/math/utils/round.d.ts.map +1 -1
  48. package/lib/math/utils/round.js +19 -5
  49. package/lib/math/utils/stats/covariance.d.ts +4 -0
  50. package/lib/math/utils/stats/covariance.d.ts.map +1 -0
  51. package/lib/math/utils/stats/covariance.js +26 -0
  52. package/lib/math/utils/stats/generateAffineCloud.d.ts +5 -0
  53. package/lib/math/utils/stats/generateAffineCloud.d.ts.map +1 -0
  54. package/lib/math/utils/stats/generateAffineCloud.js +23 -0
  55. package/lib/math/utils/stats/leastSquares.d.ts +5 -0
  56. package/lib/math/utils/stats/leastSquares.d.ts.map +1 -0
  57. package/lib/math/utils/stats/leastSquares.js +19 -0
  58. package/lib/math/utils/stats/quartiles.d.ts +3 -0
  59. package/lib/math/utils/stats/quartiles.d.ts.map +1 -0
  60. package/lib/math/utils/stats/quartiles.js +47 -0
  61. package/lib/math/utils/stats/rSquared.d.ts +2 -0
  62. package/lib/math/utils/stats/rSquared.d.ts.map +1 -0
  63. package/lib/math/utils/stats/rSquared.js +17 -0
  64. package/lib/math/utils/stats/standardDeviation.d.ts +3 -0
  65. package/lib/math/utils/stats/standardDeviation.d.ts.map +1 -0
  66. package/lib/math/utils/stats/standardDeviation.js +13 -0
  67. package/lib/math/utils/stats/sum.d.ts +8 -0
  68. package/lib/math/utils/stats/sum.d.ts.map +1 -0
  69. package/lib/math/utils/stats/sum.js +17 -0
  70. package/lib/math/utils/stats/variance.d.ts +5 -0
  71. package/lib/math/utils/stats/variance.d.ts.map +1 -0
  72. package/lib/math/utils/stats/variance.js +35 -0
  73. package/lib/playground.d.ts.map +1 -1
  74. package/lib/tree/nodes/operators/limitNode.d.ts +1 -1
  75. package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -1
  76. package/lib/tree/parsers/discreteSetParser.js +3 -0
  77. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAclC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
1
+ {"version":3,"file":"firstDegreeEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAelC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA4FF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}
@@ -7,41 +7,63 @@ const equationKeys_1 = require("../../../../exercises/utils/keys/equationKeys");
7
7
  const rational_1 = require("../../../../math/numbers/rationals/rational");
8
8
  const randint_1 = require("../../../../math/utils/random/randint");
9
9
  const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
10
- const equationSolutionNode_1 = require("../../../../tree/nodes/equations/equationSolutionNode");
11
10
  const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
12
11
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
13
- const discreteSetNode_1 = require("../../../../tree/nodes/sets/discreteSetNode");
14
12
  const alignTex_1 = require("../../../../utils/latex/alignTex");
15
13
  const shuffle_1 = require("../../../../utils/alea/shuffle");
16
- const getFirstDegreeEquation = () => {
17
- const a = (0, randint_1.randint)(-30, 30, [0]);
18
- const b = (0, randint_1.randint)(-30, 30, [0]);
14
+ const equationVEA_1 = require("../../../../exercises/vea/equationVEA");
15
+ const getInstruction = (identifiers) => {
16
+ const { a, b } = identifiers;
17
+ const frac = new fractionNode_1.FractionNode(a.toTree(), "x".toTree());
18
+ const statement = new equalNode_1.EqualNode(frac, b.toTree()).toTex();
19
+ return `Résoudre l'équation suivante :
20
+
21
+ $$
22
+ ${statement}
23
+ $$`;
24
+ };
25
+ const getHint = (identifiers) => {
26
+ return `Multiplie les deux côtés de l'équation par $x$, puis isole $x$ dans la partie droite de l'équation.`;
27
+ };
28
+ const getAnswer = (identifiers) => {
29
+ const { a, b } = identifiers;
19
30
  const answer = `x=${new rational_1.Rational(a, b).simplify().toTree().toTex()}`;
31
+ return answer;
32
+ };
33
+ const getCorrection = (identifiers) => {
34
+ const { a, b } = identifiers;
20
35
  const frac = new fractionNode_1.FractionNode(a.toTree(), "x".toTree());
21
36
  const statement = new equalNode_1.EqualNode(frac, b.toTree()).toTex();
37
+ const answer = getAnswer(identifiers);
38
+ return `On multiplie les deux côtés de l'équation par $x$, puis on divise par $${b}$ :
39
+
40
+ ${(0, alignTex_1.alignTex)([
41
+ ["", `${statement}`],
42
+ [
43
+ "\\iff",
44
+ new equalNode_1.EqualNode(new multiplyNode_1.MultiplyNode("x".toTree(), frac), new multiplyNode_1.MultiplyNode("x".toTree(), b.toTree())).toTex(),
45
+ ],
46
+ [
47
+ "\\iff",
48
+ new equalNode_1.EqualNode(a.toTree(), new multiplyNode_1.MultiplyNode(b.toTree(), "x".toTree())).toTex(),
49
+ ],
50
+ ["\\iff", answer],
51
+ ])}
52
+ `;
53
+ };
54
+ const getFirstDegreeEquation = () => {
55
+ const a = (0, randint_1.randint)(-30, 30, [0]);
56
+ const b = (0, randint_1.randint)(-30, 30, [0]);
57
+ const identifiers = { a, b };
22
58
  const question = {
23
- instruction: `Résoudre l'équation suivante : $${statement}$`,
59
+ instruction: getInstruction(identifiers),
24
60
  startStatement: `x`,
25
- answer,
61
+ answer: getAnswer(identifiers),
26
62
  keys: equationKeys_1.equationKeys,
27
63
  answerFormat: "tex",
28
- identifiers: { a, b },
29
- hint: `Multiplie les deux côtés de l'équation par $x$, puis isole $x$ dans la partie droite de l'équation.`,
30
- correction: `On multiplie les deux côtés de l'équation par $x$, puis on divise par $b$ :
31
-
32
- ${(0, alignTex_1.alignTex)([
33
- ["", `${statement}`],
34
- [
35
- "\\iff",
36
- new equalNode_1.EqualNode(new multiplyNode_1.MultiplyNode("x".toTree(), frac), new multiplyNode_1.MultiplyNode("x".toTree(), b.toTree())).toTex(),
37
- ],
38
- [
39
- "\\iff",
40
- new equalNode_1.EqualNode(a.toTree(), new multiplyNode_1.MultiplyNode(b.toTree(), "x".toTree())).toTex(),
41
- ],
42
- ["\\iff", answer],
43
- ])}
44
- `,
64
+ identifiers,
65
+ hint: getHint(identifiers),
66
+ correction: getCorrection(identifiers),
45
67
  };
46
68
  return question;
47
69
  };
@@ -59,11 +81,7 @@ const getPropositions = (n, { answer, a, b }) => {
59
81
  };
60
82
  const isAnswerValid = (ans, { a, b }) => {
61
83
  const solution = new rational_1.Rational(a, b).simplify().toTree();
62
- const answerTree = new equationSolutionNode_1.EquationSolutionNode(new discreteSetNode_1.DiscreteSetNode([solution]), {
63
- opts: { allowFractionToDecimal: true, allowRawRightChildAsSolution: true },
64
- });
65
- const validLatexs = answerTree.toAllValidTexs();
66
- return validLatexs.includes(ans);
84
+ return (0, equationVEA_1.equationVEA)(ans, solution.toTex());
67
85
  };
68
86
  exports.firstDegreeEquation = {
69
87
  id: "firstDegreeEquation",
@@ -79,4 +97,8 @@ exports.firstDegreeEquation = {
79
97
  isAnswerValid,
80
98
  subject: "Mathématiques",
81
99
  hasHintAndCorrection: true,
100
+ getHint,
101
+ getInstruction,
102
+ getCorrection,
103
+ getAnswer,
82
104
  };
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeEquationIntType1.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqFF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAc7D,CAAC"}
1
+ {"version":3,"file":"firstDegreeEquationIntType1.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA+GF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAkB7D,CAAC"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.firstDegreeEquationIntType1 = void 0;
4
4
  const exercise_1 = require("../../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const equationVEA_1 = require("../../../../exercises/vea/equationVEA");
6
7
  const affine_1 = require("../../../../math/polynomials/affine");
7
8
  const randint_1 = require("../../../../math/utils/random/randint");
8
9
  const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
@@ -10,31 +11,55 @@ const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
10
11
  const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
11
12
  const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
12
13
  const alignTex_1 = require("../../../../utils/latex/alignTex");
14
+ const getAnswer = (identifiers) => {
15
+ const { a, b, x } = identifiers;
16
+ const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree()).toTex();
17
+ return answer;
18
+ };
19
+ const getCorrection = (identifiers) => {
20
+ const { a, b, x } = identifiers;
21
+ const answer = getAnswer(identifiers);
22
+ const aMonom = new affine_1.Affine(a, 0).toTree();
23
+ const statementTex = new equalNode_1.EqualNode(aMonom, new numberNode_1.NumberNode(b)).toTex();
24
+ return `Pour isoler $x$ à gauche, on divise les deux côtés de l'équation par $${a}$:
25
+
26
+ ${(0, alignTex_1.alignTex)([
27
+ [
28
+ `${statementTex}`,
29
+ "\\iff",
30
+ new equalNode_1.EqualNode(new fractionNode_1.FractionNode(aMonom, new numberNode_1.NumberNode(a)), new fractionNode_1.FractionNode(b.toTree(), new numberNode_1.NumberNode(a))).toTex(),
31
+ ],
32
+ ["", "\\iff", answer],
33
+ ])}
34
+ `;
35
+ };
36
+ const getInstruction = (identifiers) => {
37
+ const { a, b, x } = identifiers;
38
+ const aMonom = new affine_1.Affine(a, 0).toTree();
39
+ const statementTex = new equalNode_1.EqualNode(aMonom, new numberNode_1.NumberNode(b)).toTex();
40
+ return `Résoudre l'équation suivante :
41
+
42
+ $$
43
+ ${statementTex}
44
+ $$`;
45
+ };
46
+ const getHint = (identifiers) => {
47
+ const { a, b, x } = identifiers;
48
+ return `Il faut isoler $x$ à gauche. Pour cela, effectue l'opération des deux côtés de l'équation qui permet de supprimer la multiplication par $${a}$.`;
49
+ };
13
50
  const getFirstDegreeEquationIntQuestion = () => {
14
51
  const a = (0, randint_1.randint)(-15, 15, [0]);
15
52
  const x = (0, randint_1.randint)(-15, 15, [0]);
16
53
  const b = a * x;
17
- const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree()).toTex();
18
- const aMonom = new affine_1.Affine(a, 0).toTree();
19
- const statementTex = new equalNode_1.EqualNode(aMonom, new numberNode_1.NumberNode(b)).toTex();
54
+ const identifiers = { a: a, x: x, b: b };
20
55
  const question = {
21
- answer: answer,
22
- instruction: `Résoudre l'équation suivante : $${statementTex}$`,
56
+ answer: getAnswer(identifiers),
57
+ instruction: getInstruction(identifiers),
23
58
  keys: ["x", "equal"],
24
59
  answerFormat: "tex",
25
- identifiers: { a: a, x: x, b: b },
26
- hint: `Il faut isoler $x$ à gauche. Pour cela, effectue l'opération des deux côtés de l'équation qui permet de supprimer la multiplication par $${a}$.`,
27
- correction: `Pour isoler $x$ à gauche, on divise les deux côtés de l'équation par $${a}$:
28
-
29
- ${(0, alignTex_1.alignTex)([
30
- [
31
- `${statementTex}`,
32
- "\\iff",
33
- new equalNode_1.EqualNode(new fractionNode_1.FractionNode(aMonom, new numberNode_1.NumberNode(a)), new fractionNode_1.FractionNode(b.toTree(), new numberNode_1.NumberNode(a))).toTex(),
34
- ],
35
- ["", "\\iff", answer],
36
- ])}
37
- `,
60
+ identifiers,
61
+ hint: getHint(identifiers),
62
+ correction: getCorrection(identifiers),
38
63
  };
39
64
  return question;
40
65
  };
@@ -64,9 +89,7 @@ const getPropositions = (n, { answer, a, b }) => {
64
89
  return (0, exercise_1.shuffleProps)(propositions, n);
65
90
  };
66
91
  const isAnswerValid = (ans, { answer, x }) => {
67
- const ans1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree());
68
- const latexs = ans1.toAllValidTexs({ allowRawRightChildAsSolution: true });
69
- return latexs.includes(ans);
92
+ return (0, equationVEA_1.equationVEA)(ans, answer.split("=")[1]);
70
93
  };
71
94
  exports.firstDegreeEquationIntType1 = {
72
95
  id: "firstDegreeEquationIntType1",
@@ -81,4 +104,8 @@ exports.firstDegreeEquationIntType1 = {
81
104
  isAnswerValid,
82
105
  subject: "Mathématiques",
83
106
  hasHintAndCorrection: true,
107
+ getHint,
108
+ getInstruction,
109
+ getCorrection,
110
+ getAnswer,
84
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeEquationIntType2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8FF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAc7D,CAAC"}
1
+ {"version":3,"file":"firstDegreeEquationIntType2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8HF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAc7D,CAAC"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.firstDegreeEquationIntType2 = void 0;
4
4
  const exercise_1 = require("../../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const equationVEA_1 = require("../../../../exercises/vea/equationVEA");
6
7
  const randint_1 = require("../../../../math/utils/random/randint");
7
8
  const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
8
9
  const addNode_1 = require("../../../../tree/nodes/operators/addNode");
@@ -10,33 +11,56 @@ const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
10
11
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
11
12
  const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
12
13
  const alignTex_1 = require("../../../../utils/latex/alignTex");
14
+ const getInstruction = (identifiers) => {
15
+ const { a, b, c, x } = identifiers;
16
+ const equation = new equalNode_1.EqualNode(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), b.toTree()).simplify({ forbidFactorize: true }), c.toTree());
17
+ const statementTex = equation.toTex();
18
+ return `Résoudre l'équation suivante :
19
+
20
+ $$
21
+ ${statementTex}
22
+ $$`;
23
+ };
24
+ const getHint = (identifiers) => {
25
+ return "Isolez le terme $x$ dans la partie gauche de l'équation.";
26
+ };
27
+ const getCorrection = (identifiers) => {
28
+ const { a, b, c, x } = identifiers;
29
+ const equation = new equalNode_1.EqualNode(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), b.toTree()).simplify({ forbidFactorize: true }), c.toTree());
30
+ const statementTex = equation.toTex();
31
+ const answer = getAnswer(identifiers);
32
+ return `Commencer par soustraire $${b}$ des deux côtés de l'équation pour
33
+ l'éliminer du côté gauche. Ensuite, diviser les deux côtés de l'équation par
34
+ $${a}$ pour isoler $x$, ce qui donne :
35
+
36
+ ${(0, alignTex_1.alignTex)([
37
+ [
38
+ statementTex,
39
+ "\\iff",
40
+ new equalNode_1.EqualNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), (c - b).toTree()).toTex(),
41
+ ],
42
+ ["", "\\iff", answer],
43
+ ])}`;
44
+ };
45
+ const getAnswer = (identifiers) => {
46
+ const { a, b, c, x } = identifiers;
47
+ const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree()).toTex();
48
+ return answer;
49
+ };
13
50
  const getFirstDegreeEquationIntQuestion = () => {
14
51
  const a = (0, randint_1.randint)(-15, 15, [0, 1]);
15
52
  const x = (0, randint_1.randint)(-15, 15, [0]);
16
53
  const c = (0, randint_1.randint)(-15, 15, [0, a * x]);
17
54
  const b = c - a * x;
18
- const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree()).toTex();
19
- const equation = new equalNode_1.EqualNode(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), b.toTree()).simplify({ forbidFactorize: true }), c.toTree());
20
- const statementTex = equation.toTex();
55
+ const identifiers = { a, b, c, x };
21
56
  const question = {
22
- answer: answer,
23
- instruction: `Résoudre l'équation suivante : $${statementTex}$`,
57
+ answer: getAnswer(identifiers),
58
+ instruction: getInstruction(identifiers),
24
59
  keys: ["x", "equal"],
25
60
  answerFormat: "tex",
26
- identifiers: { a: a, x: x, c: c, b: b },
27
- hint: "Isolez le terme $x$ dans la partie gauche de l'équation.",
28
- correction: `Commencer par soustraire $${b}$ des deux côtés de l'équation pour
29
- l'éliminer du côté gauche. Ensuite, diviser les deux côtés de l'équation par
30
- $${a}$ pour isoler $x$, ce qui donne :
31
-
32
- ${(0, alignTex_1.alignTex)([
33
- [
34
- statementTex,
35
- "\\iff",
36
- new equalNode_1.EqualNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), (c - b).toTree()).toTex(),
37
- ],
38
- ["", "\\iff", answer],
39
- ])}`,
61
+ identifiers,
62
+ hint: getHint(identifiers),
63
+ correction: getCorrection(identifiers),
40
64
  };
41
65
  return question;
42
66
  };
@@ -68,9 +92,7 @@ const getPropositions = (n, { answer, a, b, c }) => {
68
92
  return (0, exercise_1.shuffleProps)(propositions, n);
69
93
  };
70
94
  const isAnswerValid = (ans, { answer, x }) => {
71
- const ans1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree());
72
- const latexs = ans1.toAllValidTexs({ allowRawRightChildAsSolution: true });
73
- return latexs.includes(ans);
95
+ return (0, equationVEA_1.equationVEA)(ans, x.toTree().toTex());
74
96
  };
75
97
  exports.firstDegreeEquationIntType2 = {
76
98
  id: "firstDegreeEquationIntType2",
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeEquationIntType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsFF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAa7D,CAAC"}
1
+ {"version":3,"file":"firstDegreeEquationIntType3.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/firstDegreeEquationIntType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAUlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmGF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAe7D,CAAC"}
@@ -3,26 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.firstDegreeEquationIntType3 = void 0;
4
4
  const exercise_1 = require("../../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const equationVEA_1 = require("../../../../exercises/vea/equationVEA");
6
7
  const randint_1 = require("../../../../math/utils/random/randint");
7
8
  const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
8
9
  const addNode_1 = require("../../../../tree/nodes/operators/addNode");
9
10
  const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
10
11
  const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
11
12
  const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
13
+ const getInstruction = (identifiers) => {
14
+ const { a, b, c, d, x } = identifiers;
15
+ const equation = new equalNode_1.EqualNode(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), b.toTree()).simplify({ forbidFactorize: true }), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(c.toTree(), new variableNode_1.VariableNode("x")), d.toTree()).simplify({ forbidFactorize: true }));
16
+ return `Résoudre l'équation suivante :
17
+
18
+ $$
19
+ ${equation.toTex()}
20
+ $$`;
21
+ };
22
+ const getAnswer = (identifiers) => {
23
+ const { a, b, c, d, x } = identifiers;
24
+ const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree()).toTex();
25
+ return answer;
26
+ };
12
27
  const getFirstDegreeEquationIntQuestion = () => {
13
28
  const a = (0, randint_1.randint)(-15, 15, [0]);
14
29
  const x = (0, randint_1.randint)(-15, 15, [0]);
15
30
  const c = (0, randint_1.randint)(-15, 15, [0, a]);
16
31
  const d = (0, randint_1.randint)(-15, 15, [0]);
17
32
  const b = d - (a - c) * x;
18
- const answer = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree()).toTex();
19
- const equation = new equalNode_1.EqualNode(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(a.toTree(), new variableNode_1.VariableNode("x")), b.toTree()).simplify({ forbidFactorize: true }), new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(c.toTree(), new variableNode_1.VariableNode("x")), d.toTree()).simplify({ forbidFactorize: true }));
33
+ const identifiers = { a: a, x: x, b: b, c: c, d: d };
20
34
  const question = {
21
- answer: answer,
22
- instruction: `Résoudre l'équation suivante : $${equation.toTex()}$`,
35
+ answer: getAnswer(identifiers),
36
+ instruction: getInstruction(identifiers),
23
37
  keys: ["x", "equal"],
24
38
  answerFormat: "tex",
25
- identifiers: { a: a, x: x, b: b, c: c, d: d },
39
+ identifiers,
26
40
  };
27
41
  return question;
28
42
  };
@@ -59,9 +73,7 @@ const getPropositions = (n, { answer, a, b, c, d }) => {
59
73
  return (0, exercise_1.shuffleProps)(propositions, n);
60
74
  };
61
75
  const isAnswerValid = (ans, { answer, x }) => {
62
- const ans1 = new equalNode_1.EqualNode(new variableNode_1.VariableNode("x"), x.toTree());
63
- const latexs = ans1.toAllValidTexs({ allowRawRightChildAsSolution: true });
64
- return latexs.includes(ans);
76
+ return (0, equationVEA_1.equationVEA)(ans, x.toTree().toTex());
65
77
  };
66
78
  exports.firstDegreeEquationIntType3 = {
67
79
  id: "firstDegreeEquationIntType3",
@@ -75,4 +87,6 @@ exports.firstDegreeEquationIntType3 = {
75
87
  getPropositions,
76
88
  isAnswerValid,
77
89
  subject: "Mathématiques",
90
+ getInstruction,
91
+ getAnswer,
78
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"factoType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType1Exercise.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAclC;;;GAGG;AACH,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAoJF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
1
+ {"version":3,"file":"factoType1Exercise.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/factorisation/factoType1Exercise.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAkBlC;;;GAGG;AACH,KAAK,WAAW,GAAG;IACjB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAiKF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAapD,CAAC"}
@@ -14,7 +14,6 @@ const substractNode_1 = require("../../../../tree/nodes/operators/substractNode"
14
14
  const latexParser_1 = require("../../../../tree/parsers/latexParser");
15
15
  const random_1 = require("../../../../utils/alea/random");
16
16
  const shuffle_1 = require("../../../../utils/alea/shuffle");
17
- //TODO fix { "affinesCoeffs": [ [ -2, 8 ], [ -5, 4 ], [ 0, -8 ] ], "operation": "substract" } donne trop de moins
18
17
  const getStatementNode = (identifiers) => {
19
18
  const { affinesCoeffs, operation } = identifiers;
20
19
  const affines = affinesCoeffs.map((coeffs) => new affine_1.Affine(coeffs[1], coeffs[0]));
@@ -37,15 +36,16 @@ $$`;
37
36
  };
38
37
  const getAnswer = (identifiers) => {
39
38
  const { affinesCoeffs, operation } = identifiers;
40
- const affine1 = new affine_1.Affine(affinesCoeffs[0][1], affinesCoeffs[0][0]);
41
- const affine2 = new affine_1.Affine(affinesCoeffs[1][1], affinesCoeffs[1][0]);
42
- const answerTree = affine2.coefficients[0] === 0
43
- ? affine1.coefficients[0] === 0
44
- ? affine1.multiply(affine2).toTree()
45
- : new multiplyNode_1.MultiplyNode(affine2.toTree(), affine1.toTree())
46
- : new multiplyNode_1.MultiplyNode(affine1.toTree(), affine2.toTree());
47
- const answer = answerTree.simplify().toTex();
48
- return answer;
39
+ const factor = new affine_1.Affine(affinesCoeffs[0][1], affinesCoeffs[0][0]);
40
+ const affine2 = new affine_1.Affine(affinesCoeffs[2][1], affinesCoeffs[2][0]);
41
+ const affine1 = new affine_1.Affine(affinesCoeffs[1][1], affinesCoeffs[1][0]);
42
+ const secondTerm = (operation === "add"
43
+ ? (0, addNode_1.add)(affine1.toTree(), affine2.toTree())
44
+ : (0, substractNode_1.substract)(affine1.toTree(), affine2.toTree())).simplify({ forbidFactorize: true, towardsDistribute: true });
45
+ const sol = (0, multiplyNode_1.multiply)(factor.toTree(), secondTerm).simplify({
46
+ forbidFactorize: true,
47
+ });
48
+ return sol.toTex();
49
49
  };
50
50
  const getFactoType1Question = () => {
51
51
  const a = (0, randint_1.randint)(-9, 10, [0]);
@@ -58,7 +58,11 @@ const getFactoType1Question = () => {
58
58
  d = (0, randint_1.randint)(-9, 10, [0]);
59
59
  e = (0, randint_1.randint)(-9, 10, [0]);
60
60
  f = (0, randint_1.randint)(-9, 10, [0]);
61
- } while (c / a === d / b || e / a === f / b);
61
+ } while (c / a === d / b ||
62
+ e / a === f / b ||
63
+ //éviter un multiple +-1
64
+ (operation === "add" && f === -d && Math.abs(e + c) === 1) ||
65
+ (operation === "substract" && f === d && Math.abs(e - c) === 1));
62
66
  const identifiers = {
63
67
  affinesCoeffs: [
64
68
  [a, b],
@@ -96,16 +100,23 @@ const getPropositions = (n, { answer, affinesCoeffs, operation }) => {
96
100
  }
97
101
  return (0, shuffle_1.shuffle)(propositions);
98
102
  };
99
- const isAnswerValid = (ans, { affinesCoeffs, operation, answer }) => {
103
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
100
104
  try {
105
+ console.log(ans, answer, identifiers);
101
106
  const parsed = (0, latexParser_1.parseAlgebraic)(ans);
102
107
  if (!parsed)
103
108
  return false;
104
- if (!(0, multiplyNode_1.isMultiplyNode)(parsed))
109
+ if (answer !== "0" && !(0, multiplyNode_1.isMultiplyNode)(parsed))
105
110
  return false;
106
- const simp = parsed.simplify();
107
- const reversed = parsed.toReversed().simplify();
108
- return simp.toTex() === answer || reversed.toTex() === answer;
111
+ const simp = parsed.simplify({
112
+ forbidFactorize: true,
113
+ towardsDistribute: true,
114
+ });
115
+ const answerSimp = getStatementNode(identifiers).simplify({
116
+ towardsDistribute: true,
117
+ forbidFactorize: true,
118
+ });
119
+ return simp.toTex() === answerSimp.toTex();
109
120
  }
110
121
  catch (err) {
111
122
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"ballsCounting.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/combinatory/ballsCounting.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAIlC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAsHF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAa/C,CAAC"}
1
+ {"version":3,"file":"ballsCounting.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/combinatory/ballsCounting.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAIlC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAiJF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAe/C,CAAC"}
@@ -4,54 +4,78 @@ exports.ballsCounting = void 0;
4
4
  const exercise_1 = require("../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
6
  const randint_1 = require("../../../math/utils/random/randint");
7
- const getBallsCountingQuestion = () => {
8
- const type = (0, randint_1.randint)(0, 6);
9
- let instruction = "";
7
+ const getAnswer = (identifiers) => {
8
+ const { reds, greens, blacks, type } = identifiers;
10
9
  let answer = "";
11
- const blacks = (0, randint_1.randint)(2, 6);
12
- const greens = (0, randint_1.randint)(2, 6);
13
- const reds = (0, randint_1.randint)(3, 6);
14
10
  const total = blacks + greens + reds;
15
11
  switch (type) {
16
12
  case 0:
17
- instruction = ``;
18
13
  answer = total * (total - 1) * (total - 2) + "";
19
14
  break;
20
15
  case 1:
21
- instruction = `comportant trois boules rouges`;
22
16
  answer = reds * (reds - 1) * (reds - 2) + "";
23
17
  break;
24
18
  case 2:
25
- instruction = `ne comportant pas de boule noire`;
26
19
  answer = (reds + greens) * (reds + greens - 1) * (reds + greens - 2) + "";
27
20
  break;
28
21
  case 3:
29
- instruction = `comportant au moins une boule noire`;
30
22
  answer =
31
23
  total * (total - 1) * (total - 2) -
32
24
  (reds + greens) * (reds + greens - 1) * (reds + greens - 2) +
33
25
  "";
34
26
  break;
35
27
  case 4:
36
- instruction = `comportant trois boules de trois couleurs différentes`;
37
28
  answer = 6 * (blacks * greens * reds) + "";
38
29
  break;
39
30
  case 5:
40
- instruction = `comportant exactement une boule verte et deux boules noires`;
41
31
  answer = 3 * (greens * blacks * (blacks - 1)) + "";
42
32
  break;
43
33
  case 6:
44
- instruction = `comportant exactement une boule verte`;
45
34
  answer = 3 * greens * (reds + blacks) * (reds + blacks - 1) + "";
46
35
  }
47
- const question = {
48
- answer: answer,
49
- instruction: `Une urne contient $${blacks}$ boules noires numérotées de $1$ à $${blacks}$, $${reds}$ boules rouges numérotées de $1$ à $${reds}$ et $${greens}$ boules vertes numérotées de $1$ à $${greens}$.
36
+ return answer;
37
+ };
38
+ const getInstruction = (identifiers) => {
39
+ const { reds, greens, blacks, type } = identifiers;
40
+ let instruction = "";
41
+ switch (type) {
42
+ case 0:
43
+ instruction = ``;
44
+ break;
45
+ case 1:
46
+ instruction = `comportant trois boules rouges`;
47
+ break;
48
+ case 2:
49
+ instruction = `ne comportant pas de boule noire`;
50
+ break;
51
+ case 3:
52
+ instruction = `comportant au moins une boule noire`;
53
+ break;
54
+ case 4:
55
+ instruction = `comportant trois boules de trois couleurs différentes`;
56
+ break;
57
+ case 5:
58
+ instruction = `comportant exactement une boule verte et deux boules noires`;
59
+ break;
60
+ case 6:
61
+ instruction = `comportant exactement une boule verte`;
62
+ }
63
+ return `Une urne contient $${blacks}$ boules noires numérotées de $1$ à $${blacks}$, $${reds}$ boules rouges numérotées de $1$ à $${reds}$ et $${greens}$ boules vertes numérotées de $1$ à $${greens}$.
50
64
  On tire successivement et sans remise $3$ boules dans l'urne.
51
- Combien de tirages ${instruction} sont possibles ?`,
65
+ Combien de tirages ${instruction} sont possibles ?`;
66
+ };
67
+ const getBallsCountingQuestion = () => {
68
+ const type = (0, randint_1.randint)(0, 6);
69
+ const blacks = (0, randint_1.randint)(2, 6);
70
+ const greens = (0, randint_1.randint)(2, 6);
71
+ const reds = (0, randint_1.randint)(3, 6);
72
+ const identifiers = { type, reds, greens, blacks };
73
+ const question = {
74
+ answer: getAnswer(identifiers),
75
+ instruction: getInstruction(identifiers),
52
76
  keys: [],
53
77
  answerFormat: "tex",
54
- identifiers: { type, reds, greens, blacks },
78
+ identifiers,
55
79
  };
56
80
  return question;
57
81
  };
@@ -110,4 +134,6 @@ exports.ballsCounting = {
110
134
  getPropositions,
111
135
  isAnswerValid,
112
136
  subject: "Mathématiques",
137
+ getAnswer,
138
+ getInstruction,
113
139
  };
@@ -1,9 +1,5 @@
1
1
  import { Exercise } from "../../../../exercises/exercise";
2
2
  type Identifiers = {
3
- G1x: number;
4
- G2x: number;
5
- G2y: number;
6
- G1y: number;
7
3
  xValues: number[];
8
4
  yValues: number[];
9
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"affineAdjustment.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAgBlC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA6JF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAe1D,CAAC"}
1
+ {"version":3,"file":"affineAdjustment.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/affineAdjustment.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAkBlC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAyJF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAgB1D,CAAC"}