math-exercises 3.0.146 → 3.0.148

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 (69) hide show
  1. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.js +1 -1
  2. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts +1 -0
  3. package/lib/exercises/math/calcul/mentalCaluls/index.d.ts.map +1 -1
  4. package/lib/exercises/math/calcul/mentalCaluls/index.js +1 -0
  5. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSub.js +28 -4
  7. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSubNoRelative.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/mentalCaluls/mentalAddAndSubNoRelative.js +50 -23
  9. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.d.ts +9 -0
  10. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.d.ts.map +1 -0
  11. package/lib/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.js +423 -0
  12. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/mentalCaluls/mentalMultiplications.js +48 -24
  14. package/lib/exercises/math/calcul/mentalCaluls/mentalPercentage.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/mentalCaluls/mentalPercentage.js +236 -22
  16. package/lib/exercises/math/calcul/operations/operationsPriorities.d.ts.map +1 -1
  17. package/lib/exercises/math/calcul/operations/operationsPriorities.js +48 -20
  18. package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.d.ts.map +1 -1
  19. package/lib/exercises/math/calcul/operations/operationsPrioritiesParenthesis.js +47 -19
  20. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
  21. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +26 -6
  22. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.d.ts.map +1 -1
  23. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.js +92 -16
  24. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts.map +1 -1
  25. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.js +1 -0
  26. package/lib/exercises/math/conversion/volumeCapacityConversion.d.ts.map +1 -1
  27. package/lib/exercises/math/conversion/volumeCapacityConversion.js +171 -0
  28. package/lib/exercises/math/dataRepresentations/barChartReading.d.ts.map +1 -1
  29. package/lib/exercises/math/dataRepresentations/barChartReading.js +17 -8
  30. package/lib/exercises/math/dataRepresentations/functionGraphReading.d.ts.map +1 -1
  31. package/lib/exercises/math/dataRepresentations/functionGraphReading.js +94 -8
  32. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts +6 -1
  33. package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/affines/affineExpressionReading.js +166 -52
  35. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.d.ts +5 -1
  36. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.d.ts.map +1 -1
  37. package/lib/exercises/math/functions/affines/drawAffineFromLitExp.js +59 -17
  38. package/lib/exercises/math/functions/basics/graphicInequation.js +1 -1
  39. package/lib/exercises/math/functions/index.d.ts +1 -0
  40. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  41. package/lib/exercises/math/functions/index.js +1 -0
  42. package/lib/exercises/math/functions/linear/index.d.ts +3 -0
  43. package/lib/exercises/math/functions/linear/index.d.ts.map +1 -0
  44. package/lib/exercises/math/functions/linear/index.js +2 -0
  45. package/lib/exercises/math/functions/linear/linearFromExercise.d.ts +9 -0
  46. package/lib/exercises/math/functions/linear/linearFromExercise.d.ts.map +1 -0
  47. package/lib/exercises/math/functions/linear/linearFromExercise.js +354 -0
  48. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.d.ts +8 -0
  49. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.d.ts.map +1 -0
  50. package/lib/exercises/math/functions/linear/linearFromPercentageEvolution.js +233 -0
  51. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.d.ts.map +1 -1
  52. package/lib/exercises/math/functions/trinoms/devForm/coefficientsIdentification.js +2 -5
  53. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.d.ts +22 -0
  54. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.d.ts.map +1 -0
  55. package/lib/exercises/math/geometry/thales/thalesIsParallelFromAbstractFormula.js +647 -0
  56. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.d.ts +23 -0
  57. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.d.ts.map +1 -0
  58. package/lib/exercises/math/geometry/thales/thalesPickFormulaForIsParallel.js +540 -0
  59. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.d.ts.map +1 -1
  60. package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesInPrism.js +75 -6
  61. package/lib/index.d.ts +22 -3
  62. package/lib/index.d.ts.map +1 -1
  63. package/lib/tree/nodes/equations/notEqualNode.d.ts +35 -0
  64. package/lib/tree/nodes/equations/notEqualNode.d.ts.map +1 -0
  65. package/lib/tree/nodes/equations/notEqualNode.js +84 -0
  66. package/lib/tree/utilities/nodeSimplifier.d.ts +16 -0
  67. package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -0
  68. package/lib/tree/utilities/nodeSimplifier.js +283 -0
  69. package/package.json +1 -1
