math-exercises 3.0.131 → 3.0.133

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 (109) hide show
  1. package/lib/exercises/exercise.d.ts +37 -30
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts +2 -2
  4. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/mentalCaluls/mentalProgramSolve.js +44 -40
  6. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts +1 -1
  7. package/lib/exercises/math/calcul/ordering/compareA10N.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/ordering/compareA10N.js +15 -10
  9. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/ordering/compareFracABWithFracAPlusCBPlusC.js +0 -1
  11. package/lib/exercises/math/calcul/ordering/compareFracAndDec.d.ts +1 -1
  12. package/lib/exercises/math/calcul/ordering/compareFracAndDec.js +1 -1
  13. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +1 -1
  14. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +2 -0
  16. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.d.ts.map +1 -1
  17. package/lib/exercises/math/calcul/rounding/estimatePow10NPlusPow10MinusN.js +8 -6
  18. package/lib/exercises/math/calcul/rounding/rounding.d.ts +1 -1
  19. package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
  20. package/lib/exercises/math/calcul/rounding/rounding.js +7 -6
  21. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.d.ts.map +1 -1
  22. package/lib/exercises/math/calculLitteral/equation/equationFromProblem.js +8 -9
  23. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.d.ts.map +1 -1
  24. package/lib/exercises/math/calculLitteral/simplifying/compareATimes0.js +4 -4
  25. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.d.ts.map +1 -1
  26. package/lib/exercises/math/calculLitteral/writing/writeLitExpFromFrenchExp.js +15 -60
  27. package/lib/exercises/math/conversion/kmPerMinToKmPerHourConversion.js +14 -10
  28. package/lib/exercises/math/conversion/lengthConversion.d.ts.map +1 -1
  29. package/lib/exercises/math/conversion/lengthConversion.js +1 -0
  30. package/lib/exercises/math/conversion/prefixToNumber.d.ts +0 -2
  31. package/lib/exercises/math/conversion/prefixToNumber.d.ts.map +1 -1
  32. package/lib/exercises/math/conversion/prefixToNumber.js +31 -24
  33. package/lib/exercises/math/conversion/secondsToHours.js +1 -1
  34. package/lib/exercises/math/functions/affines/drawAffineFromPointAndLeadingCoeff.js +2 -2
  35. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts +1 -1
  36. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.d.ts.map +1 -1
  37. package/lib/exercises/math/functions/affines/drawAffineFromProgCalc.js +4 -5
  38. package/lib/exercises/math/functions/affines/leadingCoefficient.js +1 -1
  39. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts +1 -1
  40. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.d.ts.map +1 -1
  41. package/lib/exercises/math/geometry/angles/anglesUsingIsParallel.js +10 -11
  42. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.d.ts +1 -1
  43. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.d.ts.map +1 -1
  44. package/lib/exercises/math/geometry/angles/isParallelUsingAngles.js +8 -8
  45. package/lib/exercises/math/geometry/cartesian/index.d.ts +1 -0
  46. package/lib/exercises/math/geometry/cartesian/index.d.ts.map +1 -1
  47. package/lib/exercises/math/geometry/cartesian/index.js +1 -0
  48. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts +6 -9
  49. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.d.ts.map +1 -1
  50. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLine.js +60 -137
  51. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts +16 -0
  52. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts.map +1 -0
  53. package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.js +213 -0
  54. package/lib/exercises/math/percent/evolutions/globalPercent.d.ts +4 -1
  55. package/lib/exercises/math/percent/evolutions/globalPercent.d.ts.map +1 -1
  56. package/lib/exercises/math/percent/evolutions/globalPercent.js +37 -21
  57. package/lib/exercises/math/percent/findProportion.d.ts.map +1 -1
  58. package/lib/exercises/math/percent/findProportion.js +24 -26
  59. package/lib/exercises/math/percent/percentToDecimal.d.ts +4 -1
  60. package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
  61. package/lib/exercises/math/percent/percentToDecimal.js +55 -35
  62. package/lib/exercises/math/powers/calculateNegativePower.d.ts +1 -1
  63. package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
  64. package/lib/exercises/math/powers/calculateNegativePower.js +17 -10
  65. package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.js +2 -2
  66. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.d.ts +5 -1
  67. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.d.ts.map +1 -1
  68. package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.js +76 -12
  69. package/lib/exercises/math/probaStat/conditionalProbaWriteFromFrench.js +7 -7
  70. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts +2 -3
  71. package/lib/exercises/math/probaStat/probaAsSumOfProbas.d.ts.map +1 -1
  72. package/lib/exercises/math/probaStat/probaAsSumOfProbas.js +60 -95
  73. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts +12 -5
  74. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  75. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +354 -94
  76. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts +4 -1
  77. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
  78. package/lib/exercises/math/probaStat/stats1var/medianWithList.js +43 -23
  79. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.d.ts.map +1 -1
  80. package/lib/exercises/math/probaStat/stats1var/plausibilityOfAverage.js +70 -23
  81. package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts +1 -1
  82. package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts.map +1 -1
  83. package/lib/exercises/math/probaStat/stats1var/quartilesList.js +4 -4
  84. package/lib/exercises/pc/index.d.ts +0 -1
  85. package/lib/exercises/pc/index.d.ts.map +1 -1
  86. package/lib/exercises/pc/index.js +0 -1
  87. package/lib/exercises/pc/motion/averageSpeed.d.ts +0 -2
  88. package/lib/exercises/pc/motion/averageSpeed.d.ts.map +1 -1
  89. package/lib/exercises/pc/motion/averageSpeed.js +40 -45
  90. package/lib/exercises/pc/optics/lensFormula.d.ts +1 -2
  91. package/lib/exercises/pc/optics/lensFormula.d.ts.map +1 -1
  92. package/lib/exercises/pc/optics/lensFormula.js +7 -10
  93. package/lib/exercises/pc/weight/calculateWeight.d.ts +1 -3
  94. package/lib/exercises/pc/weight/calculateWeight.d.ts.map +1 -1
  95. package/lib/exercises/pc/weight/calculateWeight.js +38 -30
  96. package/lib/index.d.ts +932 -948
  97. package/lib/index.d.ts.map +1 -1
  98. package/lib/math/progCalc/progCalc.d.ts +2 -2
  99. package/lib/math/progCalc/progCalc.d.ts.map +1 -1
  100. package/lib/math/progCalc/progCalc.js +4 -11
  101. package/lib/playgroundUtils.d.ts +3 -0
  102. package/lib/playgroundUtils.d.ts.map +1 -0
  103. package/lib/playgroundUtils.js +13 -0
  104. package/lib/server.js +121 -0
  105. package/lib/tests/exoTest.d.ts.map +1 -1
  106. package/lib/tests/exoTest.js +13 -0
  107. package/lib/types/keyIds.d.ts +1 -1
  108. package/lib/types/keyIds.d.ts.map +1 -1
  109. package/package.json +1 -1
