math-exercises 2.2.47 → 2.2.49

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 (55) hide show
  1. package/lib/exercises/exercise.d.ts +5 -1
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts +1 -1
  4. package/lib/exercises/math/calcul/fractions/fractionsSum.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/fractionsSum.js +12 -4
  6. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/fractions/fractionsSumsMultiplesDenominators.js +33 -5
  8. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/fractions/fractionsSumsPrimeDenominators.js +39 -5
  10. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.d.ts.map +1 -1
  11. package/lib/exercises/math/calcul/fractions/fractionsSumsSameDenominators.js +33 -8
  12. package/lib/exercises/math/functions/affines/affineExpressionFromTwoImages.js +2 -2
  13. package/lib/exercises/math/geometry/index.d.ts +1 -0
  14. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  15. package/lib/exercises/math/geometry/index.js +1 -0
  16. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.d.ts +8 -0
  17. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.d.ts.map +1 -0
  18. package/lib/exercises/math/geometry/parametric/extractPointFromParametricLine.js +110 -0
  19. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts +8 -0
  20. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts.map +1 -0
  21. package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.js +108 -0
  22. package/lib/exercises/math/geometry/parametric/index.d.ts +4 -0
  23. package/lib/exercises/math/geometry/parametric/index.d.ts.map +1 -0
  24. package/lib/exercises/math/geometry/parametric/index.js +19 -0
  25. package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts +12 -0
  26. package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts.map +1 -0
  27. package/lib/exercises/math/geometry/parametric/pointFromParametricLine.js +95 -0
  28. package/lib/exercises/math/percent/reciprocalPercentage.js +1 -1
  29. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.d.ts.map +1 -1
  30. package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.js +66 -24
  31. package/lib/index.d.ts +14 -1
  32. package/lib/index.d.ts.map +1 -1
  33. package/lib/math/geometry/parametricLine.d.ts +15 -0
  34. package/lib/math/geometry/parametricLine.d.ts.map +1 -0
  35. package/lib/math/geometry/parametricLine.js +47 -0
  36. package/lib/math/geometry/spacePoint.d.ts +3 -0
  37. package/lib/math/geometry/spacePoint.d.ts.map +1 -1
  38. package/lib/math/geometry/spacePoint.js +12 -0
  39. package/lib/math/geometry/spaceVector.d.ts +5 -0
  40. package/lib/math/geometry/spaceVector.d.ts.map +1 -1
  41. package/lib/math/geometry/spaceVector.js +20 -0
  42. package/lib/server.js +7 -3
  43. package/lib/tree/parsers/rationalParser.d.ts +2 -0
  44. package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
  45. package/lib/tree/parsers/rationalParser.js +33 -8
  46. package/lib/tree/parsers/spacePointParser.d.ts +3 -0
  47. package/lib/tree/parsers/spacePointParser.d.ts.map +1 -0
  48. package/lib/tree/parsers/spacePointParser.js +18 -0
  49. package/lib/tree/parsers/spaceVectorParser.d.ts +3 -0
  50. package/lib/tree/parsers/spaceVectorParser.d.ts.map +1 -0
  51. package/lib/tree/parsers/spaceVectorParser.js +18 -0
  52. package/lib/tree/parsers/valueParser.d.ts +2 -0
  53. package/lib/tree/parsers/valueParser.d.ts.map +1 -0
  54. package/lib/tree/parsers/valueParser.js +10 -0
  55. package/package.json +1 -1
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractVectorFromParametricLine = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const parametricLine_1 = require("../../../../math/geometry/parametricLine");
7
+ const spacePoint_1 = require("../../../../math/geometry/spacePoint");
8
+ const spaceVector_1 = require("../../../../math/geometry/spaceVector");
9
+ const spaceVectorParser_1 = require("../../../../tree/parsers/spaceVectorParser");
10
+ const doWhile_1 = require("../../../../utils/doWhile");
11
+ const getPropositions = (n, { answer, startPoint, vector }) => {
12
+ const propositions = [];
13
+ (0, exercise_1.addValidProp)(propositions, answer);
14
+ const lineVector = spaceVector_1.SpaceVectorConstructor.fromScalars(vector);
15
+ while (propositions.length < n) {
16
+ const vector = (0, doWhile_1.doWhile)(() => spaceVector_1.SpaceVectorConstructor.random("A"), (v) => lineVector.isColinear(v));
17
+ (0, exercise_1.tryToAddWrongProp)(propositions, vector.toInlineCoordsTex());
18
+ }
19
+ return (0, exercise_1.shuffleProps)(propositions, n);
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const vector = spaceVector_1.SpaceVectorConstructor.fromScalars(identifiers.vector);
23
+ return vector.toInlineCoordsTex();
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const line = new parametricLine_1.ParametricLine(spacePoint_1.SpacePointConstructor.fromScalars(identifiers.startPoint), spaceVector_1.SpaceVectorConstructor.fromScalars(identifiers.vector));
27
+ return `Soit $d$ la droite d'équation paramétrique :
28
+
29
+ $$
30
+ ${line.toTex()}
31
+ $$
32
+
33
+ où $t\\in \\mathbb{R}$.
34
+
35
+ Donner les coordonnées d'un vecteur directeur de la droite $d$.
36
+ `;
37
+ };
38
+ // const getHint: GetHint<Identifiers> = (identifiers) => {
39
+ // return `Il suffit de remplacer $t$ par une valeur afin d'obtenir les coordonnées d'un point de la droite.`;
40
+ // };
41
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
42
+ // const line = new ParametricLine(
43
+ // SpacePointConstructor.fromScalars(identifiers.startPoint),
44
+ // SpaceVectorConstructor.fromScalars(identifiers.vector),
45
+ // );
46
+ // const detailedEquations = line.toDetailedEvaluation(new NumberNode(0));
47
+ // const point = line.getPointCoords(new NumberNode(0));
48
+ // return `Pour obtenir les coordonnées d'un point appartenant à la droite, il suffit de remplacer $t$ par n'importe quelle valeur dans les trois équations. Par simplicité, prenons $t = 0$. On obtient alors :
49
+ // $$
50
+ // \\left\\{\\begin{matrix}
51
+ // x=${detailedEquations[0].toTex()} \\\\
52
+ // y=${detailedEquations[1].toTex()} \\\\
53
+ // z=${detailedEquations[2].toTex()}
54
+ // \\end{matrix}
55
+ // \\right.
56
+ // $$
57
+ // On en déduit que le point de coordonnées $\\left(${point
58
+ // .map((e) => e.toTex())
59
+ // .join(";")}\\right)$ appartient à la droite $d$.`;
60
+ // };
61
+ const getKeys = (identifiers) => {
62
+ return ["semicolon"];
63
+ };
64
+ const isAnswerValid = (ans, { answer, startPoint, vector }) => {
65
+ try {
66
+ const v = spaceVector_1.SpaceVectorConstructor.fromScalars(vector);
67
+ const vecAnswer = (0, spaceVectorParser_1.spaceVectorParser)(ans);
68
+ if (!vecAnswer)
69
+ return false;
70
+ return v.isColinear(vecAnswer);
71
+ }
72
+ catch (err) {
73
+ return false;
74
+ }
75
+ };
76
+ const getExtractVectorFromParametricLineQuestion = () => {
77
+ const startPoint = spacePoint_1.SpacePointConstructor.random("A");
78
+ const vector = spaceVector_1.SpaceVectorConstructor.random("B");
79
+ const identifiers = {
80
+ startPoint: startPoint.getEvaluatedCoords(),
81
+ vector: vector.getEvaluatedCoords(),
82
+ };
83
+ const question = {
84
+ answer: getAnswer(identifiers),
85
+ instruction: getInstruction(identifiers),
86
+ keys: getKeys(identifiers),
87
+ answerFormat: "tex",
88
+ identifiers,
89
+ // hint: getHint(identifiers),
90
+ // correction: getCorrection(identifiers),
91
+ };
92
+ return question;
93
+ };
94
+ exports.extractVectorFromParametricLine = {
95
+ id: "extractVectorFromParametricLine",
96
+ connector: "=",
97
+ label: "Trouver un vecteur directeur d'une droite à partir de son équation paramétrique",
98
+ isSingleStep: true,
99
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getExtractVectorFromParametricLineQuestion, nb),
100
+ qcmTimer: 60,
101
+ freeTimer: 60,
102
+ getPropositions,
103
+ isAnswerValid,
104
+ subject: "Mathématiques",
105
+ // getHint,
106
+ // getCorrection,
107
+ getAnswer,
108
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./pointFromParametricLine";
2
+ export * from "./extractPointFromParametricLine";
3
+ export * from "./extractVectorFromParametricLine";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./pointFromParametricLine"), exports);
18
+ __exportStar(require("./extractPointFromParametricLine"), exports);
19
+ __exportStar(require("./extractVectorFromParametricLine"), exports);
@@ -0,0 +1,12 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ startPoint: number[];
4
+ vector: number[];
5
+ askedPointCoords: number[];
6
+ askedPointName: string;
7
+ isOnLine: boolean;
8
+ coeff?: number;
9
+ };
10
+ export declare const pointFromParametricLine: Exercise<Identifiers>;
11
+ export {};
12
+ //# sourceMappingURL=pointFromParametricLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointFromParametricLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/parametric/pointFromParametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAiBlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAqFF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAkBzD,CAAC"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pointFromParametricLine = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const parametricLine_1 = require("../../../../math/geometry/parametricLine");
7
+ const spacePoint_1 = require("../../../../math/geometry/spacePoint");
8
+ const spaceVector_1 = require("../../../../math/geometry/spaceVector");
9
+ const randint_1 = require("../../../../math/utils/random/randint");
10
+ const coinFlip_1 = require("../../../../utils/alea/coinFlip");
11
+ const randomLetter_1 = require("../../../../utils/strings/randomLetter");
12
+ const getPropositions = (n, { answer }) => {
13
+ const propositions = [];
14
+ (0, exercise_1.addValidProp)(propositions, answer, "raw");
15
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
16
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
17
+ (0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
18
+ return (0, exercise_1.shuffleProps)(propositions, n);
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ return identifiers.isOnLine ? "Oui" : "Non";
22
+ };
23
+ const getInstruction = (identifiers) => {
24
+ const point = spacePoint_1.SpacePointConstructor.fromScalars(identifiers.askedPointCoords, identifiers.askedPointName);
25
+ const line = new parametricLine_1.ParametricLine(point, spaceVector_1.SpaceVectorConstructor.fromScalars(identifiers.vector));
26
+ return `Soit $d$ la droite d'équation paramétrique :
27
+
28
+ $$
29
+ ${line.toTex()}
30
+ $$
31
+
32
+ où $t\\in \\mathbb{R}$.
33
+
34
+ Le point $${point.toTexWithCoords()}$ appartient-il à $d$ ?
35
+ `;
36
+ };
37
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
38
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
39
+ const getKeys = (identifiers) => {
40
+ return [];
41
+ };
42
+ const isAnswerValid = (ans, { answer }) => {
43
+ throw Error("VEA not implemented");
44
+ };
45
+ const getPointFromParametricLineQuestion = () => {
46
+ const startPoint = spacePoint_1.SpacePointConstructor.random("A");
47
+ const vector = spaceVector_1.SpaceVectorConstructor.random("B");
48
+ const isOnLine = (0, coinFlip_1.coinFlip)();
49
+ const askedPointName = (0, randomLetter_1.randomLetter)(true, ["O"]);
50
+ let askedPoint;
51
+ let coeff;
52
+ if (isOnLine) {
53
+ coeff = (0, randint_1.randint)(-10, 10);
54
+ const res = vector.times(coeff.toTree());
55
+ askedPoint = res.getEndPoint(startPoint);
56
+ }
57
+ else {
58
+ askedPoint = spacePoint_1.SpacePointConstructor.random(askedPointName);
59
+ }
60
+ // const askedPoint = SpacePointConstructor.random(askedPointName);
61
+ const identifiers = {
62
+ startPoint: startPoint.getEvaluatedCoords(),
63
+ vector: vector.getEvaluatedCoords(),
64
+ askedPointCoords: askedPoint.getEvaluatedCoords(),
65
+ askedPointName,
66
+ isOnLine,
67
+ };
68
+ const question = {
69
+ answer: getAnswer(identifiers),
70
+ instruction: getInstruction(identifiers),
71
+ keys: getKeys(identifiers),
72
+ answerFormat: "tex",
73
+ identifiers,
74
+ // hint: getHint(identifiers),
75
+ // correction: getCorrection(identifiers),
76
+ };
77
+ return question;
78
+ };
79
+ exports.pointFromParametricLine = {
80
+ id: "pointFromParametricLine",
81
+ connector: "=",
82
+ label: "Vérifier si un point appartient à une droite d'équation paramétrique donnée",
83
+ isSingleStep: true,
84
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getPointFromParametricLineQuestion, nb),
85
+ qcmTimer: 60,
86
+ freeTimer: 60,
87
+ getPropositions,
88
+ isAnswerValid,
89
+ subject: "Mathématiques",
90
+ // getHint,
91
+ // getCorrection,
92
+ getAnswer,
93
+ getKeys,
94
+ answerType: "QCU",
95
+ };
@@ -34,7 +34,7 @@ $$
34
34
  On transforme ce coefficient multiplicateur en taux d'évolution :
35
35
 
36
36
  $$
37
- (${recipCm.frenchify()}-1)\\times 100 = ${(0, round_1.round)(ans, 2).frenchify()}
37
+ (${recipCm.frenchify()}-1)\\times 100 = ${(0, round_1.round)(ans, 2).frenchify()}\\%
38
38
  $$
39
39
 
40
40
  Ainsi, le taux d'évolution permettant de revenir au prix initial est de $${answer}$.
@@ -1 +1 @@
1
- {"version":3,"file":"arithmeticFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAsEF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAe/D,CAAC"}
1
+ {"version":3,"file":"arithmeticFindExplicitFormula.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormula.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAiIF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAoB/D,CAAC"}
@@ -8,34 +8,61 @@ const randint_1 = require("../../../../math/utils/random/randint");
8
8
  const equalNode_1 = require("../../../../tree/nodes/equations/equalNode");
9
9
  const variableNode_1 = require("../../../../tree/nodes/variables/variableNode");
10
10
  const shuffle_1 = require("../../../../utils/alea/shuffle");
11
- const getArithmeticFindExplicitFormula = () => {
12
- const firstRank = 0;
13
- const firstValue = (0, randint_1.randint)(-10, 10);
14
- const reason = (0, randint_1.randint)(-10, 10, [0]);
15
- const formula = new polynomial_1.Polynomial([firstValue, reason], "n");
16
- const answer = "u_n=" + formula.toTex();
17
- const question = {
18
- instruction: `$(u_n)$ est une suite arithmétique de premier terme $u_{${firstRank}} = ${firstValue}$ et de raison $r = ${reason}$. $\\\\$ Donner l'expression de $u_n$ en fonction de $n$.`,
19
- answer,
20
- keys: ["un", "equal", "n"],
21
- answerFormat: "tex",
22
- identifiers: { firstValue, reason },
23
- hint: `Utilise la formule générale d'une suite arithmétique :
11
+ const getInstruction = (identifiers, opts) => {
12
+ const firstRank = opts?.firstTermRankOne ? 1 : 0;
13
+ return `$(u_n)$ est une suite arithmétique de premier terme $u_{${firstRank}} = ${identifiers.firstValue}$ et de raison $r = ${identifiers.reason}$.
14
+
15
+ Donner l'expression de $u_n$ en fonction de $n$.`;
16
+ };
17
+ const getHint = (identifiers, opts) => {
18
+ const firstRank = opts?.firstTermRankOne ? 1 : 0;
19
+ return `Utilise la formule générale d'une suite arithmétique :
24
20
 
25
- $u_n = u_0 + n \\times r $,
21
+ $$
22
+ ${firstRank === 0 ? "u_n = u_0 + n \\times r" : "u_n = u_1 + (n-1) \\times r"}
23
+ $$
26
24
 
27
- où $u_0$ est le premier terme et $r$ la raison.`,
28
- correction: `La formule générale d'une suite arithmétique est :
25
+ où $u_${firstRank}$ est le premier terme et $r$ la raison.`;
26
+ };
27
+ const getCorrection = (identifiers, opts) => {
28
+ const firstRank = opts?.firstTermRankOne ? 1 : 0;
29
+ const answer = getAnswer(identifiers, opts);
30
+ return `La formule générale d'une suite arithmétique est :
29
31
 
30
- $u_n = u_0 + n \\times r $,
32
+ $$
33
+ ${firstRank === 0 ? "u_n = u_0 + n \\times r " : "u_n = u_1 + (n-1) \\times r "}
34
+ $$
31
35
 
32
- où $u_0$ est le premier terme et $r$ la raison.
36
+ où $u_${firstRank}$ est le premier terme et $r$ la raison.
33
37
 
34
- Ici, puisque $u_0 = ${firstValue}$ et $r = ${reason}$, on a :
38
+ Ici, puisque $u_${firstRank} = ${identifiers.firstValue}$ et $r = ${identifiers.reason}$, on a :
35
39
 
36
- $${answer}$
40
+ $$
41
+ ${answer}
42
+ $$
37
43
 
38
- `,
44
+ `;
45
+ };
46
+ const getAnswer = (identifiers, opts) => {
47
+ const { firstValue, reason } = identifiers;
48
+ const formula = opts?.firstTermRankOne
49
+ ? new polynomial_1.Polynomial([firstValue - reason, reason], "n")
50
+ : new polynomial_1.Polynomial([firstValue, reason], "n");
51
+ const answer = "u_n=" + formula.toTex();
52
+ return answer;
53
+ };
54
+ const getArithmeticFindExplicitFormula = (opts) => {
55
+ const firstValue = (0, randint_1.randint)(-10, 10);
56
+ const reason = (0, randint_1.randint)(-10, 10, [0]);
57
+ const identifiers = { firstValue, reason };
58
+ const question = {
59
+ instruction: getInstruction(identifiers, opts),
60
+ answer: getAnswer(identifiers, opts),
61
+ keys: ["un", "equal", "n"],
62
+ answerFormat: "tex",
63
+ identifiers,
64
+ hint: getHint(identifiers, opts),
65
+ correction: getCorrection(identifiers, opts),
39
66
  };
40
67
  return question;
41
68
  };
@@ -50,14 +77,24 @@ const getPropositions = (n, { answer, firstValue, reason }) => {
50
77
  }
51
78
  return (0, shuffle_1.shuffle)(propositions);
52
79
  };
53
- const isAnswerValid = (ans, { reason, firstValue }) => {
54
- const formula = new polynomial_1.Polynomial([firstValue, reason], "n");
80
+ const isAnswerValid = (ans, { reason, firstValue }, opts) => {
81
+ const formula = opts?.firstTermRankOne
82
+ ? new polynomial_1.Polynomial([firstValue - reason, reason], "n")
83
+ : new polynomial_1.Polynomial([firstValue, reason], "n");
55
84
  const equal = new equalNode_1.EqualNode(new variableNode_1.VariableNode("u_n"), formula.toTree(), {
56
85
  allowRawRightChildAsSolution: true,
57
86
  });
58
87
  const texs = equal.toAllValidTexs();
59
88
  return texs.includes(ans);
60
89
  };
90
+ const options = [
91
+ {
92
+ id: "firstTermRankOne",
93
+ label: "Utiliser $u_1$ comme premier terme",
94
+ target: exercise_1.GeneratorOptionTarget.generation,
95
+ type: exercise_1.GeneratorOptionType.checkbox,
96
+ },
97
+ ];
61
98
  exports.arithmeticFindExplicitFormula = {
62
99
  id: "arithmeticFindExplicitFormula",
63
100
  connector: "=",
@@ -65,11 +102,16 @@ exports.arithmeticFindExplicitFormula = {
65
102
  levels: ["1reESM", "1reSpé", "1reTech", "1rePro", "TermTech", "TermPro"],
66
103
  sections: ["Suites"],
67
104
  isSingleStep: false,
68
- generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getArithmeticFindExplicitFormula, nb),
105
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getArithmeticFindExplicitFormula(opts), nb),
69
106
  qcmTimer: 60,
70
107
  freeTimer: 60,
71
108
  getPropositions,
72
109
  isAnswerValid,
73
110
  subject: "Mathématiques",
74
111
  hasHintAndCorrection: true,
112
+ options,
113
+ getAnswer,
114
+ getCorrection,
115
+ getHint,
116
+ getInstruction,
75
117
  };
package/lib/index.d.ts CHANGED
@@ -47,7 +47,7 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
47
47
  rational: [number, number];
48
48
  rational2: [number, number];
49
49
  }, {
50
- allowNonIrreductible: boolean;
50
+ allowNonIrreductible?: boolean | undefined;
51
51
  }> | import("./exercises/exercise").Exercise<{
52
52
  num: number;
53
53
  denum: number;
@@ -1061,6 +1061,19 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
1061
1061
  }, {}> | import("./exercises/exercise").Exercise<{
1062
1062
  type: number;
1063
1063
  commands: string[];
1064
+ }, {}> | import("./exercises/exercise").Exercise<{
1065
+ startPoint: number[];
1066
+ vector: number[];
1067
+ askedPointCoords: number[];
1068
+ askedPointName: string;
1069
+ isOnLine: boolean;
1070
+ coeff?: number | undefined;
1071
+ }, {}> | import("./exercises/exercise").Exercise<{
1072
+ startPoint: number[];
1073
+ vector: number[];
1074
+ }, {}> | import("./exercises/exercise").Exercise<{
1075
+ startPoint: number[];
1076
+ vector: number[];
1064
1077
  }, {}> | import("./exercises/exercise").Exercise<{
1065
1078
  coeffs: number[];
1066
1079
  to: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
2
+ import { SpacePoint } from "./spacePoint";
3
+ import { SpaceVector } from "./spaceVector";
4
+ export declare class ParametricLine {
5
+ startPoint: SpacePoint;
6
+ vector: SpaceVector;
7
+ equations: AlgebraicNode[];
8
+ constructor(startPoint: SpacePoint, vector: SpaceVector);
9
+ toDetailedEvaluation(t: AlgebraicNode): AlgebraicNode[];
10
+ getPointCoords(t: AlgebraicNode): AlgebraicNode[];
11
+ getPoint(t: AlgebraicNode): SpacePoint;
12
+ hasPoint(p: SpacePoint): boolean;
13
+ toTex(): string;
14
+ }
15
+ //# sourceMappingURL=parametricLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parametricLine.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/parametricLine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAA0B,MAAM,eAAe,CAAC;AAEpE,qBAAa,cAAc;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,aAAa,EAAE,CAAC;gBACf,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW;IAavD,oBAAoB,CAAC,CAAC,EAAE,aAAa;IAIrC,cAAc,CAAC,CAAC,EAAE,aAAa;IAG/B,QAAQ,CAAC,CAAC,EAAE,aAAa;IAKzB,QAAQ,CAAC,CAAC,EAAE,UAAU;IAYtB,KAAK;CAUN"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParametricLine = void 0;
4
+ const addNode_1 = require("../../tree/nodes/operators/addNode");
5
+ const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
6
+ const variableNode_1 = require("../../tree/nodes/variables/variableNode");
7
+ const spacePoint_1 = require("./spacePoint");
8
+ const spaceVector_1 = require("./spaceVector");
9
+ class ParametricLine {
10
+ constructor(startPoint, vector) {
11
+ this.startPoint = startPoint;
12
+ this.vector = vector;
13
+ const pointCoords = this.startPoint.getCoords();
14
+ const vectorCoords = this.vector.getCoords();
15
+ this.equations = [0, 1, 2].map((i) => new addNode_1.AddNode(pointCoords[i], new multiplyNode_1.MultiplyNode(vectorCoords[i], new variableNode_1.VariableNode("t"))).simplify({ forbidFactorize: true }));
16
+ }
17
+ toDetailedEvaluation(t) {
18
+ return this.equations.map((e) => e.toDetailedEvaluation({ t: t }));
19
+ }
20
+ getPointCoords(t) {
21
+ return this.toDetailedEvaluation(t).map((e) => e.simplify());
22
+ }
23
+ getPoint(t) {
24
+ const pointCoords = this.toDetailedEvaluation(t).map((e) => e.simplify());
25
+ return new spacePoint_1.SpacePoint("A", pointCoords[0], pointCoords[1], pointCoords[2]);
26
+ }
27
+ hasPoint(p) {
28
+ if (p.equals(this.startPoint))
29
+ return true;
30
+ const secondPoint = this.vector.getEndPoint(this.startPoint);
31
+ const vector1 = spaceVector_1.SpaceVectorConstructor.fromPoints(this.startPoint, p);
32
+ const vector2 = spaceVector_1.SpaceVectorConstructor.fromPoints(this.startPoint, secondPoint);
33
+ console.log(vector1.toInlineCoordsTex(), vector2.toInlineCoordsTex());
34
+ return vector1.isColinear(vector2);
35
+ }
36
+ toTex() {
37
+ return `
38
+ \\left\\{\\begin{matrix}
39
+ x=${this.equations[0].toTex()} \\\\
40
+ y=${this.equations[1].toTex()} \\\\
41
+ z=${this.equations[2].toTex()}
42
+ \\end{matrix}
43
+ \\right.
44
+ `;
45
+ }
46
+ }
47
+ exports.ParametricLine = ParametricLine;
@@ -7,6 +7,7 @@ type AleaBound = {
7
7
  export declare abstract class SpacePointConstructor {
8
8
  static random(name: string, xOpts?: AleaBound, yOpts?: AleaBound, zOpts?: AleaBound): SpacePoint;
9
9
  static randomDifferent(names: string[]): SpacePoint[];
10
+ static fromScalars(arr: number[], name?: string): SpacePoint;
10
11
  }
11
12
  export declare class SpacePoint {
12
13
  name: string;
@@ -14,6 +15,8 @@ export declare class SpacePoint {
14
15
  y: AlgebraicNode;
15
16
  z: AlgebraicNode;
16
17
  constructor(name: string, x: AlgebraicNode, y: AlgebraicNode, z: AlgebraicNode);
18
+ getCoords(): AlgebraicNode[];
19
+ getEvaluatedCoords(): number[];
17
20
  toTex(): string;
18
21
  toTexWithCoords(): string;
19
22
  toCoords(): string;
@@ -1 +1 @@
1
- {"version":3,"file":"spacePoint.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/spacePoint.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,KAAK,SAAS,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AACrE,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,SAAS,EACjB,KAAK,CAAC,EAAE,SAAS,EACjB,KAAK,CAAC,EAAE,SAAS,GAChB,UAAU;IAyBb,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;CA4BvC;AAED,qBAAa,UAAU;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBAEf,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,aAAa;IAQlB,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAKzB,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,SAAM,GAAG,UAAU;IAkB/C,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM;IAIjC,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU;IAOtC,YAAY;CAKb"}
1
+ {"version":3,"file":"spacePoint.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/spacePoint.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,KAAK,SAAS,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AACrE,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,MAAM,CACX,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,SAAS,EACjB,KAAK,CAAC,EAAE,SAAS,EACjB,KAAK,CAAC,EAAE,SAAS,GAChB,UAAU;IAyBb,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;IA4BtC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,MAAY;CAWrD;AAED,qBAAa,UAAU;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBAEf,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,aAAa,EAChB,CAAC,EAAE,aAAa;IAQlB,SAAS;IAGT,kBAAkB;IAIlB,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAKzB,QAAQ,IAAI,MAAM;IAIlB,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,SAAM,GAAG,UAAU;IAkB/C,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM;IAIjC,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU;IAOtC,YAAY;CAKb"}
@@ -27,6 +27,12 @@ class SpacePointConstructor {
27
27
  }
28
28
  return res;
29
29
  }
30
+ static fromScalars(arr, name = "A") {
31
+ if (arr.length !== 3) {
32
+ throw new Error("array must have 3 elements");
33
+ }
34
+ return new SpacePoint(name, new numberNode_1.NumberNode(arr[0]), new numberNode_1.NumberNode(arr[1]), new numberNode_1.NumberNode(arr[2]));
35
+ }
30
36
  }
31
37
  exports.SpacePointConstructor = SpacePointConstructor;
32
38
  class SpacePoint {
@@ -36,6 +42,12 @@ class SpacePoint {
36
42
  this.y = y;
37
43
  this.z = z;
38
44
  }
45
+ getCoords() {
46
+ return [this.x, this.y, this.z];
47
+ }
48
+ getEvaluatedCoords() {
49
+ return this.getCoords().map((e) => e.evaluate({}));
50
+ }
39
51
  toTex() {
40
52
  return `${this.name}`;
41
53
  }
@@ -5,6 +5,7 @@ export declare abstract class SpaceVectorConstructor {
5
5
  static fromPoints(origin: SpacePoint, end: SpacePoint): SpaceVector;
6
6
  static random(name: string, allowNull?: boolean): SpaceVector;
7
7
  static randomDifferents(names: string[], allowNull?: boolean): SpaceVector[];
8
+ static fromScalars(arr: number[]): SpaceVector;
8
9
  }
9
10
  export declare class SpaceVector {
10
11
  name: string;
@@ -13,11 +14,15 @@ export declare class SpaceVector {
13
14
  y: AlgebraicNode;
14
15
  z: AlgebraicNode;
15
16
  constructor(name: string, x: AlgebraicNode, y: AlgebraicNode, z: AlgebraicNode);
17
+ getCoords(): AlgebraicNode[];
18
+ getEvaluatedCoords(): number[];
16
19
  toTex(): string;
17
20
  toCoordsTex(): string;
18
21
  toInlineCoordsTex(): string;
19
22
  toTexWithCoords(): string;
23
+ vetorialProduct(v: SpaceVector): SpaceVector;
20
24
  isColinear(v: SpaceVector): boolean;
25
+ isCoplanar(v: SpaceVector): boolean;
21
26
  determinant(v: SpaceVector): AlgebraicNode;
22
27
  times(k: AlgebraicNode, name?: string): SpaceVector;
23
28
  scalarProduct(v: SpaceVector): Node;
@@ -1 +1 @@
1
- {"version":3,"file":"spaceVector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/spaceVector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO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E,WAAW,GAAG,WAAW;IAShC,OAAO,IAAI,aAAa;IAYxB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM;IAQjD,MAAM,CAAC,CAAC,EAAE,WAAW;CAGtB"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SpaceVector = exports.SpaceVectorConstructor = void 0;
4
4
  const sqrtNode_1 = require("../../tree/nodes/functions/sqrtNode");
5
+ const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
5
6
  const addNode_1 = require("../../tree/nodes/operators/addNode");
6
7
  const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
7
8
  const powerNode_1 = require("../../tree/nodes/operators/powerNode");
@@ -34,6 +35,12 @@ class SpaceVectorConstructor {
34
35
  }
35
36
  return res;
36
37
  }
38
+ static fromScalars(arr) {
39
+ if (arr.length !== 3) {
40
+ throw new Error("array must have 3 elements");
41
+ }
42
+ return new SpaceVector("P", new numberNode_1.NumberNode(arr[0]), new numberNode_1.NumberNode(arr[1]), new numberNode_1.NumberNode(arr[2]));
43
+ }
37
44
  }
38
45
  exports.SpaceVectorConstructor = SpaceVectorConstructor;
39
46
  class SpaceVector {
@@ -44,6 +51,12 @@ class SpaceVector {
44
51
  this.y = y;
45
52
  this.z = z;
46
53
  }
54
+ getCoords() {
55
+ return [this.x, this.y, this.z];
56
+ }
57
+ getEvaluatedCoords() {
58
+ return this.getCoords().map((e) => e.evaluate({}));
59
+ }
47
60
  toTex() {
48
61
  return `\\overrightarrow{${this.name}}`;
49
62
  }
@@ -58,7 +71,14 @@ class SpaceVector {
58
71
  toTexWithCoords() {
59
72
  return `\\overrightarrow{${this.name}}\\begin{pmatrix}${this.x.toTex()} \\\\ ${this.y.toTex()} \\\\ ${this.z.toTex()} \\end{pmatrix}`;
60
73
  }
74
+ vetorialProduct(v) {
75
+ return new SpaceVector(`w`, new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(this.y, v.z), new multiplyNode_1.MultiplyNode(this.z, v.y)).simplify(), new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(this.z, v.x), new multiplyNode_1.MultiplyNode(this.x, v.z)).simplify(), new substractNode_1.SubstractNode(new multiplyNode_1.MultiplyNode(this.x, v.y), new multiplyNode_1.MultiplyNode(this.y, v.x)).simplify());
76
+ }
61
77
  isColinear(v) {
78
+ const vectorialProduct = this.vetorialProduct(v);
79
+ return vectorialProduct.equals(new SpaceVector("0", (0).toTree(), (0).toTree(), (0).toTree()));
80
+ }
81
+ isCoplanar(v) {
62
82
  throw Error("unimplemented");
63
83
  }
64
84
  determinant(v) {