math-exercises 3.0.16 → 3.0.18

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 (26) hide show
  1. package/lib/exercises/math/calcul/proportionality/index.d.ts +1 -0
  2. package/lib/exercises/math/calcul/proportionality/index.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/proportionality/index.js +1 -0
  4. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.d.ts +7 -0
  5. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.d.ts.map +1 -0
  6. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.js +198 -0
  7. package/lib/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.d.ts +1 -0
  8. package/lib/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.d.ts.map +1 -1
  9. package/lib/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.js +47 -23
  10. package/lib/exercises/math/derivation/tangent/derivativeNumberReading.d.ts +1 -0
  11. package/lib/exercises/math/derivation/tangent/derivativeNumberReading.d.ts.map +1 -1
  12. package/lib/exercises/math/derivation/tangent/derivativeNumberReading.js +78 -22
  13. package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -1
  14. package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +24 -7
  15. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/trinoms/summitAndCanonical/summitReading.js +26 -9
  17. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.d.ts.map +1 -1
  18. package/lib/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.js +45 -24
  19. package/lib/exercises/math/geometry/convexity/convexityTrinomialsGeo.d.ts.map +1 -1
  20. package/lib/exercises/math/geometry/convexity/convexityTrinomialsGeo.js +25 -11
  21. package/lib/index.d.ts +5 -0
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/latexTester.d.ts.map +1 -1
  24. package/lib/latexTester.js +10 -9
  25. package/lib/math/polynomials/polynomial.d.ts.map +1 -1
  26. package/package.json +1 -1
@@ -5,4 +5,5 @@ export * from "./scaleUsage.js";
5
5
  export * from "./isTableProportionalNonInteger.js";
6
6
  export * from "./findCoeffInProportionalTableNonIntegers.js";
7
7
  export * from "./isTableProportional.js";
8
+ export * from "./rectangleSideAfterReduction.js";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC"}
@@ -5,3 +5,4 @@ export * from "./scaleUsage.js";
5
5
  export * from "./isTableProportionalNonInteger.js";
6
6
  export * from "./findCoeffInProportionalTableNonIntegers.js";
7
7
  export * from "./isTableProportional.js";
8
+ export * from "./rectangleSideAfterReduction.js";
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ lengths: number[];
4
+ };
5
+ export declare const rectangleSideAfterReduction: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=rectangleSideAfterReduction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rectangleSideAfterReduction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/rectangleSideAfterReduction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CAGnB,CAAC;AA8OF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAoB7D,CAAC"}
@@ -0,0 +1,198 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.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 { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ import { D3Node } from "d3-node";
9
+ const getPropositions = (n, { answer, ...identifiers }) => {
10
+ const propositions = [];
11
+ const { lengths } = identifiers;
12
+ const [a, b, c, d] = lengths;
13
+ addValidProp(propositions, answer);
14
+ const askedIndex = lengths.findIndex((e) => !e);
15
+ switch (askedIndex) {
16
+ case 0:
17
+ tryToAddWrongProp(propositions, c + (b - d) + "");
18
+ tryToAddWrongProp(propositions, round((b * d) / c, 1).frenchify());
19
+ tryToAddWrongProp(propositions, round((c * d) / b, 1).frenchify());
20
+ break;
21
+ case 1:
22
+ tryToAddWrongProp(propositions, d + (a - c) + "");
23
+ tryToAddWrongProp(propositions, round((c * d) / a, 1).frenchify());
24
+ tryToAddWrongProp(propositions, round((a * c) / d, 1).frenchify());
25
+ break;
26
+ case 2:
27
+ tryToAddWrongProp(propositions, a - (b - d) + "");
28
+ tryToAddWrongProp(propositions, round((b * d) / a, 1).frenchify());
29
+ tryToAddWrongProp(propositions, round((a * b) / d, 1).frenchify());
30
+ break;
31
+ case 3:
32
+ tryToAddWrongProp(propositions, b - (a - c) + "");
33
+ tryToAddWrongProp(propositions, round((a * c) / b, 1).frenchify());
34
+ tryToAddWrongProp(propositions, round((a * b) / c, 1).frenchify());
35
+ default:
36
+ break;
37
+ }
38
+ while (propositions.length < n) {
39
+ tryToAddWrongProp(propositions, randfloat(2, 10, 1).frenchify());
40
+ }
41
+ return shuffleProps(propositions, n);
42
+ };
43
+ const getAnswer = (identifiers) => {
44
+ const { lengths } = identifiers;
45
+ const [a, b, c, d] = lengths;
46
+ const asked = lengths.findIndex((e) => !e);
47
+ switch (asked) {
48
+ case 0:
49
+ //a = bc/d
50
+ return round((b * c) / d, 1).frenchify();
51
+ case 1:
52
+ //b = da/c
53
+ return round((d * a) / c, 1).frenchify();
54
+ case 2:
55
+ //c = ad/b
56
+ return round((a * d) / b, 1).frenchify();
57
+ case 3:
58
+ default:
59
+ //d = bc/a
60
+ return round((b * c) / a, 1).frenchify();
61
+ }
62
+ };
63
+ const getInstruction = (identifiers) => {
64
+ const { lengths } = identifiers;
65
+ const [a, b, c, d] = lengths;
66
+ const askedIndex = lengths.findIndex((e) => !e);
67
+ // Create d3-node instance
68
+ const d3n = new D3Node();
69
+ // Set SVG dimensions
70
+ const width = 300, height = 150;
71
+ const svg = d3n.createSVG(width, height);
72
+ // Function to add rotated rectangles
73
+ function addRectangle(svg, x, y, w, h, angle, color, label1, label2) {
74
+ const group = svg
75
+ .append("g")
76
+ .attr("transform", `translate(${x},${y}) rotate(${angle})`);
77
+ group
78
+ .append("rect")
79
+ .attr("width", w)
80
+ .attr("height", h)
81
+ .attr("fill", color)
82
+ .attr("fill-opacity", 0.3)
83
+ .attr("stroke", color)
84
+ .attr("stroke-width", 2);
85
+ // Add side labels
86
+ group
87
+ .append("text")
88
+ .attr("x", w + 5)
89
+ .attr("y", h / 2)
90
+ .attr("fill", color)
91
+ .attr("font-size", "14px")
92
+ .attr("font-weight", "bold")
93
+ .text(label1);
94
+ group
95
+ .append("text")
96
+ .attr("x", w / 2 - 5)
97
+ .attr("y", h + 18)
98
+ .attr("fill", color)
99
+ .attr("font-size", "14px")
100
+ .attr("font-weight", "bold")
101
+ .text(label2);
102
+ }
103
+ // Add first rectangle (red) - Bigger
104
+ addRectangle(svg, 60, 60, 120, 40, -20, "red", b === 0 ? "?" : b + "", a === 0 ? "?" : a + "");
105
+ // Add second rectangle (blue) - Smaller
106
+ addRectangle(svg, 190, 90, 80, 25, -20, "blue", d === 0 ? "?" : d + "", c === 0 ? "?" : c + "");
107
+ // Output the SVG string
108
+ const sideIsOnFirstRect = askedIndex < 2;
109
+ const sideTypeAsked = askedIndex % 2 === 0 ? "longueur" : "largeur";
110
+ const sidesString = lengths.map((e, i) => e === 0 ? "" : `${i % 2 === 0 ? "longueur" : "largeur"} $${e}$ cm`);
111
+ return `Sur la figure suivante, le premier rectangle a pour ${sideIsOnFirstRect
112
+ ? sidesString[askedIndex === 1 ? 0 : 1]
113
+ : sidesString[0] + " et pour " + sidesString[1]}.
114
+
115
+ Le deuxième rectangle est une réduction du premier rectangle et a pour ${sideIsOnFirstRect
116
+ ? sidesString[2] + " et pour " + sidesString[3]
117
+ : sidesString[askedIndex === 3 ? 2 : 3]}.
118
+
119
+ ${d3n.svgString()}
120
+
121
+ Quelle est la ${sideTypeAsked} (en cm) du ${sideIsOnFirstRect ? "premier" : "deuxième"} rectangle ? Arrondir à $0,1$ cm si nécessaire.`;
122
+ };
123
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
124
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
125
+ const getKeys = (identifiers) => {
126
+ return [];
127
+ };
128
+ const isAnswerValid = (ans, { answer }) => {
129
+ try {
130
+ return numberVEA(ans, answer, 1);
131
+ }
132
+ catch (err) {
133
+ return handleVEAError(err);
134
+ }
135
+ };
136
+ const getRectangleSideAfterReductionQuestion = (ops) => {
137
+ const askedSize = randint(0, 4);
138
+ let a;
139
+ let b;
140
+ let c;
141
+ let d;
142
+ switch (askedSize) {
143
+ case 0:
144
+ a = 0;
145
+ c = randint(3, 10);
146
+ d = randint(1, c);
147
+ b = randint(d + 1, 15);
148
+ break;
149
+ case 1:
150
+ b = 0;
151
+ c = randint(3, 10);
152
+ d = randint(1, c);
153
+ a = randint(c + 1, 15);
154
+ break;
155
+ case 2:
156
+ c = 0;
157
+ a = randint(5, 10);
158
+ b = randint(2, a);
159
+ d = randint(1, b);
160
+ break;
161
+ case 3:
162
+ default:
163
+ d = 0;
164
+ a = randint(5, 10);
165
+ b = randint(2, a);
166
+ c = randint(3, a);
167
+ break;
168
+ }
169
+ const identifiers = {
170
+ lengths: [a, b, c, d],
171
+ };
172
+ const question = {
173
+ answer: getAnswer(identifiers),
174
+ instruction: getInstruction(identifiers),
175
+ keys: getKeys(identifiers),
176
+ answerFormat: "tex",
177
+ identifiers,
178
+ // hint: getHint(identifiers),
179
+ // correction: getCorrection(identifiers),
180
+ };
181
+ return question;
182
+ };
183
+ export const rectangleSideAfterReduction = {
184
+ id: "rectangleSideAfterReduction",
185
+ // connector: "",
186
+ label: "Utiliser la proportionnalité pour déterminer les dimensions d'un rectangle après réduction",
187
+ isSingleStep: true,
188
+ generator: (nb, opts) => getDistinctQuestions(() => getRectangleSideAfterReductionQuestion(opts), nb),
189
+ qcmTimer: 60,
190
+ freeTimer: 60,
191
+ getPropositions,
192
+ isAnswerValid,
193
+ subject: "Mathématiques",
194
+ getInstruction,
195
+ // getHint,
196
+ // getCorrection,
197
+ getAnswer,
198
+ };
@@ -1,6 +1,7 @@
1
1
  import { Exercise } from "../../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  a: number;
4
+ c: number;
4
5
  coin: number;
5
6
  racine1: number;
6
7
  racine2: number;
@@ -1 +1 @@
1
- {"version":3,"file":"thirdDegreeFunctionVariation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAkHF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAa9D,CAAC"}
1
+ {"version":3,"file":"thirdDegreeFunctionVariation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/derivative/thirdDegreeFunctionVariation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAoBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAEV,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAsIF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAiB9D,CAAC"}
@@ -13,21 +13,21 @@ import { unionIntervalParser } from "../../../../tree/parsers/unionIntervalParse
13
13
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
14
14
  import { shuffle } from "../../../../utils/alea/shuffle.js";
15
15
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
16
- const getThirdDegreeFunctionVariation = () => {
17
- const a = randint(-3, 4, [0]);
18
- const c = randint(-2, 3);
19
- const racine1 = randint(-5, 4);
20
- const racine2 = randint(racine1 + 1, 6);
21
- const coefs = [
22
- c,
23
- a * racine1 * racine2,
24
- (-a * (racine1 + racine2)) / 2,
25
- a / 3,
26
- ];
27
- const polynome = new Polynomial(coefs);
28
- const coin = coinFlip() ? -1 : 1;
29
- const instruction = `Soit $f$ la fonction représentée ci-dessous. Sur quel intervalle la dérivée de $f$ est-elle ` +
30
- (coin < 0 ? "négative ?" : "positive ?");
16
+ const rebuildIdentifiers = (oldIds) => {
17
+ if (oldIds?.c !== undefined)
18
+ return oldIds;
19
+ return {
20
+ ...oldIds,
21
+ c: randint(-2, 3),
22
+ };
23
+ };
24
+ const getInstruction = (identifiers) => {
25
+ const { a, coin, racine1, racine2 } = identifiers;
26
+ return (`Soit $f$ la fonction représentée ci-dessous. Sur quel intervalle la dérivée de $f$ est-elle ` +
27
+ (coin < 0 ? "négative ?" : "positive ?"));
28
+ };
29
+ const getAnswer = (identifiers) => {
30
+ const { a, coin, racine1, racine2 } = identifiers;
31
31
  const racine1Tree = new NumberNode(racine1);
32
32
  const racine2Tree = new NumberNode(racine2);
33
33
  const answer = coin * a < 0
@@ -36,12 +36,23 @@ const getThirdDegreeFunctionVariation = () => {
36
36
  new IntervalNode(MinusInfinityNode, racine1Tree, ClosureType.OF),
37
37
  new IntervalNode(racine2Tree, PlusInfinityNode, ClosureType.FO),
38
38
  ]).toTex();
39
+ return answer;
40
+ };
41
+ const getGGBOptions = (identifiers) => {
42
+ const { a, coin, racine1, racine2, c } = identifiers;
43
+ const coefs = [
44
+ c,
45
+ a * racine1 * racine2,
46
+ (-a * (racine1 + racine2)) / 2,
47
+ a / 3,
48
+ ];
49
+ const polynome = new Polynomial(coefs);
50
+ const y1 = polynome.calculate(racine1);
51
+ const y2 = polynome.calculate(racine2);
39
52
  const commands = [
40
53
  `f(x) = ${polynome.toMathString()}`,
41
54
  `SetColor(f, "${randomColor()}")`,
42
55
  ];
43
- const y1 = polynome.calculate(racine1);
44
- const y2 = polynome.calculate(racine2);
45
56
  const yMax = Math.max(y1, y2);
46
57
  const yMin = Math.min(y1, y2);
47
58
  const xMax = Math.max(racine1, racine2);
@@ -51,16 +62,25 @@ const getThirdDegreeFunctionVariation = () => {
51
62
  lockedAxesRatio: false,
52
63
  gridDistance: false,
53
64
  });
65
+ return ggb.getOptions({
66
+ coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
67
+ });
68
+ };
69
+ const getThirdDegreeFunctionVariation = () => {
70
+ const a = randint(-3, 4, [0]);
71
+ const c = randint(-2, 3);
72
+ const racine1 = randint(-5, 4);
73
+ const racine2 = randint(racine1 + 1, 6);
74
+ const coin = coinFlip() ? -1 : 1;
75
+ const identifiers = { racine1, racine2, coin, a, c };
54
76
  const question = {
55
- instruction,
77
+ instruction: getInstruction(identifiers),
56
78
  startStatement: "S",
57
- answer,
79
+ answer: getAnswer(identifiers),
58
80
  keys: ["lbracket", "rbracket", "semicolon", "infty", "cup"],
59
81
  answerFormat: "tex",
60
- ggbOptions: ggb.getOptions({
61
- coords: ggb.getAdaptedCoords({ xMin, xMax, yMin, yMax }),
62
- }),
63
- identifiers: { racine1, racine2, coin, a },
82
+ ggbOptions: getGGBOptions(identifiers),
83
+ identifiers,
64
84
  };
65
85
  return question;
66
86
  };