@@ -26,7 +26,7 @@ const getInstruction = (identifiers) => {
26
26
  return `Une bibliothèque possède $${total}$ livres à stocker dans des boîtes. Chaque boîte doit contenir $${divisor}$ livres. Combien de livres resteront hors des boîtes ?`;
27
27
  case 2: {
28
28
  const pre = randomFirstname();
29
- return `${pre.name} possède $${total}$ billes. ${pre.isFeminine ? "Elle" : "Il"} veux remplir des tubes de $${divisor}$ billes chacun. Combien de billes ne seront pas dans un tube ?`;
29
+ return `${pre.name} possède $${total}$ billes. ${pre.isFeminine ? "Elle" : "Il"} veut remplir des tubes de $${divisor}$ billes chacun. Combien de billes ne seront pas dans un tube ?`;
30
30
  }
31
31
  case 3:
32
32
  return `Un magasin reçoit $${total}$ cartes promotionnelles. Il veut les regrouper en paquets de $${divisor}$ cartes. Combien de cartes ne seront pas dans un paquet ?`;
@@ -7,4 +7,5 @@ export * from "./mentalMultiplicationsNoRelative.js";
7
7
  export * from "./mentalProgramSolve.js";
8
8
  export * from "./mentalFractionageOfInteger.js";
9
9
  export * from "./mentalFractionageOfQuantity.js";
10
+ export * from "./mentalApplyPercentageEvolution.js";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC"}
@@ -7,3 +7,4 @@ export * from "./mentalMultiplicationsNoRelative.js";
7
7
  export * from "./mentalProgramSolve.js";
8
8
  export * from "./mentalFractionageOfInteger.js";
9
9
  export * from "./mentalFractionageOfQuantity.js";
10
+ export * from "./mentalApplyPercentageEvolution.js";
@@ -1 +1 @@
1
- {"version":3,"file":"mentalAddAndSub.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalAddAndSub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAyHF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAajD,CAAC"}
1
+ {"version":3,"file":"mentalAddAndSub.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalAddAndSub.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAmJF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAejD,CAAC"}
@@ -3,10 +3,12 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
5
  import { round } from "../../../../math/utils/round.js";
6
- import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
7
+ import { NodeSimplifier } from "../../../../tree/utilities/nodeSimplifier.js";
7
8
  import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
8
9
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
9
10
  import { shuffle } from "../../../../utils/alea/shuffle.js";
11
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
10
12
  const getInstruction = (identifiers) => {
11
13
  return `Calculer :
12
14
 
@@ -53,6 +55,26 @@ const getAnswer = (identifiers) => {
53
55
  // .join("\n \n")}
54
56
  // Le résultat est donc $${getAnswer(identifiers)}$.`;
55
57
  // };
58
+ const getHint = () => {
59
+ return `Il n'y a que des additions et/ou des soustractions :
60
+ Tu peux effectuer les calculs de gauche à droite.`;
61
+ };
62
+ const getCorrection = (identifiers) => {
63
+ const { numbers } = identifiers;
64
+ const node = numbers
65
+ .slice(1)
66
+ .reduce((acc, n) => add(acc, round(n, 2)), numbers[0].toTree());
67
+ const arrTexNodeStepByStep = NodeSimplifier.arrTexStepByStep(node);
68
+ return `Il n'y a que des additions et/ou des soustractions :
69
+ On va effectuer les calculs de gauche à droite.
70
+
71
+ ${alignTex([
72
+ [node.toTex(), "=", arrTexNodeStepByStep[0]],
73
+ ...arrTexNodeStepByStep.slice(1).map((tex) => ["", "=", tex]),
74
+ ])}
75
+
76
+ `;
77
+ };
56
78
  const getQuestionFromIdentifiers = (identifiers) => {
57
79
  const question = {
58
80
  instruction: getInstruction(identifiers),
@@ -61,8 +83,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
61
83
  keys: [],
62
84
  answerFormat: "tex",
63
85
  identifiers,
64
- // hint: getHint(identifiers),
65
- // correction: getCorrection(identifiers),
86
+ hint: getHint(identifiers),
87
+ correction: getCorrection(identifiers),
66
88
  };
67
89
  return question;
68
90
  };
@@ -112,5 +134,7 @@ export const mentalAddAndSub = {
112
134
  isAnswerValid,
113
135
  subject: "Mathématiques",
114
136
  getQuestionFromIdentifiers,
115
- // hasHintAndCorrection: true,
137
+ getHint,
138
+ getCorrection,
139
+ hasHintAndCorrection: true,
116
140
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mentalAddAndSubNoRelative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalAddAndSubNoRelative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA4FF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAa3D,CAAC"}
1
+ {"version":3,"file":"mentalAddAndSubNoRelative.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalAddAndSubNoRelative.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAwHF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAgB3D,CAAC"}
@@ -5,7 +5,9 @@ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
5
  import { randint } from "../../../../math/utils/random/randint.js";
6
6
  import { round } from "../../../../math/utils/round.js";
7
7
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
8
- import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
9
+ import { NodeSimplifier } from "../../../../tree/utilities/nodeSimplifier.js";
10
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
9
11
  const getInstruction = (identifiers) => {
10
12
  return `Calculer :
11
13
 
@@ -28,16 +30,38 @@ const getStartStatement = (identifiers) => {
28
30
  }
29
31
  return statementTree.toTex();
30
32
  };
31
- const getQuestionFromIdentifiers = (identifiers) => {
32
- const question = {
33
- answer: getAnswer(identifiers),
34
- instruction: getInstruction(identifiers),
35
- startStatement: getStartStatement(identifiers),
36
- keys: [],
37
- answerFormat: "tex",
38
- identifiers,
39
- };
40
- return question;
33
+ const getHint = () => {
34
+ return `Il n'y a que des additions et/ou des soustractions :
35
+ Tu peux effectuer les calculs de gauche à droite.`;
36
+ };
37
+ const getCorrection = (identifiers) => {
38
+ const { numbers } = identifiers;
39
+ const node = numbers
40
+ .slice(1)
41
+ .reduce((acc, n) => add(acc, round(n, 2)), numbers[0].toTree());
42
+ const arrTexNodeStepByStep = NodeSimplifier.arrTexStepByStep(node);
43
+ return `Il n'y a que des additions et/ou des soustractions :
44
+ On va effectuer les calculs de gauche à droite.
45
+
46
+ ${alignTex([
47
+ [node.toTex(), "=", arrTexNodeStepByStep[0]],
48
+ ...arrTexNodeStepByStep.slice(1).map((tex) => ["", "=", tex]),
49
+ ])}
50
+
51
+ `;
52
+ };
53
+ const getPropositions = (n, { answer }) => {
54
+ const propositions = [];
55
+ addValidProp(propositions, answer);
56
+ const answerNb = answer.unfrenchify();
57
+ propWhile(propositions, n, () => {
58
+ const incorrectAnswer = round(answerNb + Math.max(-answerNb, randfloat(-5, 6, randint(1, 3), [0])), 2);
59
+ tryToAddWrongProp(propositions, incorrectAnswer.frenchify());
60
+ });
61
+ return shuffleProps(propositions, n);
62
+ };
63
+ const isAnswerValid = (ans, { answer }) => {
64
+ return numberVEA(ans, answer);
41
65
  };
42
66
  const getMentalAddAndSubNoRelativeQuestion = () => {
43
67
  let answer = -1;
@@ -63,18 +87,18 @@ const getMentalAddAndSubNoRelativeQuestion = () => {
63
87
  const identifiers = { numbers };
64
88
  return getQuestionFromIdentifiers(identifiers);
65
89
  };
66
- const getPropositions = (n, { answer }) => {
67
- const propositions = [];
68
- addValidProp(propositions, answer);
69
- const answerNb = answer.unfrenchify();
70
- propWhile(propositions, n, () => {
71
- const incorrectAnswer = round(answerNb + Math.max(-answerNb, randfloat(-5, 6, randint(1, 3), [0])), 2);
72
- tryToAddWrongProp(propositions, incorrectAnswer.frenchify());
73
- });
74
- return shuffleProps(propositions, n);
75
- };
76
- const isAnswerValid = (ans, { answer }) => {
77
- return numberVEA(ans, answer);
90
+ const getQuestionFromIdentifiers = (identifiers) => {
91
+ const question = {
92
+ answer: getAnswer(identifiers),
93
+ instruction: getInstruction(identifiers),
94
+ startStatement: getStartStatement(identifiers),
95
+ keys: [],
96
+ answerFormat: "tex",
97
+ identifiers,
98
+ hint: getHint(identifiers),
99
+ correction: getCorrection(identifiers),
100
+ };
101
+ return question;
78
102
  };
79
103
  export const mentalAddAndSubNoRelative = {
80
104
  id: "mentalAddAndSubNoRelative",
@@ -88,4 +112,7 @@ export const mentalAddAndSubNoRelative = {
88
112
  isAnswerValid,
89
113
  subject: "Mathématiques",
90
114
  getQuestionFromIdentifiers,
115
+ getHint,
116
+ getCorrection,
117
+ hasHintAndCorrection: true,
91
118
  };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ rand: number;
4
+ a: number;
5
+ b: number;
6
+ };
7
+ export declare const mentalApplyPercentageEvolution: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=mentalApplyPercentageEvolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentalApplyPercentageEvolution.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalApplyPercentageEvolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAycF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAgBhE,CAAC"}
@@ -0,0 +1,423 @@
1
+ import { addValidProp, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
+ import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { round } from "../../../../math/utils/round.js";
6
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
9
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
10
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
11
+ const getInstruction = (identifiers) => {
12
+ const { a, b } = identifiers;
13
+ const offset = a - 100;
14
+ const isAdd = offset > 0;
15
+ return `Appliquer ${isAdd ? "une hausse" : "une baisse"} de $${round(Math.abs(offset), 1).frenchify()}\\%$ à $${b}$.`;
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { a, b } = identifiers;
19
+ const answer = ((a * b) / 100).frenchify();
20
+ return answer;
21
+ };
22
+ const getHint = () => {
23
+ return `Voici deux façons de procéder :
24
+
25
+ - en ajoutant la hausse ou la perte
26
+
27
+ - en multipliant par le taux d'évolution
28
+
29
+ `;
30
+ };
31
+ const getCorrection = (identifiers) => {
32
+ const { rand, a, b } = identifiers;
33
+ const offset = a - 100;
34
+ const isAdd = offset > 0;
35
+ const texAbsOffset = multiply(frac(Math.abs(offset), 100), b)
36
+ .simplify({ fractionsToDecimal: true })
37
+ .toTex();
38
+ const texAnswer = getAnswer(identifiers);
39
+ function strCorrectionOffset() {
40
+ const a = Math.abs(offset);
41
+ switch (rand) {
42
+ case 1: // 10% de 70%
43
+ return `
44
+
45
+ ${alignTex([
46
+ [
47
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
48
+ "=",
49
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
50
+ ],
51
+ ["", "=", `${texAbsOffset}`],
52
+ ])}
53
+
54
+ $\\ \\ \\ $donc la valeur recherchée est :
55
+
56
+ $$
57
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
58
+ $$
59
+
60
+ `;
61
+ case 2: // 30% de 9
62
+ return `
63
+
64
+ $$
65
+ ${a.frenchify()}\\% \\times ${b.frenchify()} = \\frac{${a.frenchify()}}{100} \\times ${b.frenchify()} = \\frac{1}{10} \\times ${(a / 10).frenchify()} \\times ${b.frenchify()}
66
+ $$
67
+
68
+ Or :
69
+
70
+ $$
71
+ ${(a / 10).frenchify()} \\times ${b.frenchify()} = ${((a / 10) * b).frenchify()}
72
+ $$
73
+
74
+ Donc :
75
+
76
+ $$
77
+ ${a.frenchify()}\\% \\times ${b.frenchify()} = ${texAbsOffset}
78
+ $$
79
+
80
+ $\\ \\ \\ $donc la valeur recherchée est :
81
+
82
+ $$
83
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
84
+ $$
85
+
86
+ `;
87
+ case 3: // 32% de 10
88
+ return `
89
+
90
+ ${alignTex([
91
+ [
92
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
93
+ "=",
94
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
95
+ ],
96
+ ["", "=", `${a.frenchify()} \\times \\frac{${b.frenchify()}}{100}`],
97
+ ["", "=", `${a.frenchify()} \\times \\frac{${(b / 10).frenchify()}}{10}`],
98
+ ["", "=", `${texAbsOffset}`],
99
+ ])}
100
+
101
+ $\\ \\ \\ $donc la valeur recherchée est :
102
+
103
+ $$
104
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
105
+ $$
106
+
107
+ `;
108
+ case 4: {
109
+ // 14% de 50 ou 230% de 20
110
+ return `
111
+
112
+ ${alignTex([
113
+ [
114
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
115
+ "=",
116
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
117
+ ],
118
+ ["", "=", `${texAbsOffset}`],
119
+ ])}
120
+
121
+ $\\ \\ \\ $donc la valeur recherchée est :
122
+
123
+ $$
124
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
125
+ $$
126
+
127
+ `;
128
+ }
129
+ case 5: // 12.5% de 72
130
+ if (a === 12.5) {
131
+ return `
132
+
133
+ ${alignTex([
134
+ [
135
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
136
+ "=",
137
+ `\\frac{1}{8} \\times ${b.frenchify()}`,
138
+ ],
139
+ ["", "=", `${(b / 8).frenchify()}`],
140
+ ["", "=", `${texAbsOffset}`],
141
+ ])}
142
+
143
+ $\\ \\ \\ $donc la valeur recherchée est :
144
+
145
+ $$
146
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
147
+ $$
148
+
149
+ `;
150
+ }
151
+ else {
152
+ return `
153
+
154
+ ${alignTex([
155
+ [
156
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
157
+ "=",
158
+ `\\frac{9}{8} \\times ${b.frenchify()}`,
159
+ ],
160
+ ["", "=", `9 \\times ${(b / 8).frenchify()}`],
161
+ ["", "=", `${texAbsOffset}`],
162
+ ])}
163
+
164
+ $\\ \\ \\ $donc la valeur recherchée est :
165
+
166
+ $$
167
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
168
+ $$
169
+
170
+ `;
171
+ }
172
+ case 6: // 15% de 90
173
+ return `
174
+
175
+ ${alignTex([
176
+ [
177
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
178
+ "=",
179
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
180
+ ],
181
+ [
182
+ "",
183
+ "=",
184
+ `\\frac{${a.frenchify()}}{100} \\times ${(b / 10).frenchify()} \\times 10`,
185
+ ],
186
+ ["", "=", `${(a / 10).frenchify()} \\times ${(b / 10).frenchify()}`],
187
+ ["", "=", `${texAbsOffset}`],
188
+ ])}
189
+
190
+ $\\ \\ \\ $donc la valeur recherchée est :
191
+
192
+ $$
193
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
194
+ $$
195
+
196
+ `;
197
+ case 7: // 20% de x
198
+ return `
199
+
200
+ ${alignTex([
201
+ [
202
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
203
+ "=",
204
+ `${(a / 100).frenchify()} \\times ${b.frenchify()}`,
205
+ ],
206
+ ["", "=", `\\frac{${(a / 20).frenchify()}}{5} \\times ${b.frenchify()}`],
207
+ ["", "=", `${(a / 20).frenchify()} \\times \\frac{${b.frenchify()}}{5}`],
208
+ ["", "=", `${texAbsOffset}`],
209
+ ])}
210
+
211
+ $\\ \\ \\ $donc la valeur recherchée est :
212
+
213
+ $$
214
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
215
+ $$
216
+
217
+ `;
218
+ case 8: // 75% de x
219
+ return `
220
+
221
+ ${alignTex([
222
+ [
223
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
224
+ "=",
225
+ `${(a / 25).frenchify()} \\times 25\\% \\times ${b.frenchify()}`,
226
+ ],
227
+ [
228
+ "",
229
+ "=",
230
+ `${(a / 25).frenchify()} \\times \\frac{1}{4} \\times ${b.frenchify()}`,
231
+ ],
232
+ ["", "=", `${(a / 25).frenchify()} \\times ${(b / 4).frenchify()}`],
233
+ ["", "=", `${texAbsOffset}`],
234
+ ])}
235
+
236
+ $\\ \\ \\ $donc la valeur recherchée est :
237
+
238
+ $$
239
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
240
+ $$
241
+
242
+ `;
243
+ case 9: //0.5 % de 1000
244
+ return `
245
+
246
+ ${alignTex([
247
+ [
248
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
249
+ "=",
250
+ `${(a * 10).frenchify()}\\% \\times \\frac{1}{10} \\times 1000`,
251
+ ],
252
+ ["", "=", `${(a * 10).frenchify()}\\% \\times 100`],
253
+ ["", "=", `${texAbsOffset}`],
254
+ ])}
255
+
256
+ $\\ \\ \\ $donc la valeur recherchée est :
257
+
258
+ $$
259
+ ${b.frenchify()} ${isAdd ? "+" : "-"} ${texAbsOffset} = ${texAnswer}
260
+ $$
261
+
262
+ `;
263
+ }
264
+ throw new Error("Unsupported rand: " + rand);
265
+ }
266
+ function strCorrectionFactor() {
267
+ return `
268
+
269
+ ${alignTex([
270
+ [
271
+ `\\left( 100\\% ${isAdd ? "+" : "-"} ${Math.abs(offset).frenchify()}\\% \\right) \\times ${b.frenchify()}`,
272
+ `=`,
273
+ `${a.frenchify()}\\% \\times ${b.frenchify()}`,
274
+ ],
275
+ ["", "=", `${(a / 100).frenchify()} \\times ${b.frenchify()}`],
276
+ ["", "=", `${texAnswer}`],
277
+ ])}
278
+
279
+ `;
280
+ }
281
+ return `Voici deux façons de procéder :
282
+
283
+ - en ajoutant la hausse ou la perte :
284
+
285
+ ${strCorrectionOffset()}
286
+
287
+ - en multipliant par le taux d'évolution :
288
+
289
+ ${strCorrectionFactor()}
290
+
291
+ `;
292
+ };
293
+ const isAnswerValid = (studentAns, { answer }) => {
294
+ return rationalVEA(studentAns, answer, {
295
+ allowNonIrreductible: true,
296
+ allowDecimal: true,
297
+ });
298
+ };
299
+ const getMentalApplyPercentageEvolutionQuestion = () => {
300
+ let a = 1, b = 1;
301
+ const rand = randint(1, 10);
302
+ switch (rand) {
303
+ case 1: // 10% de 70%
304
+ a = 10 * randint(1, 3);
305
+ b = randint(1, 100);
306
+ break;
307
+ case 2: // 30% de 9
308
+ a = randint(1, 10);
309
+ b = randint(1, 5) * a;
310
+ a *= 10;
311
+ break;
312
+ case 3: // 32% de 10
313
+ a = randint(1, 100);
314
+ b = 10 ** randint(1, 3);
315
+ break;
316
+ case 4: // 14% de 50 ou 230% de 20
317
+ a = coinFlip() ? randint(1, 100) : randint(11, 30) * 10;
318
+ b = coinFlip() ? 20 : 50;
319
+ break;
320
+ case 5: // 12.5% de 72
321
+ a = coinFlip() ? 12.5 : 12.5 + 100;
322
+ b = 8 * randint(1, 10);
323
+ break;
324
+ case 6: // 15% de 90
325
+ a = coinFlip() ? 15 * randint(1, 6) : 30 * randint(1, 4, [2]) + 100;
326
+ b = 3 * randint(1, 5) * 10;
327
+ break;
328
+ case 7: // 20% de x
329
+ a = 20 * randint(1, 12, [5]);
330
+ b = 5 * randint(1, 11);
331
+ break;
332
+ case 8: // 75% de x
333
+ a = 25 * randint(1, 8, [4]);
334
+ b = 4 * randint(1, 11);
335
+ break;
336
+ case 9: //0.5 % de 1000
337
+ a = randint(1, 10) / 10;
338
+ b = 1000;
339
+ break;
340
+ }
341
+ const identifiers = { rand, a: 100 + (coinFlip() ? +1 : -1) * a, b };
342
+ return getQuestionFromIdentifiers(identifiers);
343
+ };
344
+ const getPropositions = (n, { answer, rand, a: aFromIds }) => {
345
+ const offset = aFromIds - 100;
346
+ const isAdd = offset > 0;
347
+ const propositions = [];
348
+ addValidProp(propositions, answer);
349
+ let a = 0;
350
+ let b = 0;
351
+ propWhile(propositions, n, () => {
352
+ switch (rand) {
353
+ case 1: // 10% de 70%
354
+ a = 10 * randint(1, 3);
355
+ b = randint(1, 200);
356
+ break;
357
+ case 2: // 30% de 9
358
+ a = randint(1, 10);
359
+ b = randint(1, 10) * a;
360
+ a *= 10;
361
+ break;
362
+ case 3: // 32% de 10
363
+ a = randint(1, 100);
364
+ b = 10 ** randint(1, 3);
365
+ break;
366
+ case 4: // 14% de 50 ou 230% de 20
367
+ a = coinFlip() ? randint(1, 100) : randint(11, 30) * 10;
368
+ b = coinFlip() ? 20 : 50;
369
+ break;
370
+ case 5: // 12.5% de 72
371
+ a = coinFlip() ? 12.5 : 12.5 + 100;
372
+ b = 8 * randint(1, 11);
373
+ break;
374
+ case 6: // 15% de 90
375
+ a = coinFlip() ? 15 * randint(1, 6) : 30 * randint(1, 4, [2]) + 100;
376
+ b = 3 * randint(1, 10) * 10;
377
+ break;
378
+ case 7: // 20% de x
379
+ a = 20 * randint(1, 12, [5]);
380
+ b = 5 * randint(1, 21);
381
+ break;
382
+ case 8: // 75% de x
383
+ a = 25 * randint(1, 8, [4]);
384
+ b = 4 * randint(1, 75);
385
+ break;
386
+ case 9: //0.5 % de 1000
387
+ a = randint(1, 10) / 10;
388
+ b = 1000;
389
+ break;
390
+ }
391
+ const incorrectAnswer = ((100 + (isAdd ? 1 : -1) * a) * b) / 100;
392
+ tryToAddWrongProp(propositions, incorrectAnswer.frenchify());
393
+ });
394
+ return shuffle(propositions);
395
+ };
396
+ const getQuestionFromIdentifiers = (identifiers) => {
397
+ const question = {
398
+ instruction: getInstruction(identifiers),
399
+ hint: getHint(identifiers),
400
+ correction: getCorrection(identifiers),
401
+ answer: getAnswer(identifiers),
402
+ keys: [],
403
+ answerFormat: "tex",
404
+ identifiers,
405
+ };
406
+ return question;
407
+ };
408
+ export const mentalApplyPercentageEvolution = {
409
+ id: "mentalApplyPercentageEvolution",
410
+ connector: "=",
411
+ label: "Appliquer mentalement une évolution en pourcentage",
412
+ isSingleStep: true,
413
+ generator: (nb) => getDistinctQuestions(getMentalApplyPercentageEvolutionQuestion, nb),
414
+ qcmTimer: 60,
415
+ freeTimer: 60,
416
+ getPropositions,
417
+ isAnswerValid,
418
+ subject: "Mathématiques",
419
+ getQuestionFromIdentifiers,
420
+ getHint,
421
+ getCorrection,
422
+ hasHintAndCorrection: true,
423
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"mentalMultiplications.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalMultiplications.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAuFF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAYvD,CAAC"}
1
+ {"version":3,"file":"mentalMultiplications.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/mentalCaluls/mentalMultiplications.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA8GF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAevD,CAAC"}