math-exercises 3.0.209 → 3.0.212

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 (66) hide show
  1. package/lib/exercises/math/arithmetic/congruenceBasicEquation.d.ts +9 -0
  2. package/lib/exercises/math/arithmetic/congruenceBasicEquation.d.ts.map +1 -0
  3. package/lib/exercises/math/arithmetic/congruenceBasicEquation.js +116 -0
  4. package/lib/exercises/math/arithmetic/diophantianEquationSimpleSolution.d.ts +9 -0
  5. package/lib/exercises/math/arithmetic/diophantianEquationSimpleSolution.d.ts.map +1 -0
  6. package/lib/exercises/math/arithmetic/diophantianEquationSimpleSolution.js +129 -0
  7. package/lib/exercises/math/arithmetic/fermatUsageOnBigPowers.d.ts +9 -0
  8. package/lib/exercises/math/arithmetic/fermatUsageOnBigPowers.d.ts.map +1 -0
  9. package/lib/exercises/math/arithmetic/fermatUsageOnBigPowers.js +140 -0
  10. package/lib/exercises/math/arithmetic/fillCongruenceTableFirstDegree.d.ts +9 -0
  11. package/lib/exercises/math/arithmetic/fillCongruenceTableFirstDegree.d.ts.map +1 -0
  12. package/lib/exercises/math/arithmetic/fillCongruenceTableFirstDegree.js +106 -0
  13. package/lib/exercises/math/arithmetic/findBezoutCoefficients.d.ts +8 -0
  14. package/lib/exercises/math/arithmetic/findBezoutCoefficients.d.ts.map +1 -0
  15. package/lib/exercises/math/arithmetic/findBezoutCoefficients.js +175 -0
  16. package/lib/exercises/math/arithmetic/hasDiophantianEquationSolution.d.ts +9 -0
  17. package/lib/exercises/math/arithmetic/hasDiophantianEquationSolution.d.ts.map +1 -0
  18. package/lib/exercises/math/arithmetic/hasDiophantianEquationSolution.js +105 -0
  19. package/lib/exercises/math/arithmetic/index.d.ts +8 -0
  20. package/lib/exercises/math/arithmetic/index.d.ts.map +1 -1
  21. package/lib/exercises/math/arithmetic/index.js +8 -0
  22. package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.d.ts +10 -0
  23. package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.d.ts.map +1 -0
  24. package/lib/exercises/math/arithmetic/pgcdFromPrimeDecomposition.js +134 -0
  25. package/lib/exercises/math/arithmetic/pgcdHomogenuity.d.ts +8 -0
  26. package/lib/exercises/math/arithmetic/pgcdHomogenuity.d.ts.map +1 -0
  27. package/lib/exercises/math/arithmetic/pgcdHomogenuity.js +124 -0
  28. package/lib/exercises/math/calcul/ordering/compareFracAndDec.js +2 -2
  29. package/lib/exercises/math/functions/continuity/index.d.ts +2 -0
  30. package/lib/exercises/math/functions/continuity/index.d.ts.map +1 -1
  31. package/lib/exercises/math/functions/continuity/index.js +2 -0
  32. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.d.ts +11 -0
  33. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.d.ts.map +1 -0
  34. package/lib/exercises/math/functions/continuity/pyContinuityBalayageInstructionCompletion.js +276 -0
  35. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.d.ts +10 -0
  36. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.d.ts.map +1 -0
  37. package/lib/exercises/math/functions/continuity/pyContinuityDichotomyInstructionCompletion.js +265 -0
  38. package/lib/exercises/math/integration/algorithms/index.d.ts +2 -0
  39. package/lib/exercises/math/integration/algorithms/index.d.ts.map +1 -0
  40. package/lib/exercises/math/integration/algorithms/index.js +1 -0
  41. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.d.ts +10 -0
  42. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.d.ts.map +1 -0
  43. package/lib/exercises/math/integration/algorithms/pyIntegrationInstructionCompletion.js +273 -0
  44. package/lib/exercises/math/integration/index.d.ts +1 -0
  45. package/lib/exercises/math/integration/index.d.ts.map +1 -1
  46. package/lib/exercises/math/integration/index.js +1 -0
  47. package/lib/exercises/math/limits/algorithms/index.d.ts +2 -0
  48. package/lib/exercises/math/limits/algorithms/index.d.ts.map +1 -0
  49. package/lib/exercises/math/limits/algorithms/index.js +1 -0
  50. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.d.ts +17 -0
  51. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.d.ts.map +1 -0
  52. package/lib/exercises/math/limits/algorithms/pyLimitProgramExecution.js +353 -0
  53. package/lib/exercises/math/limits/index.d.ts +1 -0
  54. package/lib/exercises/math/limits/index.d.ts.map +1 -1
  55. package/lib/exercises/math/limits/index.js +1 -0
  56. package/lib/index.d.ts +54 -0
  57. package/lib/index.d.ts.map +1 -1
  58. package/lib/math/utils/arithmetic/bezout.d.ts +2 -0
  59. package/lib/math/utils/arithmetic/bezout.d.ts.map +1 -0
  60. package/lib/math/utils/arithmetic/bezout.js +10 -0
  61. package/lib/tests/singleExo.test.js +2 -2
  62. package/lib/tree/nodes/node.d.ts +1 -0
  63. package/lib/tree/nodes/node.d.ts.map +1 -1
  64. package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
  65. package/lib/tree/nodes/operators/powerNode.js +2 -0
  66. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ mod: number;
6
+ };
7
+ export declare const congruenceBasicEquation: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=congruenceBasicEquation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"congruenceBasicEquation.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/arithmetic/congruenceBasicEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AA6GF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAkBzD,CAAC"}
@@ -0,0 +1,116 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../math/utils/random/randint.js";
4
+ import { add } from "../../../tree/nodes/operators/addNode.js";
5
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
+ import { substract } from "../../../tree/nodes/operators/substractNode.js";
7
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
8
+ import { doWhile } from "../../../utils/doWhile.js";
9
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
10
+ import { alignTex } from "../../../utils/latex/alignTex.js";
11
+ const getPropositions = (n, { answer, ...identifiers }) => {
12
+ const propositions = [];
13
+ addValidProp(propositions, answer);
14
+ const { a, b, mod } = identifiers;
15
+ const r = (b - a) % mod;
16
+ tryToAddWrongProp(propositions, r.frenchify());
17
+ propWhile(propositions, n, () => {
18
+ const fakeR = doWhile(() => randint(-10, 10), (x) => (x - r) % mod === 0);
19
+ tryToAddWrongProp(propositions, add(multiply(mod, "k"), fakeR).toTex());
20
+ });
21
+ return shuffleProps(propositions, n);
22
+ };
23
+ const getAnswer = (identifiers) => {
24
+ const { a, b, mod } = identifiers;
25
+ const r = (b - a) % mod;
26
+ return add(multiply(mod, "k"), r).toTex();
27
+ };
28
+ const getInstruction = (identifiers) => {
29
+ const { a, b, mod } = identifiers;
30
+ return `Résoudre l'équation suivante dans $\\mathbb{Z}$ :
31
+
32
+ $$
33
+ ${add("x", a).toTex()} \\equiv ${b} \\ [${mod}]
34
+ $$
35
+
36
+ Donner la forme des solutions pour $k\\in \\mathbb{Z}$.`;
37
+ };
38
+ const getHint = () => {
39
+ return `L'addition est compatible avec la congruence : c'est à dire qu'on peut ajouter ou soustraire un même nombre aux deux membres de l'équation.`;
40
+ };
41
+ const getCorrection = (identifiers) => {
42
+ const { a, b, mod } = identifiers;
43
+ const r = (b - a) % mod;
44
+ return `Puisque l'addition est compatible avec la congruence, on a :
45
+
46
+ ${alignTex([
47
+ ["", `${add("x", a).toTex()} \\equiv ${b} \\ [${mod}]`],
48
+ ["\\iff", `x \\equiv ${r} \\ [${mod}]`],
49
+ ])}
50
+
51
+ Les solutions sont donc de la forme :
52
+
53
+ $$
54
+ ${add(multiply(mod, "k"), r).toTex()}
55
+ $$
56
+
57
+ avec $k \\in \\mathbb{Z}$.
58
+ `;
59
+ };
60
+ const getKeys = () => {
61
+ return ["k"];
62
+ };
63
+ const isAnswerValid = (ans, { answer, mod }) => {
64
+ try {
65
+ const parsed = parseAlgebraic(ans).simplify();
66
+ const answerNode = parseAlgebraic(answer).simplify();
67
+ return (substract(parsed, answerNode)
68
+ .simplify({ towardsDistribute: true })
69
+ .evaluate() %
70
+ mod ===
71
+ 0);
72
+ }
73
+ catch (err) {
74
+ return handleVEAError(err);
75
+ }
76
+ };
77
+ const getCongruenceBasicEquationQuestion = () => {
78
+ const mod = randint(3, 8);
79
+ const a = randint(1, mod);
80
+ const b = randint(1, mod, [a]);
81
+ const identifiers = {
82
+ a,
83
+ b,
84
+ mod,
85
+ };
86
+ return getQuestionFromIdentifiers(identifiers);
87
+ };
88
+ const getQuestionFromIdentifiers = (identifiers) => {
89
+ return {
90
+ answer: getAnswer(identifiers),
91
+ instruction: getInstruction(identifiers),
92
+ keys: getKeys(identifiers),
93
+ answerFormat: "tex",
94
+ identifiers,
95
+ hint: getHint(identifiers),
96
+ correction: getCorrection(identifiers),
97
+ };
98
+ };
99
+ export const congruenceBasicEquation = {
100
+ id: "congruenceBasicEquation",
101
+ connector: "\\iff",
102
+ label: "Résoudre une équation de congruence du type $x+a \\equiv b \\ [n]$",
103
+ isSingleStep: true,
104
+ generator: (nb, opts) => getDistinctQuestions(() => getCongruenceBasicEquationQuestion(opts), nb),
105
+ qcmTimer: 60,
106
+ freeTimer: 60,
107
+ getPropositions,
108
+ isAnswerValid,
109
+ subject: "Mathématiques",
110
+ getInstruction,
111
+ getHint,
112
+ getCorrection,
113
+ getAnswer,
114
+ getQuestionFromIdentifiers,
115
+ hasHintAndCorrection: true,
116
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ };
7
+ export declare const diophantianEquationSimpleSolution: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=diophantianEquationSimpleSolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diophantianEquationSimpleSolution.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/arithmetic/diophantianEquationSimpleSolution.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;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AA8GF,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,WAAW,CAsBnE,CAAC"}
@@ -0,0 +1,129 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { Point } from "../../../math/geometry/point.js";
4
+ import { randint } from "../../../math/utils/random/randint.js";
5
+ import { randTupleInt } from "../../../math/utils/random/randTupleInt.js";
6
+ import { add } from "../../../tree/nodes/operators/addNode.js";
7
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
8
+ import { pointParser } from "../../../tree/parsers/pointParser.js";
9
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
10
+ const getPropositions = (n, { answer, a, b, c }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer);
13
+ propWhile(propositions, n, () => {
14
+ const u = randint(-3, 3, [0]);
15
+ const v = randint(-3, 3, [0]);
16
+ if (a * u + b * v === c)
17
+ return;
18
+ tryToAddWrongProp(propositions, new Point("A", u, v).toCoords());
19
+ });
20
+ return shuffleProps(propositions, n);
21
+ };
22
+ const getCoeffs = (identifiers) => {
23
+ const { a, b, c } = identifiers;
24
+ //permet d'avoir les valeurs les plus simples en premier
25
+ for (let u = 1; u < 4; u++) {
26
+ for (let v = 1; v < 4; v++) {
27
+ if (a * u + b * v === c)
28
+ return [u, v];
29
+ if (a * u - b * v === c)
30
+ return [u, -v];
31
+ if (-a * u + b * v === c)
32
+ return [-u, v];
33
+ if (-a * u - b * v === c)
34
+ return [-u, -v];
35
+ }
36
+ }
37
+ throw new Error("No solution");
38
+ };
39
+ const getAnswer = (identifiers) => {
40
+ const [u, v] = getCoeffs(identifiers);
41
+ return new Point("A", u, v).toCoords();
42
+ };
43
+ const getInstruction = (identifiers) => {
44
+ const { a, b, c } = identifiers;
45
+ return `Déterminer une solution particulière de l'équation suivante, où $(x;y)\\in \\mathbb{Z}$ :
46
+
47
+ $$
48
+ ${add(multiply(a, "x"), multiply(b, "y")).toTex()} = ${c}
49
+ $$
50
+
51
+ On donnera le couple solution sous la forme $(u;v)$.`;
52
+ };
53
+ const getHint = () => {
54
+ return `Essaie des couples simples, avec des valeurs pour $x$ et $y$ qui rendent les calculs faciles.`;
55
+ };
56
+ const getCorrection = (identifiers) => {
57
+ const { a, b, c } = identifiers;
58
+ const [u, v] = getCoeffs(identifiers);
59
+ return `En essayant avec des valeurs simples pour $x$ et $y$, on remarque que :
60
+
61
+ $$
62
+ ${add(multiply(a, u), multiply(b, v)).toTex()} = ${c}
63
+ $$
64
+
65
+ Le couple $(${u};${v})$ est donc une solution particulière de l'équation.`;
66
+ };
67
+ const getKeys = () => {
68
+ return ["semicolon"];
69
+ };
70
+ const isAnswerValid = (ans, { a, b, c }) => {
71
+ try {
72
+ const parsed = pointParser(ans);
73
+ if (!parsed)
74
+ return false;
75
+ const [u, v] = [parsed.x.evaluate(), parsed.y.evaluate()];
76
+ return a * u + b * v === c;
77
+ }
78
+ catch (err) {
79
+ return handleVEAError(err);
80
+ }
81
+ };
82
+ const getDiophantianEquationSimpleSolutionQuestion = () => {
83
+ let a = 0;
84
+ let b = 0;
85
+ let c = 10000;
86
+ //(1, x) / (-1, x) pour x<4
87
+ //(2, x) pour x <4
88
+ while (Math.abs(c) > 50) {
89
+ const [u, v] = randTupleInt(2, {
90
+ from: -3,
91
+ to: 4,
92
+ elExcludes: [0],
93
+ });
94
+ a = randint(3, 50);
95
+ b = randint(-50, 50, [-1, 0, 1]);
96
+ c = a * u + b * v;
97
+ }
98
+ const identifiers = { a, b, c };
99
+ return getQuestionFromIdentifiers(identifiers);
100
+ };
101
+ const getQuestionFromIdentifiers = (identifiers) => {
102
+ return {
103
+ answer: getAnswer(identifiers),
104
+ instruction: getInstruction(identifiers),
105
+ keys: getKeys(identifiers),
106
+ answerFormat: "tex",
107
+ identifiers,
108
+ hint: getHint(identifiers),
109
+ correction: getCorrection(identifiers),
110
+ };
111
+ };
112
+ export const diophantianEquationSimpleSolution = {
113
+ id: "diophantianEquationSimpleSolution",
114
+ connector: "\\iff",
115
+ label: "Trouver une solution particulière simple d'une équation diophantienne $ax+by=c$",
116
+ isSingleStep: true,
117
+ generator: (nb, opts) => getDistinctQuestions(() => getDiophantianEquationSimpleSolutionQuestion(opts), nb),
118
+ qcmTimer: 60,
119
+ freeTimer: 60,
120
+ getPropositions,
121
+ isAnswerValid,
122
+ subject: "Mathématiques",
123
+ getInstruction,
124
+ getHint,
125
+ getCorrection,
126
+ getAnswer,
127
+ getQuestionFromIdentifiers,
128
+ hasHintAndCorrection: true,
129
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ p: number;
4
+ a: number;
5
+ pow: number;
6
+ };
7
+ export declare const fermatUsageOnBigPowers: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=fermatUsageOnBigPowers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fermatUsageOnBigPowers.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/arithmetic/fermatUsageOnBigPowers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AA2IF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAkBxD,CAAC"}
@@ -0,0 +1,140 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../exercises/vea/numberVEA.js";
4
+ import { randint } from "../../../math/utils/random/randint.js";
5
+ import { add } from "../../../tree/nodes/operators/addNode.js";
6
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
7
+ import { power } from "../../../tree/nodes/operators/powerNode.js";
8
+ import { random } from "../../../utils/alea/random.js";
9
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
10
+ import { alignTex } from "../../../utils/latex/alignTex.js";
11
+ const getPropositions = (n, { answer, p }) => {
12
+ const propositions = [];
13
+ addValidProp(propositions, answer);
14
+ propWhile(propositions, n, () => {
15
+ tryToAddWrongProp(propositions, randint(0, p).frenchify());
16
+ });
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { p, a, pow } = identifiers;
21
+ const r = pow % (p - 1);
22
+ return (a ** r % p).frenchify();
23
+ };
24
+ const getInstruction = (identifiers) => {
25
+ const { p, a, pow } = identifiers;
26
+ return `Donner le reste dans la division euclidienne de $${power(a, pow).toTex()}$ par $${p}$.`;
27
+ };
28
+ const getHint = () => {
29
+ return `Utilise le petit théorème de Fermat : si $p$ est un nombre premier ne divisant pas $n$, alors
30
+
31
+ $$
32
+ n^{p-1} \\equiv 1\\ [p]
33
+ $$`;
34
+ };
35
+ const getCorrection = (identifiers) => {
36
+ const { p, a, pow } = identifiers;
37
+ const q = Math.floor(pow / (p - 1));
38
+ const r = pow % (p - 1);
39
+ const finalIsCalculable = a ** r < 100;
40
+ const answer = getAnswer(identifiers);
41
+ return `Puisque $${p}$ est un nombre premier et qu'il ne divise pas $${a}$, d'après le petit théorème de Fermat :
42
+
43
+ $$
44
+ ${power(a, p - 1).toTex()} \\equiv 1\\ [${p}]
45
+ $$
46
+
47
+ On écrit la division euclidienne de $${pow}$ par $${p - 1}$ :
48
+
49
+ $$
50
+ ${pow} = ${q}\\times ${p - 1} + ${r}
51
+ $$
52
+
53
+ On a donc :
54
+
55
+ ${alignTex([
56
+ [
57
+ power(a, pow).toTex(),
58
+ "\\equiv",
59
+ power(a, add(multiply(q, p - 1), r)).toTex() + `\\ [${p}]`,
60
+ ],
61
+ [
62
+ "",
63
+ "\\equiv",
64
+ multiply(power(power(a, p - 1), q), power(a, r)).toTex() + `\\ [${p}]`,
65
+ ],
66
+ ["", "\\equiv", multiply(power("1", q), power(a, r)).toTex() + `\\ [${p}]`],
67
+ ["", "\\equiv", power(a, r).toTex() + `\\ [${p}]`],
68
+ ])}
69
+
70
+ ${finalIsCalculable
71
+ ? `Or, $${power(a, r).toTex()} \\equiv ${power(a, r)
72
+ .evaluate()
73
+ .frenchify()} \\equiv ${answer} \\ [${p}]$
74
+
75
+ `
76
+ : `Or, on a :
77
+
78
+ $$
79
+ ${power(a, 2).toTex()} \\equiv ${power(a, 2).evaluate().frenchify()}\\equiv ${power(a, 2).evaluate() % p} \\ [${p}]
80
+ $$
81
+
82
+ donc
83
+
84
+ $$
85
+ ${power(a, r).toTex()} \\equiv ${power(a, r).evaluate() % p} \\ [${p}]
86
+ $$`}
87
+
88
+ Le reste de la division euclidienne de $${power(a, pow).toTex()}$ par $${p}$ est donc $${answer}$.
89
+ `;
90
+ };
91
+ const getKeys = () => {
92
+ return [];
93
+ };
94
+ const isAnswerValid = (ans, { answer }) => {
95
+ try {
96
+ return numberVEA(ans, answer);
97
+ }
98
+ catch (err) {
99
+ return handleVEAError(err);
100
+ }
101
+ };
102
+ const getFermatUsageOnBigPowersQuestion = () => {
103
+ const p = random([5, 7, 11, 13]);
104
+ const pow = random([100, 2026, 2025, 2027, 1000, 1234].filter((e) => e % (p - 1) !== 0));
105
+ const a = randint(2, p - 1);
106
+ const identifiers = {
107
+ a,
108
+ p,
109
+ pow,
110
+ };
111
+ return getQuestionFromIdentifiers(identifiers);
112
+ };
113
+ const getQuestionFromIdentifiers = (identifiers) => {
114
+ return {
115
+ answer: getAnswer(identifiers),
116
+ instruction: getInstruction(identifiers),
117
+ keys: getKeys(identifiers),
118
+ answerFormat: "tex",
119
+ identifiers,
120
+ hint: getHint(identifiers),
121
+ correction: getCorrection(identifiers),
122
+ };
123
+ };
124
+ export const fermatUsageOnBigPowers = {
125
+ id: "fermatUsageOnBigPowers",
126
+ label: "Utiliser le petit théorème de Fermat pour calculer le reste d'une division euclidienne",
127
+ isSingleStep: true,
128
+ generator: (nb, opts) => getDistinctQuestions(() => getFermatUsageOnBigPowersQuestion(opts), nb),
129
+ qcmTimer: 60,
130
+ freeTimer: 60,
131
+ getPropositions,
132
+ isAnswerValid,
133
+ subject: "Mathématiques",
134
+ getInstruction,
135
+ getHint,
136
+ getCorrection,
137
+ getAnswer,
138
+ getQuestionFromIdentifiers,
139
+ hasHintAndCorrection: true,
140
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ mod: number;
4
+ a: number;
5
+ b: number;
6
+ };
7
+ export declare const fillCongruenceTableFirstDegree: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=fillCongruenceTableFirstDegree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fillCongruenceTableFirstDegree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/arithmetic/fillCongruenceTableFirstDegree.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AAiGF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,CAqBhE,CAAC"}
@@ -0,0 +1,106 @@
1
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
2
+ import { valueTableVEA } from "../../../exercises/vea/valueTableVEA.js";
3
+ import { randint } from "../../../math/utils/random/randint.js";
4
+ import { add } from "../../../tree/nodes/operators/addNode.js";
5
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
7
+ const getAnswerTable = (identifiers) => {
8
+ const { a, b, mod } = identifiers;
9
+ const aff = add(multiply(a, "x"), b).toTex();
10
+ const table = [
11
+ [`\\text{Si } x\\equiv \\ldots \\ [${mod}]`],
12
+ [`\\text{alors } ${aff} \\equiv \\ldots \\ [${mod}]`],
13
+ ];
14
+ for (let i = 0; i < mod; i++) {
15
+ table[0].push(i.frenchify());
16
+ table[1].push(((a * i + b) % mod).frenchify());
17
+ }
18
+ return table;
19
+ };
20
+ const getInstruction = () => {
21
+ return `Remplir le tableau de congruence suivant :
22
+
23
+ `;
24
+ };
25
+ const getHint = () => {
26
+ return `La congruence est compatible avec la multiplication et l'addition.
27
+
28
+ `;
29
+ };
30
+ const getCorrection = (identifiers) => {
31
+ const { a, b, mod } = identifiers;
32
+ const aff = add(multiply(a, "x"), b);
33
+ const indexes = Array.from({ length: mod }, (_, i) => i);
34
+ const lines = indexes.map((i) => {
35
+ const raw = aff.toDetailedEvaluation({ x: i.toTree() }).simplify();
36
+ const simp = raw.simplify();
37
+ const modulo = simp.evaluate() % mod;
38
+ const isNotModuled = simp.toTex() !== modulo.frenchify();
39
+ return `- Si $x\\equiv ${i} \\ [${mod}]$ alors $${aff.toTex()} \\equiv ${raw.toTex()} \\ [${mod}] ${isNotModuled ? `\\equiv ${modulo} \\ [${mod}]` : ""}$`;
40
+ });
41
+ return `La congruence est compatible avec la multiplication et l'addition. On a donc :
42
+
43
+ ${lines.join("\n \n")}
44
+ `;
45
+ };
46
+ const getKeys = () => {
47
+ return [];
48
+ };
49
+ const isAnswerTableValid = (ans, { answerTable }) => {
50
+ try {
51
+ return valueTableVEA(ans, answerTable);
52
+ }
53
+ catch (err) {
54
+ return handleVEAError(err);
55
+ }
56
+ };
57
+ const getFillCongruenceTableFirstDegreeQuestion = () => {
58
+ const mod = randint(3, 6);
59
+ const a = randint(2, mod);
60
+ const b = randint(-mod + 1, mod, [0]);
61
+ const identifiers = {
62
+ a,
63
+ b,
64
+ mod,
65
+ };
66
+ return getQuestionFromIdentifiers(identifiers);
67
+ };
68
+ const getQuestionFromIdentifiers = (identifiers) => {
69
+ const { a, b, mod } = identifiers;
70
+ const aff = add(multiply(a, "x"), b).toTex();
71
+ const table = [
72
+ [`\\text{Si } x\\equiv \\ldots \\ [${mod}]`],
73
+ [`\\text{alors } ${aff} \\equiv \\ldots \\ [${mod}]`],
74
+ ];
75
+ for (let i = 0; i < mod; i++) {
76
+ table[0].push(i.frenchify());
77
+ table[1].push("");
78
+ }
79
+ return {
80
+ answerTable: getAnswerTable(identifiers),
81
+ instruction: getInstruction(identifiers),
82
+ keys: getKeys(identifiers),
83
+ answerFormat: "tex",
84
+ identifiers,
85
+ hint: getHint(identifiers),
86
+ correction: getCorrection(identifiers),
87
+ initTable: table,
88
+ };
89
+ };
90
+ export const fillCongruenceTableFirstDegree = {
91
+ id: "fillCongruenceTableFirstDegree",
92
+ label: "Remplir le tableau de congruence d'une expression du type $ax+b$",
93
+ isSingleStep: true,
94
+ generator: (nb, opts) => getDistinctQuestions(() => getFillCongruenceTableFirstDegreeQuestion(opts), nb),
95
+ qcmTimer: 60,
96
+ freeTimer: 60,
97
+ isAnswerTableValid,
98
+ subject: "Mathématiques",
99
+ getInstruction,
100
+ getHint,
101
+ getCorrection,
102
+ getAnswerTable,
103
+ getQuestionFromIdentifiers,
104
+ hasHintAndCorrection: true,
105
+ answerType: "valueTable",
106
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ export declare const findBezoutCoefficients: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=findBezoutCoefficients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findBezoutCoefficients.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/arithmetic/findBezoutCoefficients.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AA0KF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAkBxD,CAAC"}