@@ -108,4 +128,8 @@ export const thirdDegreeFunctionVariation = {
108
128
  isAnswerValid,
109
129
  hasGeogebra: true,
110
130
  subject: "Mathématiques",
131
+ getInstruction,
132
+ getAnswer,
133
+ getGGBOptions,
134
+ rebuildIdentifiers,
111
135
  };
@@ -2,6 +2,7 @@ import { Exercise } from "../../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  A: number[];
4
4
  B: number[];
5
+ coeffs: number[];
5
6
  };
6
7
  export declare const derivativeNumberReading: Exercise<Identifiers>;
7
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"derivativeNumberReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/tangent/derivativeNumberReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,CAAC,EAAE,MAAM,EAAE,CAAC;CACb,CAAC;AA2FF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAezD,CAAC"}
1
+ {"version":3,"file":"derivativeNumberReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/derivation/tangent/derivativeNumberReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAgJF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAmBzD,CAAC"}
@@ -8,11 +8,53 @@ import { Polynomial } from "../../../../math/polynomials/polynomial.js";
8
8
  import { randint } from "../../../../math/utils/random/randint.js";
9
9
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
10
10
  import { shuffle } from "../../../../utils/alea/shuffle.js";
11
- const getDerivativeNumberReading = () => {
12
- let xA, yA, xB, yB;
13
- [xA, yA] = [1, 2].map((el) => randint(-5, 6));
14
- xB = xA > 0 ? randint(xA - 4, 6, [xA]) : randint(-4, xA + 5, [xA]); // l'écart entre les deux points ne soit pas grand
15
- yB = yA > 0 ? randint(yA - 4, 6) : randint(-4, yA + 5);
11
+ const rebuildIdentifiers = (oldIds) => {
12
+ if (oldIds?.coeffs?.length)
13
+ return oldIds;
14
+ const { A, B } = oldIds;
15
+ const xA = A[0];
16
+ const xB = B[0];
17
+ const yA = A[1];
18
+ const yB = B[1];
19
+ const pente = new Rational(yB - yA, xB - xA).simplify();
20
+ const penteValue = pente.value;
21
+ const [a, b] = [
22
+ (3 * randint(-100, 100, [0])) / 100,
23
+ (2 * randint(-4, 5)) / 100,
24
+ ];
25
+ const c = penteValue - a * Math.pow(xA, 2) - b * xA;
26
+ const d = yA - (a / 3) * Math.pow(xA, 3) - (b / 2) * Math.pow(xA, 2) - xA * c;
27
+ return {
28
+ A,
29
+ B,
30
+ coeffs: [d, c, b / 2, a / 3],
31
+ };
32
+ };
33
+ const getInstruction = (identifiers) => {
34
+ const { A, B } = identifiers;
35
+ const xA = A[0];
36
+ const xB = B[0];
37
+ const yA = A[1];
38
+ const yB = B[1];
39
+ return `Ci-dessous sont tracées la courbe $\\mathcal C_f$ de la fonction $f$ et la tangente à cette courbe au point d'abscisse $${xA}$.$\\\\$ Déterminer $f'(${xA})$.`;
40
+ };
41
+ const getAnswer = (identifiers) => {
42
+ const { A, B } = identifiers;
43
+ const xA = A[0];
44
+ const xB = B[0];
45
+ const yA = A[1];
46
+ const yB = B[1];
47
+ const pente = new Rational(yB - yA, xB - xA).simplify();
48
+ const penteTree = pente.toTree();
49
+ const answer = penteTree.toTex();
50
+ return answer;
51
+ };
52
+ const getGGBOptions = (identifiers) => {
53
+ const { A, B } = identifiers;
54
+ const xA = A[0];
55
+ const xB = B[0];
56
+ const yA = A[1];
57
+ const yB = B[1];
16
58
  const pente = new Rational(yB - yA, xB - xA).simplify();
17
59
  const origin = pente
18
60
  .opposite()
@@ -22,16 +64,7 @@ const getDerivativeNumberReading = () => {
22
64
  const originTree = origin.toTree();
23
65
  const penteString = penteTree.toMathString();
24
66
  const originString = originTree.toMathString();
25
- const penteValue = pente.value;
26
- const originValue = origin.value;
27
- const [a, b] = [
28
- (3 * randint(-100, 100, [0])) / 100,
29
- (2 * randint(-4, 5)) / 100,
30
- ];
31
- const c = penteValue - a * Math.pow(xA, 2) - b * xA;
32
- const d = yA - (a / 3) * Math.pow(xA, 3) - (b / 2) * Math.pow(xA, 2) - xA * c;
33
- const polynome = new Polynomial([d, c, b / 2, a / 3]);
34
- const instruction = `Ci-dessous sont tracées la courbe $\\mathcal C_f$ de la fonction $f$ et la tangente à cette courbe au point d'abscisse $${xA}$.$\\\\$ Déterminer $f'(${xA})$.`;
67
+ const polynome = new Polynomial(identifiers.coeffs);
35
68
  const commands = [
36
69
  `f(x) = ${polynome.toMathString()}`,
37
70
  `SetColor(f, "${blueMain}")`,
@@ -50,17 +83,36 @@ const getDerivativeNumberReading = () => {
50
83
  const ggb = new GeogebraConstructor({
51
84
  commands,
52
85
  });
53
- const answer = penteTree.toTex();
86
+ return ggb.getOptions({
87
+ coords: [xMin - 5, xMax + 5, yMin - 5, yMax + 5],
88
+ });
89
+ };
90
+ const getDerivativeNumberReading = () => {
91
+ let xA, yA, xB, yB;
92
+ [xA, yA] = [1, 2].map((el) => randint(-5, 6));
93
+ xB = xA > 0 ? randint(xA - 4, 6, [xA]) : randint(-4, xA + 5, [xA]); // l'écart entre les deux points ne soit pas grand
94
+ yB = yA > 0 ? randint(yA - 4, 6) : randint(-4, yA + 5);
95
+ const pente = new Rational(yB - yA, xB - xA).simplify();
96
+ const penteValue = pente.value;
97
+ const [a, b] = [
98
+ (3 * randint(-100, 100, [0])) / 100,
99
+ (2 * randint(-4, 5)) / 100,
100
+ ];
101
+ const c = penteValue - a * Math.pow(xA, 2) - b * xA;
102
+ const d = yA - (a / 3) * Math.pow(xA, 3) - (b / 2) * Math.pow(xA, 2) - xA * c;
103
+ const identifiers = {
104
+ A: [xA, yA],
105
+ B: [xB, yB],
106
+ coeffs: [d, c, b / 2, a / 3],
107
+ };
54
108
  const question = {
55
- instruction,
109
+ instruction: getInstruction(identifiers),
56
110
  startStatement: "a",
57
- answer,
58
- ggbOptions: ggb.getOptions({
59
- coords: [xMin - 5, xMax + 5, yMin - 5, yMax + 5],
60
- }),
111
+ answer: getAnswer(identifiers),
112
+ ggbOptions: getGGBOptions(identifiers),
61
113
  answerFormat: "tex",
62
114
  keys: [],
63
- identifiers: { A: [xA, yA], B: [xB, yB] },
115
+ identifiers,
64
116
  };
65
117
  return question;
66
118
  };
@@ -96,4 +148,8 @@ export const derivativeNumberReading = {
96
148
  isAnswerValid,
97
149
  hasGeogebra: true,
98
150
  subject: "Mathématiques",
151
+ getInstruction,
152
+ getAnswer,
153
+ getGGBOptions,
154
+ rebuildIdentifiers,
99
155
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAqDF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAa9C,CAAC"}
1
+ {"version":3,"file":"rootsReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/roots/rootsReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAgB9C,CAAC"}
@@ -4,9 +4,19 @@ import { randomColor } from "../../../../../geogebra/colors.js";
4
4
  import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
5
5
  import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
6
6
  import { randint } from "../../../../../math/utils/random/randint.js";
7
- const getRootsReadingQuestion = () => {
8
- const trinom = TrinomConstructor.randomNiceRoots(randint(1, 3));
7
+ const getInstruction = (identifiers) => {
8
+ return `Déterminer graphiquement le ou les racine(s) du polynôme du second degré représenté ci-dessous : `;
9
+ };
10
+ const getAnswer = (identifiers) => {
11
+ const { a, b, c } = identifiers;
12
+ const trinom = new Trinom(a, b, c);
9
13
  const roots = trinom.getRoots();
14
+ const answer = roots.length === 1 ? roots[0].toString() : roots.join("\\text{ et }");
15
+ return answer;
16
+ };
17
+ const getGGBOptions = (identifiers) => {
18
+ const { a, b, c } = identifiers;
19
+ const trinom = new Trinom(a, b, c);
10
20
  const commands = [
11
21
  `f(x) = ${trinom.toMathString()}`,
12
22
  `SetColor(f, "${randomColor()}")`,
@@ -15,14 +25,18 @@ const getRootsReadingQuestion = () => {
15
25
  commands,
16
26
  lockedAxesRatio: false,
17
27
  });
18
- const answer = roots.length === 1 ? roots[0].toString() : roots.join("\\text{ et }");
28
+ return ggb.getOptions({ coords: trinom.getCoords() });
29
+ };
30
+ const getRootsReadingQuestion = () => {
31
+ const trinom = TrinomConstructor.randomNiceRoots(randint(1, 3));
32
+ const identifiers = { a: trinom.a, b: trinom.b, c: trinom.c };
19
33
  const question = {
20
- answer,
21
- instruction: `Déterminer graphiquement le ou les racine(s) du polynôme du second degré représenté ci-dessous : `,
34
+ answer: getAnswer(identifiers),
35
+ instruction: getInstruction(identifiers),
22
36
  keys: ["et", "aucun"],
23
37
  answerFormat: "tex",
24
- ggbOptions: ggb.getOptions({ coords: trinom.getCoords() }),
25
- identifiers: { a: trinom.a, b: trinom.b, c: trinom.c },
38
+ ggbOptions: getGGBOptions(identifiers),
39
+ identifiers,
26
40
  };
27
41
  return question;
28
42
  };
@@ -60,4 +74,7 @@ export const rootsReading = {
60
74
  isAnswerValid,
61
75
  hasGeogebra: true,
62
76
  subject: "Mathématiques",
77
+ getInstruction,
78
+ getAnswer,
79
+ getGGBOptions,
63
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"summitReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/summitAndCanonical/summitReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuDF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAa/C,CAAC"}
1
+ {"version":3,"file":"summitReading.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/functions/trinoms/summitAndCanonical/summitReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsEF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAgB/C,CAAC"}
@@ -5,8 +5,18 @@ import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor
5
5
  import { Point } from "../../../../../math/geometry/point.js";
6
6
  import { Trinom, TrinomConstructor } from "../../../../../math/polynomials/trinom.js";
7
7
  import { randint } from "../../../../../math/utils/random/randint.js";
8
- const getSummitReadingQuestion = () => {
9
- const trinom = TrinomConstructor.randomCanonical();
8
+ const getInstruction = (identifiers) => {
9
+ return `Déterminer les coordonnées du sommet de la parabole représentée ci-dessous :`;
10
+ };
11
+ const getAnswer = (identifiers) => {
12
+ const { a, b, c } = identifiers;
13
+ const trinom = new Trinom(a, b, c);
14
+ const answer = trinom.getSommet().toCoords();
15
+ return answer;
16
+ };
17
+ const getGGBOptions = (identifiers) => {
18
+ const { a, b, c } = identifiers;
19
+ const trinom = new Trinom(a, b, c);
10
20
  const commands = [
11
21
  `f(x) = ${trinom.toMathString()}`,
12
22
  `SetColor(f, "${randomColor()}")`,
@@ -15,16 +25,20 @@ const getSummitReadingQuestion = () => {
15
25
  commands,
16
26
  isGridSimple: true,
17
27
  });
18
- const answer = trinom.getSommet().toCoords();
28
+ return ggb.getOptions({
29
+ coords: trinom.getCoords(),
30
+ });
31
+ };
32
+ const getSummitReadingQuestion = () => {
33
+ const trinom = TrinomConstructor.randomCanonical();
34
+ const identifiers = { a: trinom.a, b: trinom.b, c: trinom.c };
19
35
  const question = {
20
- answer,
21
- instruction: `Déterminer les coordonnées du sommet de la parabole représentée ci-dessous :`,
36
+ answer: getAnswer(identifiers),
37
+ instruction: getInstruction(identifiers),
22
38
  keys: ["leftParenthesis", "semicolon", "rightParenthesis"],
23
- ggbOptions: ggb.getOptions({
24
- coords: trinom.getCoords(),
25
- }),
39
+ ggbOptions: getGGBOptions(identifiers),
26
40
  answerFormat: "tex",
27
- identifiers: { a: trinom.a, b: trinom.b, c: trinom.c },
41
+ identifiers,
28
42
  };
29
43
  return question;
30
44
  };
@@ -56,4 +70,7 @@ export const summitReading = {
56
70
  isAnswerValid,
57
71
  hasGeogebra: true,
58
72
  subject: "Mathématiques",
73
+ getInstruction,
74
+ getAnswer,
75
+ getGGBOptions,
59
76
  };
@@ -1 +1 @@
1
- {"version":3,"file":"convexityQuadrinomialsGeo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAsBrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AA8JF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAc3D,CAAC"}
1
+ {"version":3,"file":"convexityQuadrinomialsGeo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/convexity/convexityQuadrinomialsGeo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAsBrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AA+KF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,CAiB3D,CAAC"}
@@ -32,33 +32,39 @@ function generateEvenInflexionPoint() {
32
32
  } while (inflexionPointX % 10 !== 0);
33
33
  return inflexionPointX;
34
34
  }
35
- const getConvexityQuadrinomialsGeoQuestion = () => {
36
- const inflexionPointX = generateEvenInflexionPoint() * 0.1;
37
- const quadrinomial = generatePolynomialWithIntegerInflexionPoint(3, inflexionPointX);
38
- const quadcoeffs = quadrinomial.coefficients;
39
- const trinomial = quadrinomial.derivate();
40
- const criticalPoints = trinomial.getRoots();
41
- const yValues = criticalPoints.map((x) => quadrinomial.calculate(x));
42
- const xMin = Math.min(...criticalPoints) - 5;
43
- const xMax = Math.max(...criticalPoints) + 5;
44
- const yMin = Math.min(...yValues, 0) - 5;
45
- const yMax = Math.max(...yValues, 0) + 5;
46
- const askConvex = coinFlip();
35
+ const getInstruction = (identifiers) => {
36
+ const { askConvex, inflexionPoint, quadcoeffs } = identifiers;
37
+ const questionType = askConvex ? "convexe" : "concave";
38
+ const instruction = `Ci-dessous est tracée la courbe représentative $\\mathcal C_f$ d'une fonction $f$. Sur quel intervalle $f$ est-elle ${questionType} ?`;
39
+ return instruction;
40
+ };
41
+ const getAnswer = (identifiers) => {
42
+ const { askConvex, inflexionPoint, quadcoeffs } = identifiers;
47
43
  let interval;
48
44
  if (askConvex) {
49
45
  interval =
50
46
  quadcoeffs[3] > 0
51
- ? new IntervalNode(inflexionPointX.toTree(), PlusInfinityNode, ClosureType.OO).toTex()
52
- : new IntervalNode(MinusInfinityNode, inflexionPointX.toTree(), ClosureType.OO).toTex();
47
+ ? new IntervalNode(inflexionPoint.toTree(), PlusInfinityNode, ClosureType.OO).toTex()
48
+ : new IntervalNode(MinusInfinityNode, inflexionPoint.toTree(), ClosureType.OO).toTex();
53
49
  }
54
50
  else {
55
51
  interval =
56
52
  quadcoeffs[3] <= 0
57
- ? new IntervalNode(inflexionPointX.toTree(), PlusInfinityNode, ClosureType.OO).toTex()
58
- : new IntervalNode(MinusInfinityNode, inflexionPointX.toTree(), ClosureType.OO).toTex();
53
+ ? new IntervalNode(inflexionPoint.toTree(), PlusInfinityNode, ClosureType.OO).toTex()
54
+ : new IntervalNode(MinusInfinityNode, inflexionPoint.toTree(), ClosureType.OO).toTex();
59
55
  }
60
- const questionType = askConvex ? "convexe" : "concave";
61
- const instruction = `Ci-dessous est tracée la courbe représentative $\\mathcal C_f$ d'une fonction $f$. Sur quel intervalle $f$ est-elle ${questionType} ?`;
56
+ return interval;
57
+ };
58
+ const getGGBOptions = (identifiers) => {
59
+ const { askConvex, inflexionPoint, quadcoeffs } = identifiers;
60
+ const quadrinomial = new Polynomial(quadcoeffs);
61
+ const trinomial = quadrinomial.derivate();
62
+ const criticalPoints = trinomial.getRoots();
63
+ const yValues = criticalPoints.map((x) => quadrinomial.calculate(x));
64
+ const xMin = Math.min(...criticalPoints) - 5;
65
+ const xMax = Math.max(...criticalPoints) + 5;
66
+ const yMin = Math.min(...yValues, 0) - 5;
67
+ const yMax = Math.max(...yValues, 0) + 5;
62
68
  const commands = [
63
69
  `f(x) = ${quadrinomial.toMathString()}`,
64
70
  `SetColor(f, "${blueMain}")`,
@@ -69,15 +75,27 @@ const getConvexityQuadrinomialsGeoQuestion = () => {
69
75
  commands,
70
76
  lockedAxesRatio: false,
71
77
  });
78
+ return ggb.getOptions({
79
+ coords: [xMin, xMax, yMin, yMax],
80
+ });
81
+ };
82
+ const getConvexityQuadrinomialsGeoQuestion = () => {
83
+ const inflexionPointX = generateEvenInflexionPoint() * 0.1;
84
+ const quadrinomial = generatePolynomialWithIntegerInflexionPoint(3, inflexionPointX);
85
+ const quadcoeffs = quadrinomial.coefficients;
86
+ const askConvex = coinFlip();
87
+ const identifiers = {
88
+ askConvex,
89
+ quadcoeffs,
90
+ inflexionPoint: inflexionPointX,
91
+ };
72
92
  const question = {
73
- answer: interval,
74
- instruction,
75
- ggbOptions: ggb.getOptions({
76
- coords: [xMin, xMax, yMin, yMax],
77
- }),
93
+ answer: getAnswer(identifiers),
94
+ instruction: getInstruction(identifiers),
95
+ ggbOptions: getGGBOptions(identifiers),
78
96
  keys: ["rbracket", "lbracket", "semicolon", "infty", "reals"],
79
97
  answerFormat: "tex",
80
- identifiers: { askConvex, quadcoeffs, inflexionPoint: inflexionPointX },
98
+ identifiers,
81
99
  };
82
100
  return question;
83
101
  };
@@ -118,4 +136,7 @@ export const convexityQuadrinomialsGeo = {
118
136
  isAnswerValid,
119
137
  subject: "Mathématiques",
120
138
  hasGeogebra: true,
139
+ getInstruction,
140
+ getAnswer,
141
+ getGGBOptions,
121
142
  };
@@ -1 +1 @@
1
- {"version":3,"file":"convexityTrinomialsGeo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/convexity/convexityTrinomialsGeo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAkDF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAexD,CAAC"}
1
+ {"version":3,"file":"convexityTrinomialsGeo.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/convexity/convexityTrinomialsGeo.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAmEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAkBxD,CAAC"}
@@ -2,11 +2,18 @@ import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { blueMain } from "../../../../geogebra/colors.js";
4
4
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
5
- import { TrinomConstructor } from "../../../../math/polynomials/trinom.js";
5
+ import { Trinom, TrinomConstructor } from "../../../../math/polynomials/trinom.js";
6
6
  import { shuffle } from "../../../../utils/alea/shuffle.js";
7
- const getConvexityTrinomialsGeoQuestion = () => {
8
- const trinom = TrinomConstructor.random();
9
- const instruction = `Ci-dessous est tracée la courbe représentative $\\mathcal C_f$ d'une fonction $f$. Sur $\\mathbb{R}$, la fonction $f$ est :`;
7
+ const getInstruction = (identifiers) => {
8
+ return `Ci-dessous est tracée la courbe représentative $\\mathcal C_f$ d'une fonction $f$. Sur $\\mathbb{R}$, la fonction $f$ est :`;
9
+ };
10
+ const getAnswer = (identifiers) => {
11
+ const trinom = new Trinom(identifiers.trinom[0], identifiers.trinom[1], identifiers.trinom[2]);
12
+ const isConvex = trinom.a > 0 ? "Convexe" : "Concave";
13
+ return isConvex;
14
+ };
15
+ const getGGBOptions = (identifiers) => {
16
+ const trinom = new Trinom(identifiers.trinom[0], identifiers.trinom[1], identifiers.trinom[2]);
10
17
  const commands = [
11
18
  `f(x) = ${trinom.toMathString()}`,
12
19
  `SetColor(f, "${blueMain}")`,
@@ -17,16 +24,20 @@ const getConvexityTrinomialsGeoQuestion = () => {
17
24
  commands,
18
25
  lockedAxesRatio: false,
19
26
  });
20
- const isConvex = trinom.a > 0 ? "Convexe" : "Concave";
27
+ return ggb.getOptions({
28
+ coords: trinom.getCoords(),
29
+ });
30
+ };
31
+ const getConvexityTrinomialsGeoQuestion = () => {
32
+ const trinom = TrinomConstructor.random();
33
+ const identifiers = { trinom: [trinom.a, trinom.b, trinom.c] };
21
34
  const question = {
22
- answer: isConvex,
23
- instruction,
24
- ggbOptions: ggb.getOptions({
25
- coords: trinom.getCoords(),
26
- }),
35
+ answer: getAnswer(identifiers),
36
+ instruction: getInstruction(identifiers),
37
+ ggbOptions: getGGBOptions(identifiers),
27
38
  keys: [],
28
39
  answerFormat: "raw",
29
- identifiers: { trinom: [trinom.a, trinom.b, trinom.c] },
40
+ identifiers,
30
41
  };
31
42
  return question;
32
43
  };
@@ -57,4 +68,7 @@ export const convexityTrinomialsGeo = {
57
68
  isAnswerValid,
58
69
  hasGeogebra: true,
59
70
  subject: "Mathématiques",
71
+ getInstruction,
72
+ getAnswer,
73
+ getGGBOptions,
60
74
  };
package/lib/index.d.ts CHANGED
@@ -163,6 +163,8 @@ declare const mathExercises: (Exercise<{
163
163
  }> | Exercise<{
164
164
  xValues: number[];
165
165
  yValues: number[];
166
+ }, {}> | Exercise<{
167
+ lengths: number[];
166
168
  }, {}> | Exercise<{
167
169
  precisionAsked: number;
168
170
  decimal: number;
@@ -539,6 +541,7 @@ declare const mathExercises: (Exercise<{
539
541
  coefficients: number[];
540
542
  }, {}> | Exercise<{
541
543
  a: number;
544
+ c: number;
542
545
  coin: number;
543
546
  racine1: number;
544
547
  racine2: number;
@@ -592,6 +595,7 @@ declare const mathExercises: (Exercise<{
592
595
  }, {}> | Exercise<{
593
596
  A: number[];
594
597
  B: number[];
598
+ coeffs: number[];
595
599
  }, {}> | Exercise<{
596
600
  xA: number;
597
601
  yA: number;
@@ -1886,6 +1890,7 @@ declare const pcExercises: (Exercise<{
1886
1890
  }, {}> | Exercise<{
1887
1891
  A: number[];
1888
1892
  B: number[];
1893
+ coeffs: number[];
1889
1894
  }, {}> | Exercise<{
1890
1895
  a: number;
1891
1896
  }, {}> | Exercise<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"latexTester.d.ts","sourceRoot":"","sources":["../src/latexTester.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,2CAkJxC,CAAC"}
1
+ {"version":3,"file":"latexTester.d.ts","sourceRoot":"","sources":["../src/latexTester.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,2CAsJxC,CAAC"}
@@ -5,11 +5,12 @@ export const latexTester = (latex, isDefaultInMathMode = false) => {
5
5
  let leftRightCount = 0;
6
6
  let inArray = false;
7
7
  let inPython = false;
8
- for (let i = 0; i < latex.length; i++) {
9
- const prevChar = latex[i - 1];
10
- const char = latex[i];
11
- const nextChar = latex[i + 1];
12
- const nextNextChar = latex[i + 2];
8
+ const formated = latex.replace(/<svg[\s\S]*?<\/svg>/g, "");
9
+ for (let i = 0; i < formated.length; i++) {
10
+ const prevChar = formated[i - 1];
11
+ const char = formated[i];
12
+ const nextChar = formated[i + 1];
13
+ const nextNextChar = formated[i + 2];
13
14
  if (char === "$") {
14
15
  if (isDefaultInMathMode)
15
16
  throw new Error("Dollar in default math mode");
@@ -63,13 +64,13 @@ export const latexTester = (latex, isDefaultInMathMode = false) => {
63
64
  if (char === "}" && prevChar !== "\\" && !inPython) {
64
65
  commandModeCount--;
65
66
  }
66
- const substring = latex.substring(i);
67
+ const substring = formated.substring(i);
67
68
  if ((inDollarMode || inDoubleDollarMode) && char === "\n") {
68
69
  let isEmptyLine = true;
69
- for (let j = i + 1; j < latex.length; j++) {
70
- if (latex[j] === "\n")
70
+ for (let j = i + 1; j < formated.length; j++) {
71
+ if (formated[j] === "\n")
71
72
  break;
72
- if (latex[j] !== " " && latex[j] !== "\t") {
73
+ if (formated[j] !== " " && formated[j] !== "\t") {
73
74
  isEmptyLine = false;
74
75
  break;
75
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAcpE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAa5D,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IActD;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAY;IAoBxB,MAAM,CAAC,4BAA4B,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAY;IAqBxB,MA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M,GAAG,MAAM;IAO5B,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM;IAiB7C,YAAY,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU;IAiBxC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW;IAuCzB,KAAK,IAAI,MAAM;IA0Bf,YAAY,IAAI,MAAM;CAGvB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.16",
4
+ "version": "3.0.18",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [