math-exercises 3.0.77 → 3.0.78

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 (48) hide show
  1. package/lib/exercises/math/calcul/arithmetics/calculateDistanceWithAbsoluteValue.d.ts +10 -0
  2. package/lib/exercises/math/calcul/arithmetics/calculateDistanceWithAbsoluteValue.d.ts.map +1 -0
  3. package/lib/exercises/math/calcul/arithmetics/calculateDistanceWithAbsoluteValue.js +112 -0
  4. package/lib/exercises/math/calcul/arithmetics/calculateWithAbsoluteValue.d.ts +8 -0
  5. package/lib/exercises/math/calcul/arithmetics/calculateWithAbsoluteValue.d.ts.map +1 -0
  6. package/lib/exercises/math/calcul/arithmetics/calculateWithAbsoluteValue.js +123 -0
  7. package/lib/exercises/math/calcul/arithmetics/index.d.ts +3 -0
  8. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/arithmetics/index.js +3 -0
  10. package/lib/exercises/math/calcul/arithmetics/sqrtInequality.d.ts +10 -0
  11. package/lib/exercises/math/calcul/arithmetics/sqrtInequality.d.ts.map +1 -0
  12. package/lib/exercises/math/calcul/arithmetics/sqrtInequality.js +160 -0
  13. package/lib/exercises/math/calcul/sign/absoluteNumber.js +1 -1
  14. package/lib/exercises/math/functions/absolute/absoluteValueInequations.d.ts.map +1 -1
  15. package/lib/exercises/math/functions/absolute/absoluteValueInequations.js +5 -1
  16. package/lib/exercises/math/functions/basics/graphicEquation.d.ts.map +1 -1
  17. package/lib/exercises/math/functions/basics/graphicEquation.js +33 -1
  18. package/lib/exercises/math/functions/basics/twoFunctionsEquation.d.ts.map +1 -1
  19. package/lib/exercises/math/functions/basics/twoFunctionsEquation.js +27 -0
  20. package/lib/exercises/math/functions/variations/varTableExtremaReading.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/variations/varTableExtremaReading.js +23 -8
  22. package/lib/exercises/math/geometry/angles/index.d.ts +1 -0
  23. package/lib/exercises/math/geometry/angles/index.d.ts.map +1 -1
  24. package/lib/exercises/math/geometry/angles/index.js +1 -0
  25. package/lib/exercises/math/geometry/angles/parallelogramFourthAngle.d.ts +8 -0
  26. package/lib/exercises/math/geometry/angles/parallelogramFourthAngle.d.ts.map +1 -0
  27. package/lib/exercises/math/geometry/angles/parallelogramFourthAngle.js +92 -0
  28. package/lib/exercises/math/probaStat/checkEquiprobability.d.ts +9 -0
  29. package/lib/exercises/math/probaStat/checkEquiprobability.d.ts.map +1 -0
  30. package/lib/exercises/math/probaStat/checkEquiprobability.js +129 -0
  31. package/lib/exercises/math/probaStat/index.d.ts +2 -0
  32. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  33. package/lib/exercises/math/probaStat/index.js +2 -0
  34. package/lib/exercises/math/probaStat/mostLeastProbable.d.ts +8 -0
  35. package/lib/exercises/math/probaStat/mostLeastProbable.d.ts.map +1 -0
  36. package/lib/exercises/math/probaStat/mostLeastProbable.js +114 -0
  37. package/lib/exercises/math/sets/index.d.ts +1 -0
  38. package/lib/exercises/math/sets/index.d.ts.map +1 -1
  39. package/lib/exercises/math/sets/index.js +1 -0
  40. package/lib/exercises/math/sets/subsetsOfKnownSets.d.ts +8 -0
  41. package/lib/exercises/math/sets/subsetsOfKnownSets.d.ts.map +1 -0
  42. package/lib/exercises/math/sets/subsetsOfKnownSets.js +99 -0
  43. package/lib/index.d.ts +21 -0
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/latexTester.js +2 -0
  46. package/lib/tests/pdfExo.test.d.ts.map +1 -1
  47. package/lib/tests/pdfExo.test.js +2 -2
  48. package/package.json +1 -1
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ a: NodeIdentifiers;
5
+ b: number;
6
+ c: number;
7
+ };
8
+ export declare const calculateDistanceWithAbsoluteValue: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=calculateDistanceWithAbsoluteValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateDistanceWithAbsoluteValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/calculateDistanceWithAbsoluteValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IAEjB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsHF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAqBpE,CAAC"}
@@ -0,0 +1,112 @@
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 { abs } from "../../../../tree/nodes/functions/absNode.js";
7
+ import { NodeIds } from "../../../../tree/nodes/node.js";
8
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
9
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
10
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
11
+ import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
12
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
13
+ const getPropositions = (n, { answer, a, b, c }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ tryToAddWrongProp(propositions, substract(abs(b), abs(reifyAlgebraic(a))).toTex() + "=" + c.frenchify());
17
+ tryToAddWrongProp(propositions, substract(abs(reifyAlgebraic(a)), abs(b)).toTex() + "=" + c.frenchify());
18
+ tryToAddWrongProp(propositions, add(abs(b), reifyAlgebraic(a)).toTex() + "=" + c.frenchify());
19
+ return shuffleProps(propositions, n);
20
+ };
21
+ const getAnswer = (identifiers) => {
22
+ const { a, b, c } = identifiers;
23
+ return `${abs(substract(b, reifyAlgebraic(a))).toTex()}=${c.frenchify()}`;
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const { a, b, c } = identifiers;
27
+ const proposition = a.id === NodeIds.variable
28
+ ? `la distance entre $${reifyAlgebraic(a).toTex()}$ et $${b.frenchify()}$ est égale à $${c.frenchify()}$`
29
+ : `$${reifyAlgebraic(a).toTex()}$ et $${b.frenchify()}$ sont situés à une distance de $${c.frenchify()}$ l'un de l'autre`;
30
+ return `Traduire par une égalité avec une valeur absolue la phrase suivante :
31
+
32
+ "${proposition}".`;
33
+ };
34
+ const getHint = (identifiers) => {
35
+ return `La distance entre deux nombres $a$ et $b$ est égale à :
36
+
37
+ $$
38
+ ${abs(substract("b", "a")).toTex()}
39
+ $$`;
40
+ };
41
+ const getCorrection = (identifiers) => {
42
+ const { a, b } = identifiers;
43
+ return `La distance entre $${reifyAlgebraic(a).toTex()}$ et $${b.frenchify()}$ est égale à $${abs(substract(b, reifyAlgebraic(a))).toTex()}$.
44
+
45
+ Ici, on a donc :
46
+
47
+ $$
48
+ ${getAnswer(identifiers)}
49
+ $$`;
50
+ };
51
+ const getKeys = (identifiers) => {
52
+ return ["abs", "x", "equal"];
53
+ };
54
+ const isAnswerValid = (ans, { answer, a, b, c }) => {
55
+ const aNode = reifyAlgebraic(a);
56
+ return [
57
+ `${abs(substract(b, aNode)).toTex()}=${c.frenchify()}`,
58
+ `${abs(substract(aNode, b)).toTex()}=${c.frenchify()}`,
59
+ ].includes(ans);
60
+ };
61
+ const getCalculateDistanceWithAbsoluteValueQuestion = (ops) => {
62
+ const containsVariable = coinFlip();
63
+ let a;
64
+ let b;
65
+ let c;
66
+ if (containsVariable) {
67
+ a = new VariableNode("x");
68
+ b = coinFlip() ? randint(-10, 10) : randfloat(-10, 10, 2);
69
+ c = coinFlip() ? randint(1, 10, [b]) : randfloat(0, 10, 2, [b, 0]);
70
+ }
71
+ else {
72
+ const aNb = coinFlip() ? randint(-10, 10) : randfloat(-10, 10, 2);
73
+ a = aNb.toTree();
74
+ b = randint(-10, 10, [aNb]);
75
+ c = round(Math.abs(b - aNb), 4);
76
+ }
77
+ const identifiers = {
78
+ a: a.toIdentifiers(),
79
+ b,
80
+ c,
81
+ };
82
+ return getQuestionFromIdentifiers(identifiers);
83
+ };
84
+ const getQuestionFromIdentifiers = (identifiers) => {
85
+ return {
86
+ answer: getAnswer(identifiers),
87
+ instruction: getInstruction(identifiers),
88
+ keys: getKeys(identifiers),
89
+ answerFormat: "tex",
90
+ identifiers,
91
+ hint: getHint(identifiers),
92
+ correction: getCorrection(identifiers),
93
+ };
94
+ };
95
+ export const calculateDistanceWithAbsoluteValue = {
96
+ id: "calculateDistanceWithAbsoluteValue",
97
+ connector: "=",
98
+ label: "Traduire une distance par une valeur absolue",
99
+ isSingleStep: true,
100
+ generator: (nb, opts) => getDistinctQuestions(() => getCalculateDistanceWithAbsoluteValueQuestion(opts), nb),
101
+ qcmTimer: 60,
102
+ freeTimer: 60,
103
+ getPropositions,
104
+ isAnswerValid,
105
+ subject: "Mathématiques",
106
+ getInstruction,
107
+ getHint,
108
+ getCorrection,
109
+ getAnswer,
110
+ getQuestionFromIdentifiers,
111
+ hasHintAndCorrection: true,
112
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ expression: NodeIdentifiers;
5
+ };
6
+ export declare const calculateWithAbsoluteValue: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=calculateWithAbsoluteValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateWithAbsoluteValue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/calculateWithAbsoluteValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAQ7C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC;AAmHF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAiB5D,CAAC"}
@@ -0,0 +1,123 @@
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 { abs, isAbsNode } from "../../../../tree/nodes/functions/absNode.js";
7
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
8
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
9
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
+ import { random } from "../../../../utils/alea/random.js";
11
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
13
+ const getPropositions = (n, { answer }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ while (propositions.length < n) {
17
+ const delta = coinFlip() ? randint(1, 5) : randfloat(1, 5, 2);
18
+ const direction = coinFlip() ? 1 : -1;
19
+ const wrongValue = Number((answer.unfrenchify() + direction * delta).toFixed(2));
20
+ tryToAddWrongProp(propositions, wrongValue.frenchify());
21
+ }
22
+ return shuffleProps(propositions, n);
23
+ };
24
+ const getAnswer = (identifiers) => {
25
+ const { expression } = identifiers;
26
+ const expressionValue = reifyAlgebraic(expression).simplify().evaluate();
27
+ return expressionValue.frenchify();
28
+ };
29
+ const getInstruction = (identifiers) => {
30
+ const { expression } = identifiers;
31
+ const expressionTex = reifyAlgebraic(expression).toTex();
32
+ return `Calculer et donner le résultat sans utiliser la notation de la valeur absolue :
33
+
34
+ $$
35
+ ${expressionTex}
36
+ $$ `;
37
+ };
38
+ const getHint = (identifiers) => {
39
+ const expressionTex = reifyAlgebraic(identifiers.expression).toTex();
40
+ return `Utilise la définition de la valeur absolue :
41
+
42
+ - $|x| = x$ si $x \\geq 0$;
43
+ - $|x| = -x$ si $x < 0$.`;
44
+ };
45
+ const getCorrection = (identifiers) => {
46
+ const { expression } = identifiers;
47
+ const exprNode = reifyAlgebraic(expression);
48
+ const absChild = isAbsNode(exprNode) ? exprNode.child : null;
49
+ const absChildValue = absChild ? absChild.simplify().evaluate() : "";
50
+ const answer = getAnswer(identifiers);
51
+ return `On rappelle que :
52
+
53
+ - $|x| = x$ si $x \\geq 0$;
54
+ - $|x| = -x$ si $x < 0$.
55
+
56
+ Ici, on a donc :
57
+
58
+ ${alignTex([
59
+ [
60
+ exprNode.toTex(),
61
+ "=",
62
+ isAbsNode(exprNode)
63
+ ? abs(exprNode.child.simplify()).toTex()
64
+ : exprNode.simplify({ forbidAdditions: true }).toTex(),
65
+ ],
66
+ ["", "=", answer],
67
+ ])}
68
+
69
+ `;
70
+ };
71
+ const getKeys = (identifiers) => {
72
+ return [];
73
+ };
74
+ const isAnswerValid = (ans, { answer }) => {
75
+ try {
76
+ return numberVEA(ans, answer);
77
+ }
78
+ catch (err) {
79
+ return handleVEAError(err);
80
+ }
81
+ };
82
+ const getCalculateWithAbsoluteValueQuestion = (ops) => {
83
+ const a = coinFlip() ? randint(-10, 10, [0]) : randfloat(-10, 10, 2, [0]);
84
+ const b = coinFlip() ? randint(-10, 10, [a]) : randfloat(-10, 10, 2, [a]);
85
+ const expressionGenerators = [
86
+ () => abs(add(a, b)).toIdentifiers(), // |a + b|
87
+ () => abs(add(a, -b)).toIdentifiers(), // |a - b|
88
+ () => add(abs(a), b).toIdentifiers(), // |a| + b
89
+ () => add(a, abs(b)).toIdentifiers(), // a + |b|
90
+ () => add(abs(a), abs(b)).toIdentifiers(), // |a| + |b|
91
+ ];
92
+ const expression = random(expressionGenerators)();
93
+ const identifiers = { expression };
94
+ return getQuestionFromIdentifiers(identifiers);
95
+ };
96
+ const getQuestionFromIdentifiers = (identifiers) => {
97
+ return {
98
+ answer: getAnswer(identifiers),
99
+ instruction: getInstruction(identifiers),
100
+ keys: getKeys(identifiers),
101
+ answerFormat: "tex",
102
+ identifiers,
103
+ hint: getHint(identifiers),
104
+ correction: getCorrection(identifiers),
105
+ };
106
+ };
107
+ export const calculateWithAbsoluteValue = {
108
+ id: "calculateWithAbsoluteValue",
109
+ label: "Calculer avec des valeurs absolues",
110
+ isSingleStep: true,
111
+ generator: (nb, opts) => getDistinctQuestions(() => getCalculateWithAbsoluteValueQuestion(opts), nb),
112
+ qcmTimer: 60,
113
+ freeTimer: 60,
114
+ getPropositions,
115
+ isAnswerValid,
116
+ subject: "Mathématiques",
117
+ getInstruction,
118
+ getHint,
119
+ getCorrection,
120
+ getAnswer,
121
+ getQuestionFromIdentifiers,
122
+ hasHintAndCorrection: true,
123
+ };
@@ -20,4 +20,7 @@ export * from "./isMultipleOrDivisor.js";
20
20
  export * from "./compareInverseValues.js";
21
21
  export * from "./calculateDistanceBetweenNumbers.js";
22
22
  export * from "./compareSquaredValues.js";
23
+ export * from "./calculateWithAbsoluteValue.js";
24
+ export * from "./sqrtInequality.js";
25
+ export * from "./calculateDistanceWithAbsoluteValue.js";
23
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,yCAAyC,CAAC"}
@@ -20,3 +20,6 @@ export * from "./isMultipleOrDivisor.js";
20
20
  export * from "./compareInverseValues.js";
21
21
  export * from "./calculateDistanceBetweenNumbers.js";
22
22
  export * from "./compareSquaredValues.js";
23
+ export * from "./calculateWithAbsoluteValue.js";
24
+ export * from "./sqrtInequality.js";
25
+ export * from "./calculateDistanceWithAbsoluteValue.js";
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ twoSided: boolean;
5
+ a: NodeIdentifiers;
6
+ b?: NodeIdentifiers;
7
+ };
8
+ export declare const sqrtInequality: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=sqrtInequality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqrtInequality.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/sqrtInequality.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,CAAC,EAAE,eAAe,CAAC;CACrB,CAAC;AAsJF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAkBhD,CAAC"}
@@ -0,0 +1,160 @@
1
+ import { addValidProp, tryToAddWrongProp, shuffleProps, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
5
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
6
+ import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
7
+ import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
8
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
9
+ import { intervalParser } from "../../../../tree/parsers/intervalParser.js";
10
+ import { random } from "../../../../utils/alea/random.js";
11
+ import { square } from "../../../../tree/nodes/operators/powerNode.js";
12
+ import { sqrt } from "../../../../tree/nodes/functions/sqrtNode.js";
13
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
14
+ const getPropositions = (n, { answer }) => {
15
+ const propositions = [];
16
+ addValidProp(propositions, answer);
17
+ const allClosures = Object.values(ClosureType);
18
+ while (propositions.length < n) {
19
+ const falseInterval = new IntervalNode(randint(0, 10).toTree(), randint(0, 10).toTree(), random(allClosures)).toTex();
20
+ tryToAddWrongProp(propositions, "S=\\ " + falseInterval);
21
+ }
22
+ return shuffleProps(propositions, n);
23
+ };
24
+ const getInstruction = ({ twoSided, a, b }) => {
25
+ const aNode = reifyAlgebraic(a).toTex();
26
+ if (twoSided) {
27
+ const bNode = reifyAlgebraic(b).toTex();
28
+ return `Résoudre l'inéquation suivante, pour $x\\geq 0$ :
29
+
30
+ $$
31
+ ${aNode} < \\sqrt{x} < ${bNode}
32
+ $$`;
33
+ }
34
+ else {
35
+ return `Résoudre l'inéquation suivante, pour $x\\geq 0$ :
36
+
37
+ $$
38
+ \\sqrt{x} < ${aNode}
39
+ $$`;
40
+ }
41
+ };
42
+ const getAnswer = ({ twoSided, a, b }) => {
43
+ const aVal = reifyAlgebraic(a).evaluate();
44
+ let interval;
45
+ if (twoSided) {
46
+ const bVal = reifyAlgebraic(b).evaluate();
47
+ interval = new IntervalNode((aVal * aVal).toTree(), (bVal * bVal).toTree(), ClosureType.OO);
48
+ }
49
+ else {
50
+ interval = new IntervalNode((0).toTree(), (aVal * aVal).toTree(), ClosureType.FO);
51
+ }
52
+ return "S=\\ " + interval.simplify().toTex();
53
+ };
54
+ const getHint = ({ twoSided }) => {
55
+ if (twoSided) {
56
+ return `Puisque tous les termes de cette inéquations sont positifs, on peut les élèver au carré sans changer l'ordre de l'inéquation.`;
57
+ }
58
+ else {
59
+ return `Puisque tous les termes de cette inéquations sont positifs, on peut les élèver au carré sans changer l'ordre de l'inéquation.`;
60
+ }
61
+ };
62
+ const getCorrection = (identifiers) => {
63
+ const { a, twoSided, b } = identifiers;
64
+ const aNode = reifyAlgebraic(a);
65
+ let steps;
66
+ let solTex;
67
+ const answer = getAnswer(identifiers);
68
+ if (twoSided) {
69
+ const bNode = reifyAlgebraic(b);
70
+ steps = [
71
+ [`${aNode.toTex()} < \\sqrt{x} < ${bNode.toTex()}`],
72
+ [
73
+ `${square(aNode).toTex()} < ${square(sqrt("x")).toTex()} < ${square(bNode).toTex()}`,
74
+ ],
75
+ [
76
+ `${square(aNode).simplify().toTex()} < x < ${square(bNode)
77
+ .simplify()
78
+ .toTex()}`,
79
+ ],
80
+ ];
81
+ }
82
+ else {
83
+ steps = [
84
+ [`\\sqrt{x} < ${aNode.toTex()}`],
85
+ [`${square(sqrt("x")).toTex()} < ${square(aNode).toTex()}`],
86
+ [`x < ${square(aNode).simplify().toTex()}`],
87
+ ];
88
+ }
89
+ return `Puisque tous les termes de cette inéquation sont positifs, on peut les élèver au carré sans changer l'ordre de l'inéquation (en effet, si deux nombres positifs $a$ et $b$ vérifient $a<b$, alors $a^2<b^2$).
90
+
91
+ On a donc :
92
+
93
+ ${alignTex(steps)}
94
+
95
+ La solution de l'inéquation est donc :
96
+
97
+ $$
98
+ ${answer}
99
+ $$`;
100
+ };
101
+ const getKeys = () => [
102
+ "S",
103
+ "equal",
104
+ "lbracket",
105
+ "rbracket",
106
+ "semicolon",
107
+ ];
108
+ const isAnswerValid = (ans, { answer }) => {
109
+ try {
110
+ const parsed = intervalParser(ans.replaceAll("S", "").replaceAll("=", ""));
111
+ if (!parsed)
112
+ return false;
113
+ return answer === "S=\\ " + parsed.simplify().toTex();
114
+ }
115
+ catch (err) {
116
+ return handleVEAError(err);
117
+ }
118
+ };
119
+ const getSqrtInequalityQuestion = () => {
120
+ const twoSided = coinFlip();
121
+ let aIds;
122
+ let bIds;
123
+ if (twoSided) {
124
+ const aVal = randint(1, 10);
125
+ const bVal = randint(aVal + 1, aVal + 10);
126
+ aIds = aVal.toTree().toIdentifiers();
127
+ bIds = bVal.toTree().toIdentifiers();
128
+ }
129
+ else {
130
+ const aVal = randint(1, 10);
131
+ aIds = aVal.toTree().toIdentifiers();
132
+ }
133
+ const identifiers = { twoSided, a: aIds, b: bIds };
134
+ return {
135
+ answer: getAnswer(identifiers),
136
+ instruction: getInstruction(identifiers),
137
+ keys: getKeys(identifiers),
138
+ answerFormat: "tex",
139
+ identifiers,
140
+ hint: getHint(identifiers),
141
+ correction: getCorrection(identifiers),
142
+ };
143
+ };
144
+ export const sqrtInequality = {
145
+ id: "sqrtInequality",
146
+ label: "Résoudre une inéquation du type $a<\\sqrt{x}<b$ ou $\\sqrt{x}<b$",
147
+ isSingleStep: true,
148
+ generator: (nb, opts) => getDistinctQuestions(() => getSqrtInequalityQuestion(opts), nb),
149
+ freeTimer: 60,
150
+ getInstruction,
151
+ getHint,
152
+ getCorrection,
153
+ getAnswer,
154
+ getPropositions,
155
+ getQuestionFromIdentifiers: ({ twoSided, a, b }) => getSqrtInequalityQuestion(),
156
+ getKeys,
157
+ isAnswerValid,
158
+ hasHintAndCorrection: true,
159
+ subject: "Mathématiques",
160
+ };
@@ -63,7 +63,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
63
63
  };
64
64
  export const absoluteNumber = {
65
65
  id: "absoluteNumber",
66
- label: "Calculer avec des valeurs absolues",
66
+ label: "Calculer la valeur absolue d'un nombre",
67
67
  isSingleStep: true,
68
68
  generator: (nb, opts) => getDistinctQuestions(() => getAbsoluteNumberQuestion(opts), nb),
69
69
  qcmTimer: 60,
@@ -1 +1 @@
1
- {"version":3,"file":"absoluteValueInequations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/absolute/absoluteValueInequations.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AA2GF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}
1
+ {"version":3,"file":"absoluteValueInequations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/absolute/absoluteValueInequations.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AA6GF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAa1D,CAAC"}
@@ -14,7 +14,11 @@ const getInstruction = (identifiers) => {
14
14
  const diff = new NumberNode(b - a);
15
15
  const add = new NumberNode(b + a);
16
16
  const poly = new Polynomial([-b, 1]);
17
- return `Résoudre l'inéquation $|${poly.toTree().toTex()}|${isStrict ? "<" : "\\le"}${a}$.`;
17
+ return `Résoudre l'inéquation :
18
+
19
+ $$
20
+ |${poly.toTree().toTex()}|${isStrict ? "<" : "\\le"}${a}
21
+ $$`;
18
22
  };
19
23
  const getAnswer = (identifiers) => {
20
24
  const { a, b, isStrict } = identifiers;
@@ -1 +1 @@
1
- {"version":3,"file":"graphicEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/graphicEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAiBrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CAClC,CAAC;AA4HF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
1
+ {"version":3,"file":"graphicEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/graphicEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAmBrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CAClC,CAAC;AA6JF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAejD,CAAC"}
@@ -3,6 +3,7 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { discreteSetKeys } from "../../../../exercises/utils/keys/discreteSetKeys.js";
4
4
  import { randomColor } from "../../../../geogebra/colors.js";
5
5
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
6
+ import { Point } from "../../../../math/geometry/point.js";
6
7
  import { randint } from "../../../../math/utils/random/randint.js";
7
8
  import { EquationSolutionNode } from "../../../../tree/nodes/equations/equationSolutionNode.js";
8
9
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
@@ -10,8 +11,36 @@ import { DiscreteSetNode, } from "../../../../tree/nodes/sets/discreteSetNode.js
10
11
  import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
11
12
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
12
13
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
14
+ import { pluralize } from "../../../../utils/strings/pluralize.js";
13
15
  const getInstruction = (identifiers) => {
14
- return `Déterminer graphiquement les solutions de l'équation $f(x) = ${identifiers.yValue}$ $f$ est la fonction représentée ci-dessous.`;
16
+ return `On considère la fonction $f$ dont la courbe représentative est tracée ci-dessous.
17
+
18
+ Déterminer graphiquement les solutions de l'équation $f(x) = ${identifiers.yValue}$.`;
19
+ };
20
+ const getHint = (identifiers) => {
21
+ const { splinePoints, yValue } = identifiers;
22
+ return `Les solutions de l'équation $f(x) = ${yValue}$ sont les abscisses des points de la courbe d'ordonnée $${yValue}$.`;
23
+ };
24
+ const getCorrection = (identifiers) => {
25
+ const { splinePoints, yValue } = identifiers;
26
+ const xSolutions = identifiers.splinePoints
27
+ .filter((p) => p[1] === identifiers.yValue)
28
+ .map((p) => p[0]);
29
+ const names = ["A", "B", "C", "D", "E"];
30
+ const points = xSolutions.map((x, i) => new Point(names[i], x, yValue));
31
+ return `Les solutions de l'équation $f(x) = ${yValue}$ sont les abscisses des points de la courbe d'ordonnée $${yValue}$.
32
+
33
+ On trouve graphiquement $${xSolutions.length}$ ${pluralize("point", xSolutions.length)} d'ordonnée $${yValue}$ :
34
+
35
+ $$
36
+ ${points.map((e) => e.toTexWithCoords()).join(" \\ ; \\ ")}
37
+ $$
38
+
39
+ L'ensemble des solutions de l'équation $f(x) = ${yValue}$ est donc :
40
+
41
+ $$
42
+ ${getAnswer(identifiers)}
43
+ $$`;
15
44
  };
16
45
  const getGGBOptions = (identifiers) => {
17
46
  const { splinePoints } = identifiers;
@@ -86,6 +115,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
86
115
  answerFormat: "tex",
87
116
  ggbOptions: getGGBOptions(identifiers),
88
117
  identifiers,
118
+ hint: getHint(identifiers),
119
+ correction: getCorrection(identifiers),
89
120
  };
90
121
  return question;
91
122
  };
@@ -129,4 +160,5 @@ export const graphicEquation = {
129
160
  hasGeogebra: true,
130
161
  subject: "Mathématiques",
131
162
  getQuestionFromIdentifiers,
163
+ hasHintAndCorrection: true,
132
164
  };
@@ -1 +1 @@
1
- {"version":3,"file":"twoFunctionsEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/twoFunctionsEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAarC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAiKF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAatD,CAAC"}
1
+ {"version":3,"file":"twoFunctionsEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/basics/twoFunctionsEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AA8LF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
@@ -9,6 +9,30 @@ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
9
9
  import { DiscreteSetNode } from "../../../../tree/nodes/sets/discreteSetNode.js";
10
10
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
11
11
  import { random } from "../../../../utils/alea/random.js";
12
+ import { Point } from "../../../../math/geometry/point.js";
13
+ import { pluralize } from "../../../../utils/strings/pluralize.js";
14
+ const getHint = (identifiers) => {
15
+ const { fSplinePoints, gSplinePoints, xSolutions, yValue } = identifiers;
16
+ return `Les solutions de l'équation $f(x) = g(x)$ sont les abscisses des points qui appartiennent à la fois à la courbe de $f$ et à celle de $g$.`;
17
+ };
18
+ const getCorrection = (identifiers) => {
19
+ const { fSplinePoints, gSplinePoints, xSolutions, yValue } = identifiers;
20
+ const names = ["A", "B", "C", "D", "E"];
21
+ const points = xSolutions.map((x, i) => new Point(names[i], x, yValue));
22
+ return `Les solutions de l'équation $f(x) = g(x)$ sont les abscisses des points qui appartiennent à la fois à la courbe de $f$ et à celle de $g$.
23
+
24
+ On trouve graphiquement $${xSolutions.length}$ ${pluralize("point", xSolutions.length)} d'intersection des deux courbes :
25
+
26
+ $$
27
+ ${points.map((e) => e.toTexWithCoords()).join(" \\ ; \\ ")}
28
+ $$
29
+
30
+ L'ensemble des solutions de l'équation $f(x) = g(x)$ est donc :
31
+
32
+ $$
33
+ ${getAnswer(identifiers)}
34
+ $$`;
35
+ };
12
36
  const getInstruction = (identifiers) => {
13
37
  return `Déterminer graphiquement les solutions de l'équation $f(x) = g(x)$ où $f$ et $g$ sont les fonctions représentées ci-dessous.`;
14
38
  };
@@ -103,6 +127,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
103
127
  answerFormat: "tex",
104
128
  identifiers,
105
129
  ggbOptions: getGGBOptions(identifiers),
130
+ hint: getHint(identifiers),
131
+ correction: getCorrection(identifiers),
106
132
  };
107
133
  return question;
108
134
  };
@@ -142,4 +168,5 @@ export const twoFunctionsEquation = {
142
168
  hasGeogebra: true,
143
169
  subject: "Mathématiques",
144
170
  getQuestionFromIdentifiers,
171
+ hasHintAndCorrection: true,
145
172
  };
@@ -1 +1 @@
1
- {"version":3,"file":"varTableExtremaReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/varTableExtremaReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AA4JF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAcxD,CAAC"}
1
+ {"version":3,"file":"varTableExtremaReading.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/variations/varTableExtremaReading.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AA+LF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAexD,CAAC"}