math-exercises 3.0.126 → 3.0.127

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 (64) hide show
  1. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts +1 -1
  2. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.js +56 -42
  4. package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/ordering/compareABUsingQuotient.js +5 -103
  6. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.js +22 -8
  8. package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/ordering/compareFracAndDec.js +7 -6
  10. package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.d.ts.map +1 -1
  11. package/lib/exercises/math/calcul/ordering/compareWithSquareRoots.js +4 -4
  12. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts.map +1 -1
  13. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.js +57 -17
  14. package/lib/exercises/math/calculLitteral/isolate/isolateUInInvXPlusInvYEqualsInvU.d.ts.map +1 -1
  15. package/lib/exercises/math/calculLitteral/isolate/isolateUInInvXPlusInvYEqualsInvU.js +6 -27
  16. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.d.ts.map +1 -1
  17. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.js +3 -5
  18. package/lib/exercises/math/calculLitteral/ordering/compareFromPiMinusFrac.js +1 -1
  19. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts.map +1 -1
  20. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.js +69 -23
  21. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.d.ts +4 -1
  22. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.d.ts.map +1 -1
  23. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.js +52 -34
  24. package/lib/exercises/math/conversion/prefixToNumber.d.ts.map +1 -1
  25. package/lib/exercises/math/conversion/prefixToNumber.js +14 -4
  26. package/lib/exercises/math/conversion/secondsToHours.js +1 -1
  27. package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts +5 -2
  28. package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -1
  29. package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +47 -31
  30. package/lib/exercises/math/dataRepresentations/cartesianGraphExtremaReading.d.ts.map +1 -1
  31. package/lib/exercises/math/dataRepresentations/cartesianGraphExtremaReading.js +5 -4
  32. package/lib/exercises/math/dataRepresentations/dataToGraphGraphToData.js +4 -4
  33. package/lib/exercises/math/dataRepresentations/graphReading.js +13 -13
  34. package/lib/exercises/math/dataRepresentations/histogramReading.d.ts.map +1 -1
  35. package/lib/exercises/math/dataRepresentations/histogramReading.js +32 -32
  36. package/lib/exercises/math/dataRepresentations/plausibleGraph.d.ts.map +1 -1
  37. package/lib/exercises/math/dataRepresentations/plausibleGraph.js +53 -4
  38. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.d.ts.map +1 -1
  39. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.js +17 -3
  40. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindY.d.ts.map +1 -1
  41. package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindY.js +27 -9
  42. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts.map +1 -1
  43. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.js +33 -16
  44. package/lib/exercises/math/functions/affines/representationOfAffine.d.ts +3 -0
  45. package/lib/exercises/math/functions/affines/representationOfAffine.d.ts.map +1 -1
  46. package/lib/exercises/math/functions/affines/representationOfAffine.js +121 -30
  47. package/lib/exercises/math/functions/basics/coordsOfPointOnCurveFindY.d.ts.map +1 -1
  48. package/lib/exercises/math/functions/basics/coordsOfPointOnCurveFindY.js +29 -10
  49. package/lib/exercises/math/functions/composition/functionComposition.d.ts.map +1 -1
  50. package/lib/exercises/math/functions/composition/functionComposition.js +2 -2
  51. package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.d.ts.map +1 -1
  52. package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.js +24 -9
  53. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.d.ts.map +1 -1
  54. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.js +9 -5
  55. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts +0 -1
  56. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts.map +1 -1
  57. package/lib/exercises/math/probaStat/probaAsSumOfProbas.js +13 -14
  58. package/lib/exercises/math/probaStat/stats1var/interpretIndicatorsForLists.d.ts.map +1 -1
  59. package/lib/exercises/math/probaStat/stats1var/interpretIndicatorsForLists.js +2 -3
  60. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.d.ts.map +1 -1
  61. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.js +26 -25
  62. package/lib/index.d.ts +10 -5
  63. package/lib/index.d.ts.map +1 -1
  64. package/package.json +1 -1