@@ -8,7 +8,7 @@ import { random } from "../../../utils/alea/random.js";
8
8
  const g = +earthGravity.measure.significantPart.toFixed(2);
9
9
  const optsDefault = {
10
10
  inputType: "sci",
11
- nbDigits: 2,
11
+ nbDigits: "2",
12
12
  };
13
13
  const options = [
14
14
  {
@@ -24,12 +24,13 @@ const options = [
24
24
  label: "Nombre de décimales",
25
25
  type: GeneratorOptionType.multiselect,
26
26
  target: GeneratorOptionTarget.generation,
27
- values: [0, 1, 2],
27
+ values: ["0", "1", "2"],
28
28
  defaultValue: [optsDefault.nbDigits],
29
29
  },
30
30
  ];
31
- const getInstruction = (identifiers) => {
32
- const { mass, optsIdent } = identifiers;
31
+ const getInstruction = (identifiers, optsIn) => {
32
+ const opts = optsIn ?? optsDefault;
33
+ const { mass } = identifiers;
33
34
  const instruction = `Soit un objet avec une masse de $${mass}\\ \\textrm{kg}$.
34
35
 
35
36
  L'accélération due à la gravité vaut $${g.frenchify()}$ $\\textrm{m} \\cdot \\textrm{s}^{${-2}}$.
@@ -37,7 +38,7 @@ L'accélération due à la gravité vaut $${g.frenchify()}$ $\\textrm{m} \\cdot
37
38
  Calculer le poids de cet objet en Newtons.
38
39
  Donner le résultat
39
40
  ${(() => {
40
- switch (optsIdent.inputType) {
41
+ switch (opts.inputType) {
41
42
  case "decimal":
42
43
  return `en écriture décimale`;
43
44
  case "sci":
@@ -45,12 +46,12 @@ ${(() => {
45
46
  }
46
47
  })()}
47
48
  ${(() => {
48
- switch (optsIdent.nbDigits) {
49
- case 0:
49
+ switch (opts.nbDigits) {
50
+ case "0":
50
51
  return `arrondie à l'unité`;
51
- case 1:
52
+ case "1":
52
53
  return `arrondie à une décimale`;
53
- case 2:
54
+ case "2":
54
55
  return `arrondie à deux décimales`;
55
56
  }
56
57
  })()}.
@@ -77,25 +78,30 @@ const getCorrection = (identifiers) => {
77
78
  const correction = `Pour calculer le poids de l'objet, on utilise la formule :
78
79
 
79
80
  $$
80
- P=m \\cdot g
81
+ P = m \\cdot g
81
82
  $$
82
83
 
83
84
  On a :
84
85
 
85
86
  $$
86
- P = ${mass.frenchify()} \\times ${g.frenchify()} \\Rightarrow P=${answer}
87
+ P = ${mass.frenchify()} \\times ${g.frenchify()}
88
+ $$
89
+
90
+ $$
91
+ P \\approx ${answer}
87
92
  $$`;
88
93
  return correction;
89
94
  };
