math-exercises 3.0.176 → 3.0.178

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 (136) hide show
  1. package/lib/exercises/math/derivation/variations/readExtremaAbscissFromDerivativeCurve.js +1 -1
  2. package/lib/exercises/math/functions/trinoms/sign/index.d.ts +1 -0
  3. package/lib/exercises/math/functions/trinoms/sign/index.d.ts.map +1 -1
  4. package/lib/exercises/math/functions/trinoms/sign/index.js +1 -0
  5. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.d.ts +8 -0
  6. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.d.ts.map +1 -0
  7. package/lib/exercises/math/functions/trinoms/sign/signOfProductOfAffineAndTrinom.js +233 -0
  8. package/lib/exercises/math/geometry/angles/parallelogramFourthAngle.d.ts.map +1 -1
  9. package/lib/exercises/math/geometry/angles/parallelogramFourthAngle.js +10 -10
  10. package/lib/exercises/math/geometry/quadrilaterals/parallelogramAngles.js +8 -8
  11. package/lib/exercises/math/geometry/triangles/similar/isSimilarTrianglesWithAngles.js +6 -6
  12. package/lib/exercises/math/geometry/triangles/triangleThirdAngleValue.js +8 -8
  13. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiAngle.js +1 -1
  14. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiSideLength.js +2 -2
  15. package/lib/exercises/math/geometry/vectors/scalarProduct/angleFromScalarProduct.js +2 -2
  16. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.d.ts.map +1 -1
  17. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOrthoInSquare.js +31 -6
  18. package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
  19. package/lib/exercises/math/probaStat/randomVariable/index.js +1 -0
  20. package/lib/exercises/math/probaStat/trees/index.d.ts +1 -3
  21. package/lib/exercises/math/probaStat/trees/index.d.ts.map +1 -1
  22. package/lib/exercises/math/probaStat/trees/index.js +8 -3
  23. package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts +3 -9
  24. package/lib/exercises/math/probaStat/trees/probabilityTree.d.ts.map +1 -1
  25. package/lib/exercises/math/probaStat/trees/probabilityTree.js +45 -419
  26. package/lib/exercises/math/probaStat/trees/probabilityTreeV2.d.ts +25 -0
  27. package/lib/exercises/math/probaStat/trees/probabilityTreeV2.d.ts.map +1 -0
  28. package/lib/exercises/math/probaStat/trees/probabilityTreeV2.js +625 -0
  29. package/lib/exercises/math/python/index.d.ts +1 -0
  30. package/lib/exercises/math/python/index.d.ts.map +1 -1
  31. package/lib/exercises/math/python/index.js +1 -0
  32. package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts.map +1 -1
  33. package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.js +11 -8
  34. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts.map +1 -1
  35. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.js +4 -3
  36. package/lib/exercises/math/sequences/arithmetic/index.d.ts +4 -3
  37. package/lib/exercises/math/sequences/arithmetic/index.d.ts.map +1 -1
  38. package/lib/exercises/math/sequences/arithmetic/index.js +4 -3
  39. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts.map +1 -1
  40. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.js +3 -2
  41. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -1
  42. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +8 -6
  43. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -1
  44. package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +6 -5
  45. package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +0 -2
  46. package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -1
  47. package/lib/exercises/math/sequences/arithmetic/situations/index.js +2 -2
  48. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts +1 -0
  49. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts.map +1 -1
  50. package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.js +65 -14
  51. package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts +0 -1
  52. package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts.map +1 -1
  53. package/lib/exercises/math/sequences/arithmetic/sum/index.js +1 -1
  54. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.d.ts +14 -0
  55. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.d.ts.map +1 -0
  56. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoConsecutiveTerms.js +291 -0
  57. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -1
  58. package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +4 -3
  59. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoConsecutiveTerms.d.ts +15 -0
  60. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoConsecutiveTerms.d.ts.map +1 -0
  61. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoConsecutiveTerms.js +249 -0
  62. package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +1 -1
  63. package/lib/exercises/math/sequences/geometric/index.d.ts +6 -2
  64. package/lib/exercises/math/sequences/geometric/index.d.ts.map +1 -1
  65. package/lib/exercises/math/sequences/geometric/index.js +6 -2
  66. package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -1
  67. package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +3 -2
  68. package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.js +1 -1
  69. package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.js +2 -2
  70. package/lib/exercises/math/sequences/graph/placeFirstSequencePoints.js +2 -2
  71. package/lib/exercises/math/sequences/index.d.ts +1 -0
  72. package/lib/exercises/math/sequences/index.d.ts.map +1 -1
  73. package/lib/exercises/math/sequences/index.js +1 -0
  74. package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts.map +1 -1
  75. package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.js +5 -9
  76. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.2d.js +1 -1
  77. package/lib/exercises/math/trigonometry/circle/findAngleFromCosAndSin.d.ts.map +1 -1
  78. package/lib/exercises/math/trigonometry/circle/findAngleFromCosAndSin.js +17 -8
  79. package/lib/exercises/math/trigonometry/circle/index.d.ts +2 -0
  80. package/lib/exercises/math/trigonometry/circle/index.d.ts.map +1 -1
  81. package/lib/exercises/math/trigonometry/circle/index.js +2 -1
  82. package/lib/exercises/math/trigonometry/circle/mainRemarkableValues.d.ts.map +1 -1
  83. package/lib/exercises/math/trigonometry/circle/mainRemarkableValues.js +57 -0
  84. package/lib/exercises/math/trigonometry/circle/remarkableValues.d.ts.map +1 -1
  85. package/lib/exercises/math/trigonometry/circle/remarkableValues.js +88 -0
  86. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts +5 -0
  87. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.d.ts.map +1 -1
  88. package/lib/exercises/math/trigonometry/circle/selectQuadrantOnTrigoCircle.js +92 -94
  89. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.d.ts +11 -0
  90. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.d.ts.map +1 -0
  91. package/lib/exercises/math/trigonometry/functions/associateAngleSimplification.js +166 -0
  92. package/lib/exercises/math/trigonometry/functions/basicEquationCos.d.ts.map +1 -1
  93. package/lib/exercises/math/trigonometry/functions/basicEquationCos.js +54 -9
  94. package/lib/exercises/math/trigonometry/functions/basicEquationSin.d.ts.map +1 -1
  95. package/lib/exercises/math/trigonometry/functions/basicEquationSin.js +54 -8
  96. package/lib/exercises/math/trigonometry/functions/equationSinOnRandomInterval.js +1 -2
  97. package/lib/exercises/math/trigonometry/functions/index.d.ts +1 -0
  98. package/lib/exercises/math/trigonometry/functions/index.d.ts.map +1 -1
  99. package/lib/exercises/math/trigonometry/functions/index.js +1 -0
  100. package/lib/exercises/math/trigonometry/triangle/trigonometryAngleCalcul.js +2 -2
  101. package/lib/exercises/pc/snellDescartes.js +2 -2
  102. package/lib/index.d.ts +165 -36
  103. package/lib/index.d.ts.map +1 -1
  104. package/lib/latexTester.d.ts.map +1 -1
  105. package/lib/latexTester.js +8 -5
  106. package/lib/math/polynomials/affine.d.ts +1 -0
  107. package/lib/math/polynomials/affine.d.ts.map +1 -1
  108. package/lib/math/polynomials/affine.js +5 -0
  109. package/lib/math/utils/arithmetic/primeFactors.js +1 -1
  110. package/lib/math/utils/functions/functionComposition.d.ts.map +1 -1
  111. package/lib/math/utils/functions/functionComposition.js +18 -1
  112. package/lib/math/utils/random/randTupleInt.d.ts +1 -0
  113. package/lib/math/utils/random/randTupleInt.d.ts.map +1 -1
  114. package/lib/math/utils/random/randTupleInt.js +1 -1
  115. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +18 -4
  116. package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
  117. package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +437 -336
  118. package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -1
  119. package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +3 -1
  120. package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts +5 -0
  121. package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts.map +1 -1
  122. package/lib/math/utils/sequences/situations/seqGeometricSituations.js +58 -25
  123. package/lib/prototypesEnhancement.d.ts +1 -0
  124. package/lib/prototypesEnhancement.d.ts.map +1 -1
  125. package/lib/prototypesEnhancement.js +3 -0
  126. package/lib/tests/pdfs/mdCodeToLatex.d.ts.map +1 -1
  127. package/lib/tests/pdfs/mdCodeToLatex.js +8 -15
  128. package/lib/tests/questionTest.d.ts.map +1 -1
  129. package/lib/tests/questionTest.js +6 -3
  130. package/lib/tree/nodes/algebraicNode.d.ts +1 -0
  131. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  132. package/lib/tree/nodes/geometry/degree.js +1 -1
  133. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  134. package/lib/tree/nodes/operators/addNode.js +4 -2
  135. package/lib/tree/parsers/degreeParser.js +2 -2
  136. package/package.json +1 -1
@@ -0,0 +1,291 @@
1
+ import { addValidProp, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
2
+ import { getOptionFirstTermRankOneStuff, } from "../../../../exercises/options/optionFirstTermRankOne.js";
3
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { round } from "../../../../math/utils/round.js";
7
+ import { EqualNode, isEqualNode, } from "../../../../tree/nodes/equations/equalNode.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
11
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
12
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
13
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
14
+ import { random } from "../../../../utils/alea/random.js";
15
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
16
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
17
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
18
+ const getInstruction = (identifiers) => {
19
+ const { rank1, value1, rank2, value2 } = identifiers;
20
+ return `Soit $u$ une suite géométrique telle que $u_{${rank1.frenchify()}} = ${value1.frenchify()}$ et $u_{${rank2.frenchify()}} = ${value2.frenchify()}$.
21
+
22
+ Donner l'expression de $u_n$ en fonction de $n$.`;
23
+ };
24
+ const getAnswerStuff = (identifiers, opts) => {
25
+ const firstRank = opts.firstTermRankOne ? 1 : 0;
26
+ const { rank1, value1, rank2, value2, precisionInitial, precisionReason } = identifiers;
27
+ const reason = round(power(frac(value2, value1), frac(1, substract(rank2, rank1))).evaluate(), precisionReason);
28
+ const valueFirstRank = round(frac(value1, power(reason, rank1 - firstRank)).evaluate(), precisionInitial);
29
+ const nodeFormula = multiply(valueFirstRank, power(reason, substract("n".toTree(), firstRank).simplify()));
30
+ const equalNode = new EqualNode("u_n".toTree(), nodeFormula);
31
+ return {
32
+ initial: valueFirstRank,
33
+ reason,
34
+ answerNode: equalNode,
35
+ };
36
+ };
37
+ const getAnswer = (identifiers, optsIn) => {
38
+ const opts = optsIn ?? optsDefault;
39
+ return getAnswerStuff(identifiers, opts).answerNode.toTex();
40
+ };
41
+ const getHint = (_, optsIn) => {
42
+ const opts = optsIn ?? optsDefault;
43
+ const firstRank = opts?.firstTermRankOne ? 1 : 0;
44
+ return `Commence par déterminer la raison $q$ de la suite $u$.
45
+
46
+ Puis, utilise cette raison et un des termes connus de la suite pour déterminer $u_{${firstRank}}$.`;
47
+ };
48
+ const getCorrection = (identifiers, optsIn) => {
49
+ const opts = optsIn ?? optsDefault;
50
+ const firstRank = opts?.firstTermRankOne ? 1 : 0;
51
+ const { rank1, value1, rank2, value2 } = identifiers;
52
+ const closest = Math.abs(firstRank - rank1) < Math.abs(firstRank - rank2) ? rank1 : rank2;
53
+ const diff = firstRank - closest;
54
+ const closestValue = closest === rank1 ? value1 : value2;
55
+ const { reason, answerNode } = getAnswerStuff(identifiers, opts);
56
+ return `On commence par déterminer la raison $q$ de la suite $u$.
57
+
58
+ On a :
59
+
60
+ ${alignTex([
61
+ [
62
+ `u_{${rank1}}`,
63
+ "=",
64
+ `u_{${firstRank}} \\times q^{${rank1.frenchify()} - ${firstRank.frenchify()}}`,
65
+ ],
66
+ [
67
+ `u_{${rank2}}`,
68
+ "=",
69
+ `u_{${firstRank}} \\times q^{${rank2.frenchify()} - ${firstRank.frenchify()}}`,
70
+ ],
71
+ ])}
72
+
73
+ On forme le quotient :
74
+
75
+ ${alignTex([
76
+ [
77
+ `\\frac{u_{${rank2}}}{u_{${rank1}}}`,
78
+ "=",
79
+ `q^{${rank2.frenchify()} - ${rank1.frenchify()}}`,
80
+ ],
81
+ [
82
+ `\\frac{${value2.frenchify()}}{${value1.frenchify()}}`,
83
+ "=",
84
+ `q^{${(rank2 - rank1).frenchify()}}`,
85
+ ],
86
+ [`${reason.frenchify()}`, "=", `q`],
87
+ ])}
88
+
89
+ On peut alors déterminer $u_{${firstRank.frenchify()}}$ en utilisant $u_{${closest.frenchify()}}$ et $q$. En effet, on a :
90
+
91
+ ${alignTex([
92
+ [
93
+ `u_{${firstRank.frenchify()}}`,
94
+ "=",
95
+ `\\frac{u_{${closest.frenchify()}}}{q^{${(-diff).frenchify()}}}`,
96
+ ],
97
+ ["", "=", frac(closestValue, power(reason, -diff)).toTex()],
98
+ ["", "=", multiply(closestValue, power(reason, diff)).evaluate().frPretty(1)],
99
+ ])}
100
+
101
+ On a donc :
102
+
103
+ ${(() => {
104
+ const texFormulaAbstract = firstRank === 0 ? "u_0 \\times q^{n}" : "u_1 \\times q^{n-1}";
105
+ return alignTex([
106
+ ["u_n", "=", texFormulaAbstract],
107
+ ["", "=", answerNode.rightChild.toTex()],
108
+ ]);
109
+ })()}
110
+
111
+ `;
112
+ };
113
+ const getPropositions = (n, { answer, ..._identifiers }, optsIn) => {
114
+ const opts = optsIn ?? optsDefault;
115
+ // const firstRank = opts?.firstTermRankOne ? 1 : 0;
116
+ const propositions = [];
117
+ addValidProp(propositions, answer);
118
+ propWhile(propositions, n, () => {
119
+ const identifiersWrong = createRandomIdentifiersCurated(opts);
120
+ const texWrong = getAnswer(identifiersWrong, opts);
121
+ tryToAddWrongProp(propositions, texWrong);
122
+ });
123
+ return shuffle(propositions);
124
+ };
125
+ const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
126
+ const opts = optsIn ?? optsDefault;
127
+ try {
128
+ //TODO faire fonctionner parseAlgebraic("u_n=3+2n") (token _ not implemented)
129
+ const nodeAnswer = getAnswerStuff(identifiers, opts).answerNode;
130
+ if (!ans.includes("=")) {
131
+ // return false;
132
+ ans = nodeAnswer.leftChild.toTex() + "=" + ans;
133
+ }
134
+ // const nodeAns = parseAlgebraic(ans);
135
+ const nodeAns = (() => {
136
+ const [lhs, rhs] = ans.split("=");
137
+ const nodeLhs = lhs.toTree();
138
+ const nodeRhs = parseAlgebraic(rhs);
139
+ return new EqualNode(nodeLhs, nodeRhs);
140
+ })();
141
+ if (!isEqualNode(nodeAns)) {
142
+ return false;
143
+ }
144
+ const isValidLhs = () => nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
145
+ const isValidRhs = () => {
146
+ const nodeAnsRhs = nodeAns.rightChild;
147
+ const nodeAnswerRhs = nodeAnswer.rightChild;
148
+ return [0, 1, 2, 10].every((n) => {
149
+ return (substract(nodeAnsRhs.evaluate({ n }), nodeAnswerRhs.evaluate({ n })).evaluate() === 0);
150
+ });
151
+ };
152
+ return isValidLhs() && isValidRhs();
153
+ }
154
+ catch (e) {
155
+ handleVEAError(e);
156
+ return false;
157
+ }
158
+ };
159
+ const createRandomIdentifiersRaw = (opts) => {
160
+ const firstRank = opts?.firstTermRankOne ? 1 : 0;
161
+ const isDivergent = coinFlip();
162
+ const isReasonNegative = coinFlip();
163
+ const signReason = isReasonNegative ? -1 : +1;
164
+ function createGeometricDivergent() {
165
+ const precisionInitial = 1;
166
+ const initial = randfloat(1, 10, precisionInitial, [1]);
167
+ const precisionReason = 0;
168
+ const reason = signReason * randint(2, 10);
169
+ return [initial, precisionInitial, reason, precisionReason];
170
+ }
171
+ function createGeometricConvergent() {
172
+ const poolReasonStuff = [
173
+ {
174
+ q: 0.5,
175
+ precision: 1,
176
+ invQ: 2,
177
+ },
178
+ {
179
+ q: 0.25,
180
+ precision: 2,
181
+ invQ: 4,
182
+ },
183
+ {
184
+ q: 0.2,
185
+ precision: 1,
186
+ invQ: 5,
187
+ },
188
+ {
189
+ q: 0.1,
190
+ precision: 1,
191
+ invQ: 10,
192
+ },
193
+ {
194
+ q: 0.05,
195
+ precision: 2,
196
+ invQ: 20,
197
+ },
198
+ ];
199
+ const { q, invQ, precision: precisionReason } = random(poolReasonStuff);
200
+ const reason = signReason * q;
201
+ const precisionInitial = 0;
202
+ const initial = round(randint(10, 100) * Math.pow(invQ, 8), precisionInitial);
203
+ return [initial, precisionInitial, reason, precisionReason];
204
+ }
205
+ const [initial, precisionInitial, reason, precisionReason] = (() => {
206
+ if (isDivergent) {
207
+ return createGeometricDivergent();
208
+ }
209
+ else {
210
+ return createGeometricConvergent();
211
+ }
212
+ })();
213
+ const rank1 = randint(firstRank + 1, 5);
214
+ const rank2 = rank1 + randint(1, 5);
215
+ function valueForRank(initial, reason, rank) {
216
+ return initial * Math.pow(reason, rank);
217
+ }
218
+ const [value1, value2] = [rank1, rank2].map((rank) => round(valueForRank(initial, reason, rank), 6));
219
+ const identifiers = {
220
+ rank1,
221
+ value1,
222
+ rank2,
223
+ value2,
224
+ precisionInitial,
225
+ precisionReason,
226
+ };
227
+ return identifiers;
228
+ };
229
+ const createRandomIdentifiersCurated = (opts) => {
230
+ let identifiers;
231
+ let isValid = false;
232
+ let counter = -1;
233
+ while (!isValid && counter < 100) {
234
+ counter++;
235
+ const identifiersCandidate = createRandomIdentifiersRaw(opts);
236
+ const answer = getAnswer(identifiersCandidate, opts);
237
+ isValid = !answer.includes("NaN");
238
+ if (isValid) {
239
+ identifiers = identifiersCandidate;
240
+ }
241
+ }
242
+ if (!isValid) {
243
+ //2.5 * 2^n
244
+ const identifiersDefault = {
245
+ rank1: 2,
246
+ value1: 10,
247
+ rank2: 5,
248
+ value2: 40,
249
+ precisionInitial: 1,
250
+ precisionReason: 0,
251
+ };
252
+ identifiers = identifiersDefault;
253
+ }
254
+ return identifiers;
255
+ };
256
+ const getGeometricFindExplicitFormulaFromTwoConsecutiveTermsQuestion = (optsIn) => {
257
+ const opts = optsIn ?? optsDefault;
258
+ const identifiers = createRandomIdentifiersCurated(opts);
259
+ return getQuestionFromIdentifiers(identifiers, opts);
260
+ };
261
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
262
+ const question = {
263
+ answer: getAnswer(identifiers, opts),
264
+ instruction: getInstruction(identifiers, opts),
265
+ keys: ["un", "equal", "n"],
266
+ answerFormat: "tex",
267
+ identifiers,
268
+ hint: getHint(identifiers, opts),
269
+ correction: getCorrection(identifiers, opts),
270
+ options: opts,
271
+ };
272
+ return question;
273
+ };
274
+ const { optsDefaultFirstTermRankOne, generatorOptionFirstTermRankOne } = getOptionFirstTermRankOneStuff(false);
275
+ const optsDefault = Object.assign({}, optsDefaultFirstTermRankOne);
276
+ const options = [generatorOptionFirstTermRankOne];
277
+ export const geometricFindExplicitFormulaFromTwoConsecutiveTerms = {
278
+ id: "geometricFindExplicitFormulaFromTwoConsecutiveTerms",
279
+ connector: "=",
280
+ label: "Connaissant deux termes consécutifs d'une suite géométrique, en donner une formule générale",
281
+ isSingleStep: true,
282
+ generator: (nb, opts) => getDistinctQuestions(() => getGeometricFindExplicitFormulaFromTwoConsecutiveTermsQuestion(opts), nb),
283
+ options,
284
+ qcmTimer: 60,
285
+ freeTimer: 60,
286
+ getPropositions,
287
+ isAnswerValid,
288
+ subject: "Mathématiques",
289
+ getQuestionFromIdentifiers,
290
+ hasHintAndCorrection: true,
291
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"geometricFindExplicitFormulaFromTwoTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAoB3D,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAkWF,KAAK,OAAO,GAAG,sBAAsB,CAAC;AAMtC,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAC7D,WAAW,EACX,OAAO,CAoBR,CAAC"}
1
+ {"version":3,"file":"geometricFindExplicitFormulaFromTwoTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAoB3D,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAsWF,KAAK,OAAO,GAAG,sBAAsB,CAAC;AAMtC,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAC7D,WAAW,EACX,OAAO,CAoBR,CAAC"}
@@ -136,10 +136,12 @@ const getPropositions = (n, { answer, ..._identifiers }, optsIn) => {
136
136
  const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
137
137
  const opts = optsIn ?? optsDefault;
138
138
  try {
139
+ //TODO faire fonctionner parseAlgebraic("u_n=3+2n") (token _ not implemented)
140
+ const nodeAnswer = getAnswerStuff(identifiers, opts).answerNode;
139
141
  if (!ans.includes("=")) {
140
- return false;
142
+ // return false;
143
+ ans = nodeAnswer.leftChild.toTex() + "=" + ans;
141
144
  }
142
- //TODO faire fonctionner parseAlgebraic("u_n=3+2n") (token _ not implemented)
143
145
  // const nodeAns = parseAlgebraic(ans);
144
146
  const nodeAns = (() => {
145
147
  const [lhs, rhs] = ans.split("=");
@@ -150,7 +152,6 @@ const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
150
152
  if (!isEqualNode(nodeAns)) {
151
153
  return false;
152
154
  }
153
- const nodeAnswer = getAnswerStuff(identifiers, opts).answerNode;
154
155
  const isValidLhs = () => nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
155
156
  const isValidRhs = () => {
156
157
  const nodeAnsRhs = nodeAns.rightChild;
@@ -0,0 +1,15 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { OptionFirstTermRankOne } from "../../../../exercises/options/optionFirstTermRankOne.js";
3
+ type Identifiers = {
4
+ rank1: number;
5
+ value1: number;
6
+ rank2: number;
7
+ value2: number;
8
+ precisionInitial: number;
9
+ precisionReason: number;
10
+ rankAsked: number;
11
+ };
12
+ type Options = OptionFirstTermRankOne;
13
+ export declare const geometricFindRandomTermFromTwoConsecutiveTerms: Exercise<Identifiers, Options>;
14
+ export {};
15
+ //# sourceMappingURL=geometricFindRandomTermFromTwoConsecutiveTerms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometricFindRandomTermFromTwoConsecutiveTerms.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoConsecutiveTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAe3D,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA6RF,KAAK,OAAO,GAAG,sBAAsB,CAAC;AAMtC,eAAO,MAAM,8CAA8C,EAAE,QAAQ,CACnE,WAAW,EACX,OAAO,CAoBR,CAAC"}
@@ -0,0 +1,249 @@
1
+ import { addValidProp, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
2
+ import { getOptionFirstTermRankOneStuff, } from "../../../../exercises/options/optionFirstTermRankOne.js";
3
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
4
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
5
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
6
+ import { randint } from "../../../../math/utils/random/randint.js";
7
+ import { round } from "../../../../math/utils/round.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { power } from "../../../../tree/nodes/operators/powerNode.js";
10
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
11
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
12
+ import { random } from "../../../../utils/alea/random.js";
13
+ import { shuffle } from "../../../../utils/alea/shuffle.js";
14
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
15
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
16
+ const getInstruction = (identifiers) => {
17
+ const { rank1, value1, rank2, value2, rankAsked } = identifiers;
18
+ return `Soit $u$ une suite géométrique telle que $u_{${rank1.frenchify()}} = ${value1.frenchify()}$ et $u_{${rank2.frenchify()}} = ${value2.frenchify()}$.
19
+
20
+ Que vaut $u_{${rankAsked}}$ ?`;
21
+ };
22
+ const getAnswerStuff = (identifiers, _opts) => {
23
+ const { rank1, value1, rank2, value2, precisionInitial, precisionReason, rankAsked, } = identifiers;
24
+ const reason = round(power(frac(value2, value1), frac(1, substract(rank2, rank1))).evaluate(), precisionReason);
25
+ const valueAsked = round(frac(value1, power(reason, rank1 - rankAsked)).evaluate(), precisionInitial);
26
+ return {
27
+ reason,
28
+ answerNode: valueAsked.toTree(),
29
+ };
30
+ };
31
+ const getAnswer = (identifiers, optsIn) => {
32
+ const opts = optsIn ?? optsDefault;
33
+ return getAnswerStuff(identifiers, opts).answerNode.toTex();
34
+ };
35
+ const getHint = (identifiers, _optsIn) => {
36
+ const { rankAsked } = identifiers;
37
+ return `Commence par déterminer la raison $q$ de la suite $u$.
38
+
39
+ Puis, utilise cette raison et un des termes connus de la suite pour déterminer $u_{${rankAsked}}$.`;
40
+ };
41
+ const getCorrection = (identifiers, optsIn) => {
42
+ const opts = optsIn ?? optsDefault;
43
+ const firstRank = opts?.firstTermRankOne ? 1 : 0;
44
+ const { rank1, value1, rank2, value2, rankAsked } = identifiers;
45
+ const diff = rankAsked - rank1;
46
+ const { reason, answerNode } = getAnswerStuff(identifiers, opts);
47
+ return `On commence par déterminer la raison $q$ de la suite $u$.
48
+
49
+ On a :
50
+
51
+ ${alignTex([
52
+ [
53
+ `u_{${rank1}}`,
54
+ "=",
55
+ `u_{${firstRank}} \\times q^{${rank1.frenchify()} - ${firstRank.frenchify()}}`,
56
+ ],
57
+ [
58
+ `u_{${rank2}}`,
59
+ "=",
60
+ `u_{${firstRank}} \\times q^{${rank2.frenchify()} - ${firstRank.frenchify()}}`,
61
+ ],
62
+ ])}
63
+
64
+ On forme le quotient :
65
+
66
+ ${alignTex([
67
+ [
68
+ `\\frac{u_{${rank2}}}{u_{${rank1}}}`,
69
+ "=",
70
+ `q^{${rank2.frenchify()} - ${rank1.frenchify()}}`,
71
+ ],
72
+ [
73
+ `\\frac{${value2.frenchify()}}{${value1.frenchify()}}`,
74
+ "=",
75
+ `q^{${(rank2 - rank1).frenchify()}}`,
76
+ ],
77
+ [`${reason.frenchify()}`, "=", `q`],
78
+ ])}
79
+
80
+ On peut alors déterminer $u_{${rankAsked.frenchify()}}$ en utilisant $u_{${rank1.frenchify()}}$ et $q$. En effet, on a :
81
+
82
+ ${alignTex([
83
+ [
84
+ `u_{${rankAsked.frenchify()}}`,
85
+ "=",
86
+ `\\frac{u_{${rank1.frenchify()}}}{q^{${(-diff).frenchify()}}}`,
87
+ ],
88
+ ["", "=", frac(value1, power(reason, -diff)).toTex()],
89
+ ["", "=", answerNode.toTex()],
90
+ ])}
91
+
92
+ `;
93
+ };
94
+ const getPropositions = (n, { answer, ..._identifiers }, optsIn) => {
95
+ const opts = optsIn ?? optsDefault;
96
+ // const firstRank = opts?.firstTermRankOne ? 1 : 0;
97
+ const propositions = [];
98
+ addValidProp(propositions, answer);
99
+ propWhile(propositions, n, () => {
100
+ const identifiersWrong = createRandomIdentifiersCurated(opts);
101
+ const texWrong = getAnswer(identifiersWrong, opts);
102
+ tryToAddWrongProp(propositions, texWrong);
103
+ });
104
+ return shuffle(propositions);
105
+ };
106
+ const isAnswerValid = (ans, { answer }) => {
107
+ try {
108
+ return numberVEA(ans, answer);
109
+ }
110
+ catch (err) {
111
+ return handleVEAError(err);
112
+ }
113
+ };
114
+ const createRandomIdentifiersRaw = (opts) => {
115
+ const firstRank = opts?.firstTermRankOne ? 1 : 0;
116
+ const isDivergent = coinFlip();
117
+ const isReasonNegative = coinFlip();
118
+ const signReason = isReasonNegative ? -1 : +1;
119
+ function createGeometricDivergent() {
120
+ const precisionInitial = 1;
121
+ const initial = randfloat(1, 10, precisionInitial, [1]);
122
+ const precisionReason = 0;
123
+ const reason = signReason * randint(2, 10);
124
+ return [initial, precisionInitial, reason, precisionReason];
125
+ }
126
+ function createGeometricConvergent() {
127
+ const poolReasonStuff = [
128
+ {
129
+ q: 0.5,
130
+ precision: 1,
131
+ invQ: 2,
132
+ },
133
+ {
134
+ q: 0.25,
135
+ precision: 2,
136
+ invQ: 4,
137
+ },
138
+ {
139
+ q: 0.2,
140
+ precision: 1,
141
+ invQ: 5,
142
+ },
143
+ {
144
+ q: 0.1,
145
+ precision: 1,
146
+ invQ: 10,
147
+ },
148
+ {
149
+ q: 0.05,
150
+ precision: 2,
151
+ invQ: 20,
152
+ },
153
+ ];
154
+ const { q, invQ, precision: precisionReason } = random(poolReasonStuff);
155
+ const reason = signReason * q;
156
+ const precisionInitial = 0;
157
+ const initial = round(randint(10, 100) * Math.pow(invQ, 8), precisionInitial);
158
+ return [initial, precisionInitial, reason, precisionReason];
159
+ }
160
+ const [initial, precisionInitial, reason, precisionReason] = (() => {
161
+ if (isDivergent) {
162
+ return createGeometricDivergent();
163
+ }
164
+ else {
165
+ return createGeometricConvergent();
166
+ }
167
+ })();
168
+ const rank1 = randint(firstRank + 1, 5);
169
+ const rank2 = rank1 + 1;
170
+ const rankAsked = randint(2, 9, [rank1, rank2]);
171
+ function valueForRank(initial, reason, rank) {
172
+ return initial * Math.pow(reason, rank);
173
+ }
174
+ const [value1, value2] = [rank1, rank2].map((rank) => round(valueForRank(initial, reason, rank), 4));
175
+ const identifiers = {
176
+ rank1,
177
+ value1,
178
+ rank2,
179
+ value2,
180
+ precisionInitial,
181
+ precisionReason,
182
+ rankAsked,
183
+ };
184
+ return identifiers;
185
+ };
186
+ const createRandomIdentifiersCurated = (opts) => {
187
+ let identifiers;
188
+ let isValid = false;
189
+ let counter = -1;
190
+ while (!isValid && counter < 100) {
191
+ counter++;
192
+ const identifiersCandidate = createRandomIdentifiersRaw(opts);
193
+ const answer = getAnswer(identifiersCandidate, opts);
194
+ isValid = !answer.includes("NaN");
195
+ if (isValid) {
196
+ identifiers = identifiersCandidate;
197
+ }
198
+ }
199
+ if (!isValid) {
200
+ //2.5 * 2^n
201
+ const identifiersDefault = {
202
+ rank1: 2,
203
+ value1: 10,
204
+ rank2: 5,
205
+ value2: 40,
206
+ precisionInitial: 1,
207
+ precisionReason: 0,
208
+ rankAsked: 9,
209
+ };
210
+ identifiers = identifiersDefault;
211
+ }
212
+ return identifiers;
213
+ };
214
+ const getGeometricFindRandomTermFromTwoConsecutiveTermsQuestion = (optsIn) => {
215
+ const opts = optsIn ?? optsDefault;
216
+ const identifiers = createRandomIdentifiersCurated(opts);
217
+ return getQuestionFromIdentifiers(identifiers, opts);
218
+ };
219
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
220
+ const question = {
221
+ answer: getAnswer(identifiers, opts),
222
+ instruction: getInstruction(identifiers, opts),
223
+ keys: ["un", "equal", "n"],
224
+ answerFormat: "tex",
225
+ identifiers,
226
+ hint: getHint(identifiers, opts),
227
+ correction: getCorrection(identifiers, opts),
228
+ options: opts,
229
+ };
230
+ return question;
231
+ };
232
+ const { optsDefaultFirstTermRankOne, generatorOptionFirstTermRankOne } = getOptionFirstTermRankOneStuff(false);
233
+ const optsDefault = Object.assign({}, optsDefaultFirstTermRankOne);
234
+ const options = [generatorOptionFirstTermRankOne];
235
+ export const geometricFindRandomTermFromTwoConsecutiveTerms = {
236
+ id: "geometricFindRandomTermFromTwoConsecutiveTerms",
237
+ connector: "=",
238
+ label: "Connaissant deux termes consécutifs d'une suite géométrique, en donner une formule générale",
239
+ isSingleStep: true,
240
+ generator: (nb, opts) => getDistinctQuestions(() => getGeometricFindRandomTermFromTwoConsecutiveTermsQuestion(opts), nb),
241
+ options,
242
+ qcmTimer: 60,
243
+ freeTimer: 60,
244
+ getPropositions,
245
+ isAnswerValid,
246
+ subject: "Mathématiques",
247
+ getQuestionFromIdentifiers,
248
+ hasHintAndCorrection: true,
249
+ };
@@ -177,7 +177,7 @@ const createRandomIdentifiersRaw = (opts) => {
177
177
  }
178
178
  })();
179
179
  const rank1 = randint(firstRank + 1, 5);
180
- const rank2 = rank1 + randint(1, 5);
180
+ const rank2 = rank1 + randint(2, 5);
181
181
  const rankAsked = randint(2, 9, [rank1, rank2]);
182
182
  function valueForRank(initial, reason, rank) {
183
183
  return initial * Math.pow(reason, rank);
@@ -2,13 +2,17 @@ export * from "./geometricExplicitFormulaUsage.js";
2
2
  export * from "./geometricFindExplicitFormula.js";
3
3
  export * from "./geometricFindExplicitFormulaFirstRankOne.js";
4
4
  export * from "./geometricFindReason.js";
5
- export * from "./geometricFirstTermsSum.js";
6
5
  export * from "./geometricReasonUsage.js";
7
6
  export * from "./geometricRecurrenceFormulaUsage.js";
8
7
  export * from "./geometricFindExplicitFormulaFirstTermRandom.js";
9
8
  export * from "./geometricFindTerm.js";
10
9
  export * from "./geometricFindTermFirstRankOne.js";
11
10
  export * from "./geometricRecognizeReasonFromFirstTerms.js";
12
- export * from "./geometricFirstTermsGeneralSum.js";
13
11
  export * from "./geometricVariations.js";
12
+ export * from "./geometricFindExplicitFormulaFromTwoTerms.js";
13
+ export * from "./geometricFindExplicitFormulaFromTwoConsecutiveTerms.js";
14
+ export * from "./geometricFindRandomTermFromTwoTerms.js";
15
+ export * from "./geometricFindRandomTermFromTwoConsecutiveTerms.js";
16
+ export * from "./sum/index.js";
17
+ export * from "./situations/index.js";
14
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;AAE9D,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kDAAkD,CAAC;AACjE,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AAEnD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/geometric/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;AAE9D,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kDAAkD,CAAC;AACjE,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AAEnD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0BAA0B,CAAC;AAEzC,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0DAA0D,CAAC;AACzE,cAAc,0CAA0C,CAAC;AACzD,cAAc,qDAAqD,CAAC;AAEpE,cAAc,gBAAgB,CAAC;AAE/B,cAAc,uBAAuB,CAAC"}
@@ -2,12 +2,16 @@ export * from "./geometricExplicitFormulaUsage.js";
2
2
  export * from "./geometricFindExplicitFormula.js";
3
3
  export * from "./geometricFindExplicitFormulaFirstRankOne.js";
4
4
  export * from "./geometricFindReason.js";
5
- export * from "./geometricFirstTermsSum.js";
6
5
  export * from "./geometricReasonUsage.js";
7
6
  export * from "./geometricRecurrenceFormulaUsage.js";
8
7
  export * from "./geometricFindExplicitFormulaFirstTermRandom.js";
9
8
  export * from "./geometricFindTerm.js";
10
9
  export * from "./geometricFindTermFirstRankOne.js";
11
10
  export * from "./geometricRecognizeReasonFromFirstTerms.js";
12
- export * from "./geometricFirstTermsGeneralSum.js";
13
11
  export * from "./geometricVariations.js";
12
+ export * from "./geometricFindExplicitFormulaFromTwoTerms.js";
13
+ export * from "./geometricFindExplicitFormulaFromTwoConsecutiveTerms.js";
14
+ export * from "./geometricFindRandomTermFromTwoTerms.js";
15
+ export * from "./geometricFindRandomTermFromTwoConsecutiveTerms.js";
16
+ export * from "./sum/index.js";
17
+ export * from "./situations/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"geometricFindExplicitFormulaFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAIhE,OAAO,EAEL,iCAAiC,EAElC,MAAM,iEAAiE,CAAC;AAiBzE,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,iCAAiC,CAAC;CACrD,CAAC;AA8OF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,yCAAyC,EAAE,QAAQ,CAC9D,WAAW,EACX,OAAO,CAoBR,CAAC"}
1
+ {"version":3,"file":"geometricFindExplicitFormulaFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAIhE,OAAO,EAEL,iCAAiC,EAElC,MAAM,iEAAiE,CAAC;AAiBzE,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,iCAAiC,CAAC;CACrD,CAAC;AAiPF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,yCAAyC,EAAE,QAAQ,CAC9D,WAAW,EACX,OAAO,CAoBR,CAAC"}
@@ -101,8 +101,10 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
101
101
  const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
102
102
  const opts = optsIn ?? optsDefault;
103
103
  try {
104
+ const nodeAnswer = getAnswerNode(identifiers, opts);
104
105
  if (!ans.includes("=")) {
105
- return false;
106
+ // return false;
107
+ ans = nodeAnswer.leftChild.toTex() + "=" + ans;
106
108
  }
107
109
  //TODO faire fonctionner parseAlgebraic("u_n = 3 \\times 2^n") (token _ not implemented)
108
110
  // const nodeAns = parseAlgebraic(ans);
@@ -115,7 +117,6 @@ const isAnswerValid = (ans, { answer, ...identifiers }, optsIn) => {
115
117
  if (!isEqualNode(nodeAns)) {
116
118
  return false;
117
119
  }
118
- const nodeAnswer = getAnswerNode(identifiers, opts);
119
120
  const isValidLhs = () => nodeAns.leftChild.toTex() === nodeAnswer.leftChild.toTex();
120
121
  const isValidRhs = () => {
121
122
  const nodeAnsRhs = nodeAns.rightChild;