@@ -6,7 +6,7 @@ type Identifiers = {
6
6
  progCalcIds: ProgCalcIdentifiers;
7
7
  };
8
8
  type Options = {
9
- numberType: "Integer" | "Decimal";
9
+ numberType: "Entier" | "Décimal";
10
10
  nbSteps: number;
11
11
  nbDigits: number;
12
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mentalProgramSolve.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalProgramSolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAI7C,OAAO,EAEL,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AA2BzC,KAAK,WAAW,GAAG;IACjB,qBAAqB,EAAE,eAAe,CAAC;IACvC,WAAW,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAoMF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,SAAS,GAAG,SAAS,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAiCF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAyB7D,CAAC"}
1
+ {"version":3,"file":"mentalProgramSolve.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalProgramSolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAGL,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAgCzC,KAAK,WAAW,GAAG;IACjB,qBAAqB,EAAE,eAAe,CAAC;IACvC,WAAW,EAAE,mBAAmB,CAAC;CAClC,CAAC;AA8MF,KAAK,OAAO,GAAG;IACb,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAiCF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CA0B7D,CAAC"}
@@ -2,22 +2,27 @@ import { addValidProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType,
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
4
  import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
5
- import { randomMany } from "../../../../utils/alea/random.js";
6
5
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
7
6
  import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
8
- import { ProgCalcConstructor, } from "../../../../math/progCalc/progCalc.js";
9
- import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
+ import { ProgCalc, ProgCalcConstructor, } from "../../../../math/progCalc/progCalc.js";
8
+ import { isAddNode } from "../../../../tree/nodes/operators/addNode.js";
10
9
  import { abs } from "../../../../tree/nodes/functions/absNode.js";
10
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
11
+ import { isOppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
12
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
11
13
  const getStrSolvingStep = (nodeStep) => {
12
14
  //write 10 + (-8) instead of 10 - 8
13
15
  function isNegative(node) {
14
16
  return !abs(node).simplify().equals(node.simplify());
15
17
  }
16
- if (nodeStep instanceof AddNode && isNegative(nodeStep.rightChild)) {
18
+ if (isAddNode(nodeStep) && isNegative(nodeStep.rightChild)) {
17
19
  return `${nodeStep.leftChild.toTex()} + (${nodeStep.rightChild.toTex()}) = ${nodeStep
18
20
  .simplify()
19
21
  .toTex()}`;
20
22
  }
23
+ else if (isOppositeNode(nodeStep)) {
24
+ return `-(${nodeStep.child.toTex()}) = ${nodeStep.simplify().toTex()}`;
25
+ }
21
26
  else {
22
27
  const texL = nodeStep.toTex({
23
28
  allowDoubleMinus: true,
@@ -30,52 +35,61 @@ const getStrSolvingStep = (nodeStep) => {
30
35
  return `${texL} = ${texR}`;
31
36
  }
32
37
  };
33
- const getPropositions = (n, { answer }) => {
38
+ const getPropositions = (n, { answer, progCalcIds, nodeIdsStartingNumber }) => {
34
39
  const propositions = [];
35
40
  addValidProp(propositions, answer);
36
- const nodeFinalNumber = answer.toTree();
37
- const nbWrong = n - 1;
38
- const arrOffset = randomMany([-10, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 10], nbWrong);
39
- for (let i = 0; i < arrOffset.length; i++) {
40
- const offset = arrOffset[i];
41
- tryToAddWrongProp(propositions, add(nodeFinalNumber, offset).simplify().toTex());
41
+ const nodeStartingNumber = NodeConstructor.fromIdentifiers(nodeIdsStartingNumber);
42
+ const progCalc = ProgCalcConstructor.fromIdentifiers(progCalcIds);
43
+ const nodeFinalNumber = progCalc.apply(nodeStartingNumber).simplify();
44
+ //applies progCalc to finalNumber
45
+ tryToAddWrongProp(propositions, progCalc.apply(nodeFinalNumber).simplify().toTex());
46
+ //applies progCalc operations in reverse to finalNumber
47
+ const progCalcReversed = new ProgCalc(progCalc.operations.toReversed());
48
+ tryToAddWrongProp(propositions, progCalcReversed.apply(nodeFinalNumber).simplify().toTex());
49
+ //stops at intermediary step (stops before goal)
50
+ const progCalcInverse = progCalc.getInverseProgCalc();
51
+ const inverseOperations = progCalcInverse.operations;
52
+ const arrStepNodes = [nodeFinalNumber];
53
+ for (let i = 0; i < inverseOperations.length - 1; i++) {
54
+ const nodePrevious = arrStepNodes[arrStepNodes.length - 1].simplify();
55
+ const operation = inverseOperations[i];
56
+ const nodeStep = operation.func(nodePrevious);
57
+ arrStepNodes.push(nodeStep);
42
58
  }
59
+ shuffle(arrStepNodes).forEach((nodeStep) => {
60
+ if (propositions.length < n) {
61
+ tryToAddWrongProp(propositions, nodeStep.simplify().toTex());
62
+ }
63
+ });
43
64
  return shuffleProps(propositions, n);
44
65
  };
45
- const getAnswer = (identifiers) => {
66
+ const getAnswerNode = (identifiers) => {
46
67
  const { nodeIdsStartingNumber } = identifiers;
47
- const nodeStartingNumber = NodeConstructor.fromIdentifiers(nodeIdsStartingNumber);
48
- return nodeStartingNumber.toTex();
68
+ return NodeConstructor.fromIdentifiers(nodeIdsStartingNumber);
69
+ };
70
+ const getAnswer = (identifiers) => {
71
+ return getAnswerNode(identifiers).toTex();
49
72
  };
50
73
  const getInstruction = (identifiers, opts) => {
51
74
  const { nodeIdsStartingNumber, progCalcIds } = identifiers;
52
75
  const nodeStartingNumber = NodeConstructor.fromIdentifiers(nodeIdsStartingNumber);
53
76
  const progCalc = ProgCalcConstructor.fromIdentifiers(progCalcIds);
54
77
  const nodeFinalNumber = progCalc.apply(nodeStartingNumber).simplify();
55
- const strOpening = `Voici un programme de calcul :`;
56
- const strChooseANumber = `Choisir un nombre
57
-
58
- `;
59
- const arrStrProgCalc = progCalc.getArrOfFrenchStrings().map((str) => `
60
-
61
- ${str}`);
62
- const strProgCalc = arrStrProgCalc.reduce((acc, str) => acc + str);
63
- const strFinalNumber = opts?.numberType == "Integer"
78
+ const strFinalNumber = opts?.numberType == "Entier"
64
79
  ? nodeFinalNumber.evaluate().frenchify()
65
80
  : nodeFinalNumber
66
81
  .evaluate()
67
82
  .toFixed(opts?.nbDigits ?? 0)
68
83
  .replace(".", ",");
69
- const strQuestion = `Quel nombre faut-il choisir au départ pour obtenir $ ${strFinalNumber} $ à la fin ?`;
70
- return `
71
- ${strOpening}
84
+ return `Voici un programme de calcul :
72
85
 
73
- ${strChooseANumber}
86
+ > Choisir un nombre
74
87
 
75
- ${strProgCalc}
88
+ ${progCalc.getArrOfFrenchStrings().map((str) => `> ${str}`).join(`
89
+
90
+ `)}
76
91
 
77
- ${strQuestion}
78
- `;
92
+ Quel nombre faut-il choisir au départ pour obtenir $ ${strFinalNumber} $ à la fin ?`;
79
93
  };
80
94
  const getHint = () => {
81
95
  return `Pars du résultat obtenu à la fin et remonte à l'envers en inversant chaque étape.`;
@@ -106,12 +120,10 @@ const getCorrection = (identifiers) => {
106
120
  return `
107
121
  On part de la fin et on remonte à l'envers en inversant chaque étape.
108
122
 
109
- ${arrStrSolvingSteps.map((str) => `
110
-
111
- $$
112
- ${str}
113
- $$
114
- `)}
123
+ ${alignTex(arrStrSolvingSteps.map((str) => {
124
+ const [lhs, rhs] = str.split("=");
125
+ return [lhs, "=", rhs];
126
+ }))}
115
127
 
116
128
  Le nombre choisi au départ était donc $ ${nodeStartingNumber.toTex()} $.`;
117
129
  };
@@ -131,12 +143,13 @@ const getMentalProgramSolveQuestion = (optsIn) => {
131
143
  const opts = optsIn ? Object.assign(optsDefault, optsIn) : optsDefault;
132
144
  let nbDigits = 0;
133
145
  switch (opts.numberType) {
134
- case "Integer":
135
- nbDigits = 0;
136
- break;
137
- case "Decimal":
146
+ case "Décimal":
138
147
  nbDigits = opts.nbDigits ?? 2;
139
148
  break;
149
+ default:
150
+ case "Entier":
151
+ nbDigits = 0;
152
+ break;
140
153
  }
141
154
  const powerOf10 = Math.pow(10, nbDigits);
142
155
  const valueStart = randint(0, 33 * powerOf10, []) / powerOf10;
@@ -161,7 +174,7 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
161
174
  };
162
175
  };
163
176
  const optsDefault = {
164
- numberType: "Integer",
177
+ numberType: "Entier",
165
178
  nbSteps: 4,
166
179
  nbDigits: 0,
167
180
  };
@@ -170,7 +183,7 @@ const options = [
170
183
  id: "numberType",
171
184
  label: "Type de nombres utilisés",
172
185
  defaultValue: optsDefault.numberType,
173
- values: ["Integer", "Decimal"],
186
+ values: ["Entier", "Décimal"],
174
187
  target: GeneratorOptionTarget.generation,
175
188
  type: GeneratorOptionType.select,
176
189
  },
@@ -214,4 +227,5 @@ export const mentalProgramSolve = {
214
227
  getAnswer,
215
228
  getQuestionFromIdentifiers,
216
229
  hasHintAndCorrection: true,
230
+ answerType: "QCU",
217
231
  };
@@ -1 +1 @@
1
- {"version":3,"file":"compareABUsingQuotient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareABUsingQuotient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAe7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,eAAe,EAAE,CAAC;CACnC,CAAC;AAyRF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAiBxD,CAAC"}
1
+ {"version":3,"file":"compareABUsingQuotient.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareABUsingQuotient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,eAAe,EAAE,CAAC;CACnC,CAAC;AA+IF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAiBxD,CAAC"}
@@ -1,73 +1,10 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
- import { abs } from "../../../../tree/nodes/functions/absNode.js";
5
- import { FunctionsIds, isFunctionNode, } from "../../../../tree/nodes/functions/functionNode.js";
6
- import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
7
4
  import { sqrt } from "../../../../tree/nodes/functions/sqrtNode.js";
8
5
  import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
9
6
  import { add } from "../../../../tree/nodes/operators/addNode.js";
10
- import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
11
- import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
12
- import { isOperatorNode, OperatorIds, } from "../../../../tree/nodes/operators/operatorNode.js";
13
- import { power } from "../../../../tree/nodes/operators/powerNode.js";
14
- import { substract } from "../../../../tree/nodes/operators/substractNode.js";
15
- import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
16
7
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
17
- import { shuffle } from "../../../../utils/alea/shuffle.js";
18
- const randomOperatorReplacementDict = () => {
19
- const operatorIds = [
20
- OperatorIds.add,
21
- OperatorIds.multiply,
22
- OperatorIds.fraction,
23
- ];
24
- return Object.fromEntries(shuffle(operatorIds).map((opId, i) => [opId, operatorIds[i]]));
25
- };
26
- const randomFunctionReplacementDict = () => {
27
- const functionIds = [FunctionsIds.sqrt, FunctionsIds.abs];
28
- return Object.fromEntries(shuffle(functionIds).map((fId, i) => [fId, functionIds[i]]));
29
- };
30
- const nodeByReplacingOperations = (node, operatorReplacementDict, functionReplacementDict) => {
31
- if (isOperatorNode(node)) {
32
- const leftChild = nodeByReplacingOperations(node.leftChild, operatorReplacementDict, functionReplacementDict);
33
- const rightChild = nodeByReplacingOperations(node.rightChild, operatorReplacementDict, functionReplacementDict);
34
- const targetOperatorId = operatorReplacementDict[+node.id] ?? node.id;
35
- switch (+targetOperatorId) {
36
- case OperatorIds.add:
37
- return add(leftChild, rightChild);
38
- case OperatorIds.substract:
39
- return substract(leftChild, rightChild);
40
- case OperatorIds.multiply:
41
- return multiply(leftChild, rightChild);
42
- case OperatorIds.divide:
43
- case OperatorIds.fraction:
44
- return frac(leftChild, rightChild);
45
- case OperatorIds.power:
46
- return power(leftChild, rightChild);
47
- default:
48
- return add(leftChild, rightChild);
49
- }
50
- }
51
- else if (isFunctionNode(node)) {
52
- const child = nodeByReplacingOperations(node.child, operatorReplacementDict, functionReplacementDict);
53
- const targetFunctionId = functionReplacementDict[+node.id] ?? node.id;
54
- switch (+targetFunctionId) {
55
- case FunctionsIds.sqrt:
56
- return sqrt(child);
57
- case FunctionsIds.abs:
58
- return abs(child);
59
- case FunctionsIds.opposite:
60
- default:
61
- return opposite(child);
62
- }
63
- }
64
- else {
65
- return node;
66
- }
67
- };
68
- const nodeBySubstitutingX = (node, strVar) => {
69
- return parseAlgebraic(node.toTex().replaceAll("{x}", `"${strVar}"`));
70
- };
71
8
  const getInstruction = (identifiers) => {
72
9
  const { orderedNodeIds } = identifiers;
73
10
  const [A, B] = orderedNodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds).toTex());
@@ -84,13 +21,7 @@ $$
84
21
  \\frac{${B}}{${A}} > 1
85
22
  $$
86
23
 
87
- essaie de te ramener à
88
-
89
- $$
90
- ${B} <(ou >) ${A}
91
- $$
92
-
93
- par des opérations que l'on effectue à droite et à gauche de l'inégalité.`;
24
+ essaye d’isoler chaque expression de chaque côté de l’inégalité.`;
94
25
  };
95
26
  const getCorrection = (identifiers) => {
96
27
  const { orderedNodeIds } = identifiers;
@@ -156,40 +87,11 @@ const getKeys = (identifiers) => {
156
87
  ];
157
88
  };
158
89
  const getCompareABUsingQuotientQuestion = () => {
159
- const nbNodes = 2;
160
90
  const n = randint(2, 150);
161
- const [s, t] = [0, 1].map(() => randint(1, 100));
162
- const refNode = add(s, abs(multiply(t, "{x}")));
163
- let orderedNodesAndEvaluations;
164
- let isValidNodes = false;
165
- while (!isValidNodes) {
166
- const nodeInner = nodeBySubstitutingX(sqrt(add(1, "{x}")), `${n.frenchify()}`);
167
- const nodes = [...Array(nbNodes).keys()].map(() => nodeBySubstitutingX(nodeByReplacingOperations(refNode, randomOperatorReplacementDict(), randomFunctionReplacementDict()), `{${nodeInner.toTex()}}`));
168
- try {
169
- const evaluations = nodes.map((node) => node.evaluate());
170
- //discard impossible
171
- if (evaluations.some((evaluation) => isNaN(evaluation) || evaluation <= 0)) {
172
- isValidNodes = false;
173
- continue;
174
- }
175
- //discard same
176
- if (evaluations.some((evaluation, i) => evaluations.filter((_, j) => j !== i).includes(evaluation))) {
177
- isValidNodes = false;
178
- continue;
179
- }
180
- orderedNodesAndEvaluations = nodes
181
- .map((node, i) => {
182
- return { node, evaluation: evaluations[i] };
183
- })
184
- .toSorted(({ evaluation: evaluation1 }, { evaluation: evaluation2 }) => evaluation1 - evaluation2);
185
- isValidNodes = true;
186
- }
187
- catch (_) {
188
- continue;
189
- }
190
- }
191
- const orderedNodeIds = orderedNodesAndEvaluations.map(({ node }) => node.toIdentifiers());
192
- return getQuestionFromIdentifiers({ orderedNodeIds });
91
+ const orderedNodesIncreasing = [add(1, sqrt(add(1, n))), add(2, sqrt(n))];
92
+ return getQuestionFromIdentifiers({
93
+ orderedNodeIds: orderedNodesIncreasing.map((node) => node.toIdentifiers()),
94
+ });
193
95
  };
194
96
  const getQuestionFromIdentifiers = (identifiers) => {
195
97
  const question = {
@@ -1 +1 @@
1
- {"version":3,"file":"compareFracABWithFracAPlusCBPlusC.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AA8KF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAoBnE,CAAC"}
1
+ {"version":3,"file":"compareFracABWithFracAPlusCBPlusC.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AA4LF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAoBnE,CAAC"}
@@ -4,7 +4,7 @@ import { lcm } from "../../../../math/utils/arithmetic/lcm.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
6
6
  import { add } from "../../../../tree/nodes/operators/addNode.js";
7
- import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
+ import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
8
8
  import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
10
  import { shuffle } from "../../../../utils/alea/shuffle.js";
@@ -19,18 +19,27 @@ const getHint = () => {
19
19
  const getCorrection = (identifiers) => {
20
20
  const { nodeIds } = identifiers;
21
21
  const nodes = nodeIds.map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
22
- const [den1, den2] = nodes.map((node) => node.rightChild);
22
+ const nodesSimplified = nodes.map((node) => node.simplify());
23
+ const [den1, den2] = nodesSimplified.map((nodeSimplified) => {
24
+ return isFractionNode(nodeSimplified)
25
+ ? nodeSimplified.rightChild
26
+ : (1).toTree();
27
+ });
23
28
  const sameDen = lcm(den1.evaluate(), den2.evaluate());
24
- const nodesSameDenMult = nodes.map((node) => frac(multiply(node.leftChild.simplify(), frac(sameDen, node.rightChild).simplify()), sameDen));
25
- const nodesSameDen = nodes.map((node) => frac(multiply(node.leftChild.simplify(), frac(sameDen, node.rightChild)).simplify(), sameDen));
29
+ const nodesSameDenMult = nodesSimplified.map((node) => isFractionNode(node)
30
+ ? frac(multiply(node.leftChild.simplify(), frac(sameDen, node.rightChild).simplify()), multiply(node.rightChild.simplify(), frac(sameDen, node.rightChild).simplify()))
31
+ : frac(multiply(node, sameDen), multiply(1, sameDen)));
32
+ const nodesSameDen = nodes.map((node) => isFractionNode(node)
33
+ ? frac(multiply(node.leftChild.simplify(), frac(sameDen, node.rightChild)).simplify(), sameDen)
34
+ : frac(multiply(node, sameDen).simplify(), sameDen));
26
35
  const answer = getAnswer(identifiers);
27
36
  return `On a :
28
37
 
29
38
  $$
30
- ${nodes[1].toTex()} = ${frac(nodes[1].leftChild.simplify(), nodes[1].rightChild.simplify()).toTex()}
39
+ ${nodes[1].toSimplificationTex()}
31
40
  $$
32
41
 
33
- On veut donc comparer $${nodes[0].toTex()}$ et $${nodes[1].simplify().toTex()}$.
42
+ On veut donc comparer $${nodesSimplified[0].toTex()}$ et $${nodesSimplified[1].toTex()}$.
34
43
 
35
44
  On peut choisir $${sameDen.frenchify()}$ comme dénominateur commun.
36
45
 
@@ -39,7 +48,12 @@ ${nodes
39
48
  ? `
40
49
 
41
50
  $$
42
- ${(i === 0 ? nodes[i] : nodes[i].simplify()).toTex()} = ${nodesSameDenMult[i].toTex()} = ${nodesSameDen[i].toTex()}
51
+ ${(i === 0 ? nodes[i] : nodes[i].simplify()).toTex()} = ${[
52
+ ...new Set([
53
+ nodesSameDenMult[i].toTex(),
54
+ nodesSameDen[i].toTex(),
55
+ ]).values(),
56
+ ].join("=")}
43
57
  $$`
44
58
  : ``)
45
59
  .join("")}
@@ -75,7 +89,7 @@ const isAnswerValid = (ans, { texAnswers }) => {
75
89
  };
76
90
  const getCompareFracABWithFracAPlusCBPlusCQuestion = () => {
77
91
  const a = randint(1, 10);
78
- const b = randint(1, 10);
92
+ const b = randint(1, 10, [a]);
79
93
  const c = randint(1, 10);
80
94
  const nodes = [frac(a, b), frac(add(a, c), add(b, c))];
81
95
  const isOrderAsc = coinFlip();
@@ -1 +1 @@
1
- {"version":3,"file":"compareFracAndDec.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareFracAndDec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3D,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB,CAAC;AAiYF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AA+BF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB5D,CAAC"}
1
+ {"version":3,"file":"compareFracAndDec.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareFracAndDec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3D,KAAK,EAAE,OAAO,EAAE,CAAC;CAClB,CAAC;AAkYF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,OAAO,CAAC;CACpC,CAAC;AA+BF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB5D,CAAC"}
@@ -47,7 +47,7 @@ $$
47
47
  Le classement par ordre décroissant de ces trois nombres est :`;
48
48
  };
49
49
  const getHint = () => {
50
- return `Pour comparer des nombres on peut soit les écrire sous formes décimales
50
+ return `Pour comparer des nombres on peut soit les écrire sous forme décimale
51
51
 
52
52
  soit les mettre au même dénominateur.`;
53
53
  };
@@ -215,7 +215,9 @@ const getCompareFracAndDecQuestion = (optsIn) => {
215
215
  const nodes = {
216
216
  A: frac(a, 5),
217
217
  B: frac(substract(multiply(20, a), b).simplify(), 100),
218
- C: frac(add(multiply(2, a), c).simplify(), 10),
218
+ C: frac(add(multiply(2, a), c).simplify(), 10)
219
+ .evaluate()
220
+ .toTree(),
219
221
  };
220
222
  Object.keys(nodes).forEach((letter) => {
221
223
  nodes[letter] = multiply(sign, nodes[letter]);
@@ -246,8 +248,7 @@ const getCompareFracAndDecQuestion = (optsIn) => {
246
248
  return `
247
249
 
248
250
  $$
249
- ${opts.isUseABC ? `${fakeName} =` : ``}
250
- ${dictIsInDecimalFormat[trueName]
251
+ ${opts.isUseABC ? `${fakeName} =` : ``}${dictIsInDecimalFormat[trueName]
251
252
  ? ``
252
253
  : (() => {
253
254
  if (trueName === "A") {
@@ -322,7 +323,7 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
322
323
  };
323
324
  const optsDefault = {
324
325
  isUseABC: false,
325
- nbDecimalFormat: 0,
326
+ nbDecimalFormat: 1,
326
327
  isAllowingNegativeNumbers: false,
327
328
  };
328
329
  const options = [
@@ -338,7 +339,7 @@ const options = [
338
339
  label: "Nombre d'écritures décimales",
339
340
  target: GeneratorOptionTarget.generation,
340
341
  type: GeneratorOptionType.select,
341
- values: [0, 1, 2],
342
+ values: [1, 2],
342
343
  defaultValue: optsDefault.nbDecimalFormat,
343
344
  },
344
345
  {
@@ -1 +1 @@
1
- {"version":3,"file":"compareWithSquareRoots.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareWithSquareRoots.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAqKF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAgBxD,CAAC"}
1
+ {"version":3,"file":"compareWithSquareRoots.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/ordering/compareWithSquareRoots.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAmKF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAgBxD,CAAC"}
@@ -11,10 +11,10 @@ const getInstruction = (identifiers) => {
11
11
  comparer $${b} ${isAdd ? "+" : "-"} \\sqrt{${a}}$ et $${b} ${isAdd ? "+" : "-"} \\sqrt{${a + 1}}$.`;
12
12
  };
13
13
  const getHint = (identifiers) => {
14
- const { a, b, isAdd } = identifiers;
14
+ const { a } = identifiers;
15
15
  return `En partant de $\\sqrt{${a}} < \\sqrt{${a + 1}}$,
16
16
 
17
- essaie de te ramener à $${b} ${isAdd ? "+" : "-"} \\sqrt{${a}}$ <(ou >) $${b} ${isAdd ? "+" : "-"} \\sqrt{${a + 1}}$
17
+ essaie de te ramener aux expressions demandées
18
18
 
19
19
  par des opérations que l'on effectue à droite et à gauche de l'inégalité.
20
20
 
@@ -22,7 +22,7 @@ Attention si tu multiplies à droite et à gauche d'une inégalité par un nombr
22
22
  };
23
23
  const getCorrection = (identifiers) => {
24
24
  const { a, b, isAdd } = identifiers;
25
- return `
25
+ return `On sait que :
26
26
 
27
27
  $$
28
28
  \\sqrt{${a}} < \\sqrt{${a + 1}}
@@ -80,7 +80,7 @@ const getPropositions = (nbProps, { answer, ...identifiers }) => {
80
80
  const { a, b, isAdd } = identifiers;
81
81
  const propositions = [];
82
82
  addValidProp(propositions, `${b} ${isAdd ? "+" : "-"} \\sqrt{${a}} ${isAdd ? "<" : ">"} ${b} ${isAdd ? "+" : "-"} \\sqrt{${a + 1}}`, "tex");
83
- tryToAddWrongProp(propositions, `${b} ${!isAdd ? "+" : "-"} \\sqrt{${a}} ${!isAdd ? "<" : ">"} ${b} ${!isAdd ? "+" : "-"} \\sqrt{${a + 1}}`, "tex");
83
+ tryToAddWrongProp(propositions, `${b} ${isAdd ? "+" : "-"} \\sqrt{${a}} ${!isAdd ? "<" : ">"} ${b} ${isAdd ? "+" : "-"} \\sqrt{${a + 1}}`, "tex");
84
84
  return shuffleProps(propositions, nbProps);
85
85
  };
86
86
  const getKeys = (identifiers) => {
@@ -1 +1 @@
1
- {"version":3,"file":"equationFromProblem.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationFromProblem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AActE,KAAK,WAAW,GAAG;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,YAAY,EAAE,eAAe,CAAC;CAC/B,CAAC;AA0mBF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAarD,CAAC"}
1
+ {"version":3,"file":"equationFromProblem.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationFromProblem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKlE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAgBtE,KAAK,WAAW,GAAG;IACjB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,YAAY,EAAE,eAAe,CAAC;CAC/B,CAAC;AA6qBF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}