90
- const getAnswer = (identifiers) => {
91
- const { mass, optsIdent } = identifiers;
92
- switch (optsIdent.inputType) {
95
+ const getAnswer = (identifiers, optsIn) => {
96
+ const opts = optsIn ?? optsDefault;
97
+ const { mass } = identifiers;
98
+ switch (opts.inputType) {
93
99
  case "decimal": {
94
- const answer = round(mass * g, optsIdent.nbDigits);
100
+ const answer = round(mass * g, Number(opts.nbDigits));
95
101
  return `${answer.frenchify()}N`;
96
102
  }
97
103
  case "sci": {
98
- const answer = (mass * g).toScientific(optsIdent.nbDigits);
104
+ const answer = (mass * g).toScientific(Number(opts.nbDigits));
99
105
  return `${answer.toTex()}N`;
100
106
  }
101
107
  }
@@ -103,30 +109,32 @@ const getAnswer = (identifiers) => {
103
109
  const isAnswerValid = (ans, { answer }) => {
104
110
  return ans === answer;
105
111
  };
106
- const getPropositions = (n, { answer, mass, optsIdent }) => {
112
+ const getPropositions = (n, { answer, mass }, optsIn) => {
113
+ const opts = optsIn ?? optsDefault;
107
114
  const propositions = [];
108
115
  const weight = mass * g;
109
116
  addValidProp(propositions, answer);
110
- switch (optsIdent.inputType) {
117
+ const nbDigits = Number(opts.nbDigits);
118
+ switch (opts.inputType) {
111
119
  case "decimal":
112
120
  {
113
- tryToAddWrongProp(propositions, `${round(weight * 10, optsIdent.nbDigits).frenchify()}N`);
114
- tryToAddWrongProp(propositions, `${round(randfloat(weight - 100, weight + 100, 2, [weight]) / 10, optsIdent.nbDigits).frenchify()}N`);
121
+ tryToAddWrongProp(propositions, `${round(weight * 10, nbDigits).frenchify()}N`);
122
+ tryToAddWrongProp(propositions, `${round(randfloat(weight - 100, weight + 100, 2, [weight]) / 10, nbDigits).frenchify()}N`);
115
123
  propWhile(propositions, n, () => {
116
124
  const random = randfloat(weight - 50, weight + 50, 2, [weight]);
117
- tryToAddWrongProp(propositions, `${round(random, optsIdent.nbDigits).frenchify()}N`);
125
+ tryToAddWrongProp(propositions, `${round(random, nbDigits).frenchify()}N`);
118
126
  });
119
127
  }
120
128
  break;
121
129
  case "sci":
122
130
  {
123
- tryToAddWrongProp(propositions, `${(weight * 10).toScientific(optsIdent.nbDigits).toTex()}N`);
131
+ tryToAddWrongProp(propositions, `${(weight * 10).toScientific(nbDigits).toTex()}N`);
124
132
  tryToAddWrongProp(propositions, `${(randfloat(weight - 100, weight + 100, 2, [weight]) / 10)
125
- .toScientific(optsIdent.nbDigits)
133
+ .toScientific(nbDigits)
126
134
  .toTex()}N`);
127
135
  propWhile(propositions, n, () => {
128
136
  const random = randfloat(weight - 50, weight + 50, 2, [weight]);
129
- tryToAddWrongProp(propositions, `${random.toScientific(optsIdent.nbDigits).toTex()}N`);
137
+ tryToAddWrongProp(propositions, `${random.toScientific(nbDigits).toTex()}N`);
130
138
  });
131
139
  }
132
140
  break;
@@ -137,20 +145,20 @@ const getCalculateWeightQuestion = (optsIn) => {
137
145
  const opts = optsIn
138
146
  ? Object.assign(optsDefault, {
139
147
  inputType: random(optsIn.inputType),
140
- nbDigits: +random(optsIn.nbDigits),
148
+ nbDigits: random(optsIn.nbDigits),
141
149
  })
142
150
  : optsDefault;
143
151
  const mass = randint(30, 151);
144
- const identifiers = { mass: mass, optsIdent: opts };
152
+ const identifiers = { mass: mass };
145
153
  return getQuestionFromIdentifiers(identifiers, opts);
146
154
  };
147
155
  const getQuestionFromIdentifiers = (identifiers, opts) => {
148
156
  const question = {
149
- answer: getAnswer(identifiers),
150
- instruction: getInstruction(identifiers),
157
+ answer: getAnswer(identifiers, opts),
158
+ instruction: getInstruction(identifiers, opts),
151
159
  keys: ["N"],
152
- hint: getHint(identifiers),
153
- correction: getCorrection(identifiers),
160
+ hint: getHint(identifiers, opts),
161
+ correction: getCorrection(identifiers, opts),
154
162
  answerFormat: "tex",
155
163
  identifiers,
156
164
  options: opts,