math-exercises 3.0.87 → 3.0.88

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.
@@ -10,4 +10,5 @@ export * from "./inverseImageFunctionTable.js";
10
10
  export * from "./imageAntecedentFromSentence.js";
11
11
  export * from "./graphicInequationAffine.js";
12
12
  export * from "./valueTableCompletion.js";
13
+ export * from "./valueTableFromGraph.js";
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC"}
@@ -10,3 +10,4 @@ export * from "./inverseImageFunctionTable.js";
10
10
  export * from "./imageAntecedentFromSentence.js";
11
11
  export * from "./graphicInequationAffine.js";
12
12
  export * from "./valueTableCompletion.js";
13
+ export * from "./valueTableFromGraph.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ points: number[][];
4
+ initTable: string[][];
5
+ };
6
+ export declare const valueTableFromGraph: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=valueTableFromGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valueTableFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/valueTableFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;CACvB,CAAC;AAkIF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAmBrD,CAAC"}
@@ -0,0 +1,139 @@
1
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
2
+ import { randomColor } from "../../../../geogebra/colors.js";
3
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
4
+ import { Point } from "../../../../math/geometry/point.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { numberParser } from "../../../../tree/parsers/numberParser.js";
7
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
9
+ const getAnswerTable = (identifiers) => {
10
+ const { points, initTable } = identifiers;
11
+ const answerTable = [[], []];
12
+ for (let j = 1; j < initTable[0].length; j++) {
13
+ if (initTable[0][j] === "") {
14
+ answerTable[0].push(points
15
+ .find((p) => p[1] === Number(initTable[1][j]))[0]
16
+ .toTree()
17
+ .toTex());
18
+ answerTable[1].push(initTable[1][j]);
19
+ }
20
+ else {
21
+ answerTable[1].push(points
22
+ .find((p) => p[0] === Number(initTable[0][j]))[1]
23
+ .toTree()
24
+ .toTex());
25
+ answerTable[0].push(initTable[0][j]);
26
+ }
27
+ }
28
+ return [
29
+ ["x", ...answerTable[0]],
30
+ ["f(x)", ...answerTable[1]],
31
+ ];
32
+ };
33
+ const getInstruction = (identifiers) => {
34
+ return `Soit $f$ la fonction dont la courbe représentative est tracée ci-dessous.
35
+
36
+ Compléter le tableau de valeurs de $f$.`;
37
+ };
38
+ const getGGBOptions = (identifiers) => {
39
+ const ggb = new GeogebraConstructor({
40
+ commands: [
41
+ `S = Spline(${identifiers.points
42
+ .map((point) => `(${point[0]},${point[1]})`)
43
+ .join(",")})`,
44
+ "SetFixed(S, true)",
45
+ `SetColor(S, "${randomColor()}")`,
46
+ ],
47
+ });
48
+ return ggb.getOptions({
49
+ coords: ggb.getCoordsForPoints(identifiers.points.map((point) => new Point("A", point[0], point[1]))),
50
+ });
51
+ };
52
+ const getHint = (identifiers) => {
53
+ return "Dans un tableau de valeurs, la deuxième ligne contient les images de la première ligne par la fonction $f$. Pour trouver une case de la deuxième ligne, il faut donc lire graphiquement l'image du nombre de la première ligne par la fonction $f$.";
54
+ };
55
+ const getCorrection = (identifiers) => {
56
+ return `
57
+ On lit graphiquement que :
58
+
59
+ ${identifiers.points.map((p) => `- $f(${p[0]}) = ${p[1]}$`).join("\n")}
60
+
61
+ Le tableau de valeurs complété est donc :
62
+
63
+ ${mdTable(getAnswerTable(identifiers), true)}
64
+
65
+ `;
66
+ };
67
+ const getKeys = (identifiers) => {
68
+ return [];
69
+ };
70
+ const isAnswerTableValid = (ans, { answerTable }) => {
71
+ try {
72
+ for (let i = 0; i < 2; i++) {
73
+ for (let j = 1; j < ans[i].length; j++) {
74
+ const ansParsed = numberParser(ans[i][j]);
75
+ const answerParsed = numberParser(answerTable[i][j]);
76
+ const valid = ansParsed === answerParsed;
77
+ if (!valid)
78
+ return false;
79
+ }
80
+ }
81
+ return true;
82
+ }
83
+ catch (err) {
84
+ return handleVEAError(err);
85
+ }
86
+ };
87
+ const getValueTableFromGraphQuestion = (ops) => {
88
+ const xs = [randint(-10, -5), randint(-5, 0), randint(0, 5), randint(6, 10)];
89
+ const points = [[xs[0], randint(-9, 10)]];
90
+ for (let i = 1; i < xs.length; i++) {
91
+ let y = points[i - 1][1] + randint(-5, 6);
92
+ points.push([xs[i], y]);
93
+ }
94
+ let stringXs = points.map((p) => p[0].toString());
95
+ const ys = [];
96
+ for (let i = 0; i < stringXs.length; i++) {
97
+ ys.push("");
98
+ }
99
+ const initTable = [
100
+ ["x", ...stringXs],
101
+ ["f(x)", ...ys],
102
+ ];
103
+ const identifiers = {
104
+ points: points,
105
+ initTable,
106
+ };
107
+ return getQuestionFromIdentifiers(identifiers);
108
+ };
109
+ const getQuestionFromIdentifiers = (identifiers) => {
110
+ return {
111
+ answerTable: getAnswerTable(identifiers),
112
+ instruction: getInstruction(identifiers),
113
+ keys: getKeys(identifiers),
114
+ answerFormat: "tex",
115
+ identifiers,
116
+ hint: getHint(identifiers),
117
+ correction: getCorrection(identifiers),
118
+ initTable: identifiers.initTable,
119
+ ggbOptions: getGGBOptions(identifiers),
120
+ };
121
+ };
122
+ export const valueTableFromGraph = {
123
+ id: "valueTableFromGraph",
124
+ connector: "=",
125
+ label: "Compléter un tableau de valeurs d'une fonction à partir d'un graphique",
126
+ isSingleStep: true,
127
+ generator: (nb, opts) => getDistinctQuestions(() => getValueTableFromGraphQuestion(opts), nb),
128
+ valueTableTimer: 120,
129
+ subject: "Mathématiques",
130
+ getInstruction,
131
+ getHint,
132
+ getCorrection,
133
+ getAnswerTable,
134
+ getQuestionFromIdentifiers,
135
+ hasHintAndCorrection: true,
136
+ answerType: "valueTable",
137
+ isAnswerTableValid,
138
+ hasGeogebra: true,
139
+ };
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ evolutions: number[];
4
+ };
5
+ export declare const globalCM: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=globalCM.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalCM.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/globalCM.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAoFF,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAmB1C,CAAC"}
@@ -0,0 +1,89 @@
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 { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
9
+ const getPropositions = (n, { answer }) => {
10
+ const propositions = [];
11
+ addValidProp(propositions, answer);
12
+ while (propositions.length < n) {
13
+ tryToAddWrongProp(propositions, randfloat(0, 2, 4).frenchify());
14
+ }
15
+ return shuffleProps(propositions, n);
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { evolutions } = identifiers;
19
+ const cms = evolutions.map((e) => round(1 + e / 100, 4));
20
+ return round(cms.reduce((acc, curr) => acc * curr, 1), 4).frenchify();
21
+ };
22
+ const getInstruction = (identifiers) => {
23
+ const { evolutions } = identifiers;
24
+ return `Déterminer le coefficient multiplicateur associé à une ${evolutions[0] > 0 ? "hausse" : "baisse"} de $${Math.abs(evolutions[0])}\\%$ suivie d'une ${evolutions[1] > 0 ? "hausse" : "baisse"} de $${Math.abs(evolutions[1])}\\%$. `;
25
+ };
26
+ const getHint = (identifiers) => {
27
+ return `Détermine les coefficients multiplicateurs de chacune des évolutions. Puis, multiplie ces coefficients multiplicateurs.`;
28
+ };
29
+ const getCorrection = (identifiers) => {
30
+ const { evolutions } = identifiers;
31
+ const cms = evolutions.map((e) => round(1 + e / 100, 4));
32
+ return `Le coefficient multiplicateur associé à une ${evolutions[0] > 0 ? "hausse" : "baisse"} de $${Math.abs(evolutions[0])}\\%$ est $${cms[0].frenchify()}$.
33
+
34
+ Le coefficient multiplicateur associé à une ${evolutions[1] > 0 ? "hausse" : "baisse"} de $${Math.abs(evolutions[1])}\\%$ est $${cms[1].frenchify()}$.
35
+
36
+ Pour déterminer le coefficient multiplicateur global, on multiplie ces deux coefficients multiplicateurs :
37
+
38
+ $$
39
+ ${multiply(cms[0], cms[1]).toTex()}=${getAnswer(identifiers)}
40
+ $$
41
+ `;
42
+ };
43
+ const getKeys = (identifiers) => {
44
+ return [];
45
+ };
46
+ const isAnswerValid = (ans, { answer }) => {
47
+ try {
48
+ return numberVEA(ans, answer);
49
+ }
50
+ catch (err) {
51
+ return handleVEAError(err);
52
+ }
53
+ };
54
+ const getGlobalCmQuestion = (ops) => {
55
+ const evolutions = [randint(-99, 101, [0]), randint(-99, 101, [0])];
56
+ const identifiers = {
57
+ evolutions,
58
+ };
59
+ return getQuestionFromIdentifiers(identifiers);
60
+ };
61
+ const getQuestionFromIdentifiers = (identifiers) => {
62
+ return {
63
+ answer: getAnswer(identifiers),
64
+ instruction: getInstruction(identifiers),
65
+ keys: getKeys(identifiers),
66
+ answerFormat: "tex",
67
+ identifiers,
68
+ hint: getHint(identifiers),
69
+ correction: getCorrection(identifiers),
70
+ };
71
+ };
72
+ export const globalCM = {
73
+ id: "globalCM",
74
+ connector: "=",
75
+ label: "Calculer le coefficient multiplicateur associé à deux évolutions successives",
76
+ isSingleStep: true,
77
+ generator: (nb, opts) => getDistinctQuestions(() => getGlobalCmQuestion(opts), nb),
78
+ qcmTimer: 60,
79
+ freeTimer: 60,
80
+ getPropositions,
81
+ isAnswerValid,
82
+ subject: "Mathématiques",
83
+ getInstruction,
84
+ getHint,
85
+ getCorrection,
86
+ getAnswer,
87
+ getQuestionFromIdentifiers,
88
+ hasHintAndCorrection: true,
89
+ };
@@ -8,4 +8,5 @@ export * from "./evolutionRateFromValues.js";
8
8
  export * from "./findStartValueAfterEvolution.js";
9
9
  export * from "./findEndValueAfterEvolution.js";
10
10
  export * from "./findRightCalculForPriceEvolution.js";
11
+ export * from "./globalCM.js";
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/percent/evolutions/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,eAAe,CAAC"}
@@ -8,3 +8,4 @@ export * from "./evolutionRateFromValues.js";
8
8
  export * from "./findStartValueAfterEvolution.js";
9
9
  export * from "./findEndValueAfterEvolution.js";
10
10
  export * from "./findRightCalculForPriceEvolution.js";
11
+ export * from "./globalCM.js";
@@ -9,4 +9,5 @@ export * from "./populationEffectifFromSubPopulation.js";
9
9
  export * from "./percentWritings.js";
10
10
  export * from "./evolutions/index.js";
11
11
  export * from "./interests/index.js";
12
+ export * from "./percentOfPercent.js";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,uCAAuC,CAAC;AACtD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,uCAAuC,CAAC;AACtD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
@@ -9,3 +9,4 @@ export * from "./populationEffectifFromSubPopulation.js";
9
9
  export * from "./percentWritings.js";
10
10
  export * from "./evolutions/index.js";
11
11
  export * from "./interests/index.js";
12
+ export * from "./percentOfPercent.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ export declare const percentOfPercent: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=percentOfPercent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percentOfPercent.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/percentOfPercent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA0EF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAkBlD,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randfloat } from "../../../math/utils/random/randfloat.js";
4
+ import { randint } from "../../../math/utils/random/randint.js";
5
+ import { round } from "../../../math/utils/round.js";
6
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
7
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
8
+ import { percentParser } from "../../../tree/parsers/percentParser.js";
9
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
10
+ const getPropositions = (n, { answer }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer);
13
+ while (propositions.length < n) {
14
+ tryToAddWrongProp(propositions, randfloat(1, 100, 2).frenchify() + "\\%");
15
+ }
16
+ return shuffleProps(propositions, n);
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { x, y } = identifiers;
20
+ return `${round((x / 100) * y, 4).frenchify()}\\%`;
21
+ };
22
+ const getInstruction = (identifiers) => {
23
+ const { x, y } = identifiers;
24
+ return `Quel pourcentage est égal à $${x}\\ \\%$ de $${y}\\ \\%$ ?`;
25
+ };
26
+ const getHint = (identifiers) => {
27
+ return `Pour calculer $x\\%$ de $y\\%$, tu peux multiplier les deux pourcentages.`;
28
+ };
29
+ const getCorrection = (identifiers) => {
30
+ const { x, y } = identifiers;
31
+ return `On calcule $${x}\\%$ de $${y}$ :
32
+
33
+ $$
34
+ ${multiply(frac(x, 100), y).toTex()} = ${round((x / 100) * y, 4).frenchify()}
35
+ $$
36
+
37
+ Le pourcentage égal à $${x}\\%$ de $${y}\\%$ est donc $${getAnswer(identifiers)}$.
38
+
39
+ `;
40
+ };
41
+ const getKeys = (identifiers) => {
42
+ return ["percent"];
43
+ };
44
+ const isAnswerValid = (ans, { answer }) => {
45
+ try {
46
+ const parsed = percentParser(ans);
47
+ if (!parsed)
48
+ return false;
49
+ return parsed === answer;
50
+ }
51
+ catch (err) {
52
+ return handleVEAError(err);
53
+ }
54
+ };
55
+ const getPercentOfPercentQuestion = (ops) => {
56
+ const x = randint(1, 100);
57
+ const y = randint(1, 100);
58
+ const identifiers = { x, y };
59
+ return getQuestionFromIdentifiers(identifiers);
60
+ };
61
+ const getQuestionFromIdentifiers = (identifiers) => {
62
+ return {
63
+ answer: getAnswer(identifiers),
64
+ instruction: getInstruction(identifiers),
65
+ keys: getKeys(identifiers),
66
+ answerFormat: "tex",
67
+ identifiers,
68
+ hint: getHint(identifiers),
69
+ correction: getCorrection(identifiers),
70
+ };
71
+ };
72
+ export const percentOfPercent = {
73
+ id: "percentOfPercent",
74
+ connector: "=",
75
+ label: "Calculer un pourcentage de pourcentage",
76
+ isSingleStep: true,
77
+ generator: (nb, opts) => getDistinctQuestions(() => getPercentOfPercentQuestion(opts), nb),
78
+ qcmTimer: 60,
79
+ freeTimer: 60,
80
+ getPropositions,
81
+ isAnswerValid,
82
+ subject: "Mathématiques",
83
+ getInstruction,
84
+ getHint,
85
+ getCorrection,
86
+ getAnswer,
87
+ getQuestionFromIdentifiers,
88
+ hasHintAndCorrection: true,
89
+ };
@@ -1,7 +1,8 @@
1
1
  import { Point } from "../math/geometry/point.js";
2
2
  import { IntervalNode } from "../tree/nodes/sets/intervalNode.js";
3
3
  export declare abstract class SplineConstructor {
4
- random(): Spline;
4
+ static random(): Spline;
5
+ static getAdequatePoints(nbOfPoints?: number): [number, number][];
5
6
  }
6
7
  export declare class Spline {
7
8
  points: number[][];
@@ -1 +1 @@
1
- {"version":3,"file":"spline.d.ts","sourceRoot":"","sources":["../../src/geogebra/spline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAIrD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAKrE,8BAAsB,iBAAiB;IACrC,MAAM;CAQP;AACD,qBAAa,MAAM;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;gBAEP,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE;IAuDpD,WAAW;CAUZ"}
1
+ {"version":3,"file":"spline.d.ts","sourceRoot":"","sources":["../../src/geogebra/spline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAIrD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAKrE,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,MAAM;IASb,MAAM,CAAC,iBAAiB,CAAC,UAAU,SAAI;CAsCxC;AACD,qBAAa,MAAM;IACjB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;gBAEP,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE;IAuDpD,WAAW;CAUZ"}
@@ -2,14 +2,52 @@ import { randfloat } from "../math/utils/random/randfloat.js";
2
2
  import { randint } from "../math/utils/random/randint.js";
3
3
  import { ClosureType } from "../tree/nodes/sets/closure.js";
4
4
  import { IntervalNode } from "../tree/nodes/sets/intervalNode.js";
5
+ import { coinFlip } from "../utils/alea/coinFlip.js";
5
6
  import { doWhile } from "../utils/doWhile.js";
6
7
  import { randomColor } from "./colors.js";
7
8
  export class SplineConstructor {
8
- random() {
9
+ static random() {
9
10
  const a = randint(-10, 0);
10
11
  const b = doWhile(() => randint(0, 10), (x) => Math.abs(x - a) < 5);
11
12
  return new Spline(new IntervalNode(a.toTree(), b.toTree(), ClosureType.FF));
12
13
  }
14
+ static getAdequatePoints(nbOfPoints = 4) {
15
+ let xSolutions = [];
16
+ const nb = nbOfPoints;
17
+ // const nb = 2;
18
+ for (let i = 0; i < nb; i++) {
19
+ xSolutions.push(randint(-9, 10, xSolutions));
20
+ }
21
+ xSolutions.sort((a, b) => a - b);
22
+ const yValue = randint(-5, 6);
23
+ const splinePoints = [];
24
+ let prevYWasAbove = coinFlip();
25
+ if (coinFlip()) {
26
+ const y = prevYWasAbove ? randint(-2, 0) : randint(1, 3);
27
+ prevYWasAbove = y > 0;
28
+ splinePoints.push([xSolutions[0] - (1 + Math.random() * 3), yValue + y]);
29
+ }
30
+ for (let i = 0; i < xSolutions.length; i++) {
31
+ splinePoints.push([xSolutions[i], yValue]);
32
+ if (i < xSolutions.length - 1) {
33
+ const mid = (xSolutions[i] + xSolutions[i + 1]) / 2;
34
+ const distance = xSolutions[i + 1] - xSolutions[i];
35
+ const x = mid + ((Math.random() * 2) / 5) * (distance / 2);
36
+ const y = prevYWasAbove ? randint(-2, 0) : randint(1, 3);
37
+ prevYWasAbove = y > 0;
38
+ splinePoints.push([x, yValue + y]);
39
+ }
40
+ }
41
+ if (coinFlip() || splinePoints.length < 4) {
42
+ const y = prevYWasAbove ? randint(-2, 0) : randint(1, 3);
43
+ prevYWasAbove = y > 0;
44
+ splinePoints.push([
45
+ xSolutions[xSolutions.length - 1] + (1 + Math.random() * 3),
46
+ yValue + y,
47
+ ]);
48
+ }
49
+ return splinePoints;
50
+ }
13
51
  }
14
52
  export class Spline {
15
53
  points;
package/lib/index.d.ts CHANGED
@@ -900,6 +900,9 @@ declare const mathExercises: (Exercise<{
900
900
  }, {}> | Exercise<{
901
901
  coeffs: number[];
902
902
  initTable: string[][];
903
+ }, {}> | Exercise<{
904
+ points: number[][];
905
+ initTable: string[][];
903
906
  }, {}> | Exercise<{
904
907
  k: number;
905
908
  }, {}> | Exercise<{
@@ -1681,6 +1684,8 @@ declare const mathExercises: (Exercise<{
1681
1684
  price: number;
1682
1685
  evolution: number;
1683
1686
  askingFinalPrice: boolean;
1687
+ }, {}> | Exercise<{
1688
+ evolutions: number[];
1684
1689
  }, {}> | Exercise<{
1685
1690
  initialCapital: number;
1686
1691
  rate: number;
@@ -1694,6 +1699,9 @@ declare const mathExercises: (Exercise<{
1694
1699
  }, {
1695
1700
  withFormula?: boolean;
1696
1701
  }> | Exercise<{
1702
+ x: number;
1703
+ y: number;
1704
+ }, {}> | Exercise<{
1697
1705
  int: number;
1698
1706
  power: number;
1699
1707
  }, {}> | 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;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.87",
4
+ "version": "3.0.88",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [