math-exercises 3.0.140 → 3.0.142

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 (95) hide show
  1. package/lib/exercises/math/calcul/arithmetics/euclideanDivision.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/arithmetics/euclideanDivision.js +65 -8
  3. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.d.ts +9 -0
  4. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.d.ts.map +1 -0
  5. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.js +111 -0
  6. package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.js +3 -6
  8. package/lib/exercises/math/calcul/arithmetics/index.d.ts +4 -0
  9. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/arithmetics/index.js +4 -1
  11. package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.d.ts +8 -0
  12. package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.d.ts.map +1 -0
  13. package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.js +128 -0
  14. package/lib/exercises/math/calcul/fractions/fractionEquality.d.ts +10 -0
  15. package/lib/exercises/math/calcul/fractions/fractionEquality.d.ts.map +1 -0
  16. package/lib/exercises/math/calcul/fractions/fractionEquality.js +123 -0
  17. package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
  18. package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
  19. package/lib/exercises/math/calcul/fractions/index.js +1 -0
  20. package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.d.ts +8 -0
  21. package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.d.ts.map +1 -0
  22. package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.js +392 -0
  23. package/lib/exercises/math/calcul/proportionality/index.d.ts +2 -0
  24. package/lib/exercises/math/calcul/proportionality/index.d.ts.map +1 -1
  25. package/lib/exercises/math/calcul/proportionality/index.js +2 -0
  26. package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.d.ts +8 -0
  27. package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.d.ts.map +1 -0
  28. package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.js +349 -0
  29. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.d.ts.map +1 -1
  30. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.js +10 -1
  31. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts +4 -1
  32. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
  33. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +32 -9
  34. package/lib/exercises/math/calculLitteral/equation/index.d.ts +2 -0
  35. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  36. package/lib/exercises/math/calculLitteral/equation/index.js +2 -0
  37. package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.js +1 -1
  38. package/lib/exercises/math/calculLitteral/equation/proportionEquation.d.ts +11 -0
  39. package/lib/exercises/math/calculLitteral/equation/proportionEquation.d.ts.map +1 -0
  40. package/lib/exercises/math/calculLitteral/equation/proportionEquation.js +152 -0
  41. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts +12 -0
  42. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts.map +1 -0
  43. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.js +197 -0
  44. package/lib/exercises/math/calculLitteral/factorisation/factoType2.d.ts.map +1 -1
  45. package/lib/exercises/math/calculLitteral/factorisation/factoType2.js +30 -4
  46. package/lib/exercises/math/calculLitteral/factorisation/factoType3.d.ts.map +1 -1
  47. package/lib/exercises/math/calculLitteral/factorisation/factoType3.js +30 -4
  48. package/lib/exercises/math/calculLitteral/factorisation/factoType4.d.ts.map +1 -1
  49. package/lib/exercises/math/calculLitteral/factorisation/factoType4.js +30 -5
  50. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.js +1 -1
  51. package/lib/exercises/math/dataRepresentations/index.js +1 -0
  52. package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.d.ts +12 -0
  53. package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.d.ts.map +1 -0
  54. package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.js +175 -0
  55. package/lib/exercises/math/functions/affines/index.d.ts +2 -0
  56. package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
  57. package/lib/exercises/math/functions/affines/index.js +2 -0
  58. package/lib/exercises/math/functions/affines/placePointsFromAffine.d.ts +8 -0
  59. package/lib/exercises/math/functions/affines/placePointsFromAffine.d.ts.map +1 -0
  60. package/lib/exercises/math/functions/affines/placePointsFromAffine.js +135 -0
  61. package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.d.ts +10 -0
  62. package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.d.ts.map +1 -0
  63. package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.js +208 -0
  64. package/lib/exercises/math/functions/basics/index.d.ts +1 -0
  65. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  66. package/lib/exercises/math/functions/basics/index.js +1 -0
  67. package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts +8 -0
  68. package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts.map +1 -0
  69. package/lib/exercises/math/functions/basics/placePointsFromValueTable.js +128 -0
  70. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
  71. package/lib/exercises/math/geometry/areas/rightTriangleArea.js +41 -0
  72. package/lib/exercises/math/geometry/pythagore/isTriangleRight.d.ts.map +1 -1
  73. package/lib/exercises/math/geometry/pythagore/isTriangleRight.js +19 -9
  74. package/lib/exercises/math/powers/powersOfTenMixOperations.js +1 -1
  75. package/lib/exercises/utils/data/boxXY.d.ts +7 -0
  76. package/lib/exercises/utils/data/boxXY.d.ts.map +1 -0
  77. package/lib/exercises/utils/data/boxXY.js +16 -0
  78. package/lib/exercises/utils/data/isBoxable.d.ts +2 -0
  79. package/lib/exercises/utils/data/isBoxable.d.ts.map +1 -0
  80. package/lib/exercises/utils/data/isBoxable.js +5 -0
  81. package/lib/exercises/utils/data/randomDataTable.d.ts +11 -0
  82. package/lib/exercises/utils/data/randomDataTable.d.ts.map +1 -0
  83. package/lib/exercises/utils/data/randomDataTable.js +65 -0
  84. package/lib/index.d.ts +43 -1
  85. package/lib/index.d.ts.map +1 -1
  86. package/lib/math/utils/random/randfloat.d.ts +1 -0
  87. package/lib/math/utils/random/randfloat.d.ts.map +1 -1
  88. package/lib/math/utils/random/randfloat.js +35 -0
  89. package/lib/utils/arrays/transpose.d.ts +2 -0
  90. package/lib/utils/arrays/transpose.d.ts.map +1 -0
  91. package/lib/utils/arrays/transpose.js +10 -0
  92. package/lib/utils/strings/randomFirstname.d.ts +5 -0
  93. package/lib/utils/strings/randomFirstname.d.ts.map +1 -0
  94. package/lib/utils/strings/randomFirstname.js +41 -0
  95. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"euclideanDivision.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/euclideanDivision.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAkFF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAYnD,CAAC"}
1
+ {"version":3,"file":"euclideanDivision.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/euclideanDivision.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA4HF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAanD,CAAC"}
@@ -2,9 +2,9 @@ import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../..
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../../math/utils/random/randint.js";
4
4
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
5
- import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
6
- import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
7
- import { MultiplyNode } from "../../../../tree/nodes/operators/multiplyNode.js";
5
+ import { add, AddNode } from "../../../../tree/nodes/operators/addNode.js";
6
+ import { equal, EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
7
+ import { multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
8
8
  const getInstruction = (identifiers) => {
9
9
  const { dividend, divisor } = identifiers;
10
10
  return `Écrire la division euclidienne de $${dividend}$ par $${divisor}$.`;
@@ -15,6 +15,34 @@ const getAnswer = (identifiers) => {
15
15
  const answerTex = answer.toTex();
16
16
  return answerTex;
17
17
  };
18
+ const getHint = (identifiers) => {
19
+ const { dividend, divisor } = identifiers;
20
+ return `La division euclidienne de $${dividend}$ par $${divisor}$ est de la forme :
21
+
22
+ $$
23
+ ${dividend} = ${divisor} \\times q + r
24
+ $$
25
+
26
+ où $q$ (le quotient) et $r$ (le reste) sont deux entier naturels, avec $r<${divisor}$.`;
27
+ };
28
+ const getCorrection = (identifiers) => {
29
+ const { dividend, divisor, quotient, remainder } = identifiers;
30
+ // const steps = divisionStepsManual(identifiers.dividend, identifiers.divisor);
31
+ return `On a :
32
+
33
+ $$
34
+ ${divisor}\\times ${quotient} = ${divisor * quotient}
35
+ $$
36
+
37
+ On en déduit donc que :
38
+
39
+ $$
40
+ ${getAnswer(identifiers)}
41
+ $$
42
+
43
+ Cette écriture est bien la division euclidienne de $${dividend}$ par $${divisor}$, car le reste $${remainder}$ est bien inférieur à $${divisor}$.
44
+ `;
45
+ };
18
46
  const getEuclideanDivisionQuestions = () => {
19
47
  let dividend = randint(5, 100);
20
48
  let divisor = randint(2, 11);
@@ -34,6 +62,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
34
62
  keys: ["equal"],
35
63
  answerFormat: "tex",
36
64
  identifiers,
65
+ hint: getHint(identifiers),
66
+ correction: getCorrection(identifiers),
37
67
  };
38
68
  return question;
39
69
  };
@@ -42,14 +72,15 @@ const isAnswerValid = (ans, { dividend, divisor, quotient, remainder }) => {
42
72
  const validLatexs = tree.toAllValidTexs();
43
73
  return validLatexs.includes(ans);
44
74
  };
45
- const getPropositions = (n, { answer, dividend }) => {
75
+ const getPropositions = (n, { answer, dividend, divisor, quotient, remainder }) => {
46
76
  const propositions = [];
47
77
  addValidProp(propositions, answer);
78
+ tryToAddWrongProp(propositions, equal(dividend, add(multiply(divisor, quotient - 1), remainder + dividend)).toTex());
48
79
  propWhile(propositions, n, () => {
49
- const divisor = randint(2, 11);
50
- const quotient = Math.floor(randint(5, 100) / divisor);
51
- const remainder = randint(5, 100) % divisor;
52
- const wrongAnswer = new EqualNode(new NumberNode(dividend), new AddNode(new MultiplyNode(new NumberNode(divisor), new NumberNode(quotient)), new NumberNode(remainder)));
80
+ const fakeDivisor = randint(2, 11);
81
+ const fakeQuotient = Math.floor(randint(5, 100) / fakeDivisor);
82
+ const fakeRemainder = randint(5, 100) % fakeDivisor;
83
+ const wrongAnswer = new EqualNode(new NumberNode(dividend), new AddNode(new MultiplyNode(new NumberNode(fakeDivisor), new NumberNode(fakeQuotient)), new NumberNode(fakeRemainder)));
53
84
  tryToAddWrongProp(propositions, wrongAnswer.toTex());
54
85
  });
55
86
  return shuffleProps(propositions, n);
@@ -66,4 +97,30 @@ export const euclideanDivision = {
66
97
  isAnswerValid,
67
98
  subject: "Mathématiques",
68
99
  getQuestionFromIdentifiers,
100
+ hasHintAndCorrection: true,
69
101
  };
102
+ function _divisionStepsManual(dividend, divisor) {
103
+ if (divisor === 0) {
104
+ throw new Error("Division par zéro impossible.");
105
+ }
106
+ const steps = [];
107
+ let remainder = dividend;
108
+ const quotient = Math.floor(dividend / divisor);
109
+ const quotientStr = quotient.toString();
110
+ for (let i = 0; i < quotientStr.length; i++) {
111
+ // On forme la "partie" du quotient qu'on utilise (ex : 10, puis 3)
112
+ const factor = parseInt(quotientStr[i], 10) * Math.pow(10, quotientStr.length - 1 - i);
113
+ if (factor === 0)
114
+ continue;
115
+ const product = factor * divisor;
116
+ const before = remainder;
117
+ remainder -= product;
118
+ steps.push({
119
+ quotientPart: factor,
120
+ product,
121
+ remainderBefore: before,
122
+ remainderAfter: remainder,
123
+ });
124
+ }
125
+ return steps;
126
+ }
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ situation: number;
4
+ total: number;
5
+ divisor: number;
6
+ };
7
+ export declare const findLeftoverInContext: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=findLeftoverInContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findLeftoverInContext.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/findLeftoverInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAmHF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
@@ -0,0 +1,111 @@
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 { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
6
+ import { pluralize } from "../../../../utils/strings/pluralize.js";
7
+ import { randomFirstname } from "../../../../utils/strings/randomFirstname.js";
8
+ const getPropositions = (n, { answer, divisor, total }) => {
9
+ const propositions = [];
10
+ addValidProp(propositions, answer);
11
+ tryToAddWrongProp(propositions, Math.floor(total / divisor).frenchify());
12
+ propWhile(propositions, n, () => {
13
+ tryToAddWrongProp(propositions, Math.max(0, (total % divisor) + randint(-3, 3, [0])).frenchify());
14
+ });
15
+ return shuffleProps(propositions, n);
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ return (identifiers.total % identifiers.divisor).frenchify();
19
+ };
20
+ const getInstruction = (identifiers) => {
21
+ const { divisor, situation, total } = identifiers;
22
+ switch (situation) {
23
+ case 0:
24
+ return `J'ai $${total}$ bonbons. Si je les range dans des sachets de $${divisor}$ bonbons, combien de bonbons ne seront pas dans un sachet ?`;
25
+ case 1:
26
+ return `Une bibliothèque possède $${total}$ livres à stocker dans des boîtes. Chaque boîte doit contenir $${divisor}$ livres. Combien de livres resteront hors des boîtes ?`;
27
+ case 2: {
28
+ const pre = randomFirstname();
29
+ return `${pre.name} possède $${total}$ billes. ${pre.isFeminine ? "Elle" : "Il"} veux remplir des tubes de $${divisor}$ billes chacun. Combien de billes ne seront pas dans un tube ?`;
30
+ }
31
+ case 3:
32
+ return `Un magasin reçoit $${total}$ cartes promotionnelles. Il veut les regrouper en paquets de $${divisor}$ cartes. Combien de cartes ne seront pas dans un paquet ?`;
33
+ case 4:
34
+ default:
35
+ return `J'ai récolté $${total}$ pommes. Je veux les ranger dans des paniers de $${divisor}$ pommes chacun. Combien de pommes ne seront pas dans un panier ?`;
36
+ }
37
+ };
38
+ const getHint = (identifiers) => {
39
+ return `Écris la division euclidienne de $${identifiers.total}$ par $${identifiers.divisor}$.`;
40
+ };
41
+ const getCorrection = (identifiers) => {
42
+ const { total, divisor, situation } = identifiers;
43
+ const answer = getAnswer(identifiers);
44
+ const objectType = ["bonbon", "livre", "bille", "carte", "pomme"][situation];
45
+ const contentType = ["sachet", "boîte", "tube", "paquet", "panier"][situation];
46
+ const quotient = Math.floor(total / divisor);
47
+ const leftover = total % divisor;
48
+ return `On écrit la division euclidienne de $${identifiers.total}$ par $${identifiers.divisor}$ :
49
+
50
+ $$
51
+ ${total} = ${divisor} \\times ${quotient} + ${leftover}
52
+ $$
53
+
54
+ Le reste est $${answer}$.
55
+
56
+ On peut donc faire $${quotient}$ ${pluralize(contentType, quotient)} de $${divisor}$ ${pluralize(objectType, divisor)}, et il va rester $${answer}$ ${pluralize(objectType, total % divisor)}.`;
57
+ };
58
+ const getKeys = () => {
59
+ return [];
60
+ };
61
+ const isAnswerValid = (ans, { answer }) => {
62
+ try {
63
+ return numberVEA(ans, answer);
64
+ }
65
+ catch (err) {
66
+ return handleVEAError(err);
67
+ }
68
+ };
69
+ const getFindLeftoverInContextQuestion = () => {
70
+ let total = 0;
71
+ let divisor = 0;
72
+ do {
73
+ total = randint(30, 100);
74
+ divisor = randint(3, 20);
75
+ } while (total % divisor === 0);
76
+ const identifiers = {
77
+ situation: randint(0, 5),
78
+ divisor,
79
+ total,
80
+ };
81
+ return getQuestionFromIdentifiers(identifiers);
82
+ };
83
+ const getQuestionFromIdentifiers = (identifiers) => {
84
+ return {
85
+ answer: getAnswer(identifiers),
86
+ instruction: getInstruction(identifiers),
87
+ keys: getKeys(identifiers),
88
+ answerFormat: "tex",
89
+ identifiers,
90
+ hint: getHint(identifiers),
91
+ correction: getCorrection(identifiers),
92
+ };
93
+ };
94
+ export const findLeftoverInContext = {
95
+ id: "findLeftoverInContext",
96
+ connector: "=",
97
+ label: "Déterminer le reste d'une division euclidienne dans un contexte",
98
+ isSingleStep: true,
99
+ generator: (nb, opts) => getDistinctQuestions(() => getFindLeftoverInContextQuestion(opts), nb),
100
+ qcmTimer: 60,
101
+ freeTimer: 60,
102
+ getPropositions,
103
+ isAnswerValid,
104
+ subject: "Mathématiques",
105
+ getInstruction,
106
+ getHint,
107
+ getCorrection,
108
+ getAnswer,
109
+ getQuestionFromIdentifiers,
110
+ hasHintAndCorrection: true,
111
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"findRightPrimeDecomposition.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAkIF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBtE,CAAC"}
1
+ {"version":3,"file":"findRightPrimeDecomposition.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAiIF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBtE,CAAC"}
@@ -1,6 +1,4 @@
1
- import { addValidProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType,
2
- // tryToAddWrongProp,
3
- addWrongProp, } from "../../../../exercises/exercise.js";
1
+ import { addValidProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
4
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
5
3
  import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
6
4
  import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
@@ -27,7 +25,7 @@ const getPropositions = (n, { answer, fakeDecomps }) => {
27
25
  const propositions = [];
28
26
  addValidProp(propositions, answer);
29
27
  for (const decomp of fakeDecomps) {
30
- addWrongProp(propositions, reifyAlgebraic(decomp).toTex({ forceNoSimplification: true }));
28
+ tryToAddWrongProp(propositions, reifyAlgebraic(decomp).toTex({ forceNoSimplification: true }));
31
29
  }
32
30
  return shuffleProps(propositions, n);
33
31
  };
@@ -50,7 +48,7 @@ n = p_1^{k_1} \\times p_2^{k_2} \\times ...
50
48
  $$`}
51
49
 
52
50
  où $p_1$, $p_2$, ... sont des nombres premiers${opts?.doNotUsePowers
53
- ? " ."
51
+ ? "."
54
52
  : " et $k_1$, $k_2$, ... sont des entiers naturels."}
55
53
 
56
54
  Parmi les écritures proposées, il faut donc repérer celle dans laquelle chaque facteur est un nombre premier.`;
@@ -75,7 +73,6 @@ const getFindRightPrimeDecompositionQuestion = (opts) => {
75
73
  // );
76
74
  const fakeDecomps = [];
77
75
  const nonPrimes = [];
78
- console.log(nb);
79
76
  for (let i = 0; i < 3; i++) {
80
77
  const nonPrime = doWhile(() => random(divisors.slice(1).filter((n) => !isPrime(n))), (n) => nonPrimes.includes(n));
81
78
  nonPrimes.push(nonPrime);
@@ -13,4 +13,8 @@ export * from "./isMultipleOrDivisor.js";
13
13
  export * from "./coprime.js";
14
14
  export * from "./countDivisors.js";
15
15
  export * from "./findPrimeInList.js";
16
+ export * from "./findRightPrimeDecomposition.js";
17
+ export * from "./primeNumberIdentification.js";
18
+ export * from "./primeNumbersAffirmations.js";
19
+ export * from "./findLeftoverInContext.js";
16
20
  //# 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,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,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,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC"}
@@ -13,4 +13,7 @@ export * from "./isMultipleOrDivisor.js";
13
13
  export * from "./coprime.js";
14
14
  export * from "./countDivisors.js";
15
15
  export * from "./findPrimeInList.js";
16
- // export * from "./findRightPrimeDecomposition.js";
16
+ export * from "./findRightPrimeDecomposition.js";
17
+ export * from "./primeNumberIdentification.js";
18
+ export * from "./primeNumbersAffirmations.js";
19
+ export * from "./findLeftoverInContext.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ rightAffirmationsIndexes: number[];
4
+ wrongAffirmationsIndexes: number[];
5
+ };
6
+ export declare const primeNumbersAffirmations: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=primeNumbersAffirmations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primeNumbersAffirmations.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/primeNumbersAffirmations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAiDrC,KAAK,WAAW,GAAG;IACjB,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;CACpC,CAAC;AAqFF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAkB1D,CAAC"}
@@ -0,0 +1,128 @@
1
+ import { addValidProp, shuffleProps, addWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { randTupleInt } from "../../../../math/utils/random/randTupleInt.js";
5
+ const rightAffirmations = [
6
+ "Tout entier naturel est diviseur de lui-même.",
7
+ "Il y a une infinité de nombres premiers.",
8
+ "Tout nombre entier admet au moins deux diviseurs.",
9
+ "$1$ est diviseur de tous les nombres entiers.",
10
+ "$2$ est le seul nombre premier pair.",
11
+ "Un nombre premier n'a que deux diviseurs : $1$ et lui-même.",
12
+ ];
13
+ const rightAffirmationsCorrections = [
14
+ `C'est vrai, car pour tout entier naturel $n$, on a :
15
+
16
+ $$
17
+ n = n\\times 1
18
+ $$`,
19
+ "C'est vrai, c'est une propriété du cours.",
20
+ `C'est vrai, car pour tout entier naturel $n$, on a :
21
+
22
+ $$
23
+ n = n\\times 1
24
+ $$
25
+
26
+ donc tout entier naturel est divisible par $1$ et par lui-même.`,
27
+ `C'est vrai, car pour tout entier naturel $n$, on a :
28
+
29
+ $$
30
+ n = 1\\times n
31
+ $$`,
32
+ `C'est vrai, car $2$ est divisible uniquement par $1$ et par lui-même, et tous les nombres pairs sont divisibles par $2$, donc ils au moins trois diviseurs.`,
33
+ "C'est vrai, c'est la définition d'un nombre premier.",
34
+ ];
35
+ const wrongAffirmations = [
36
+ "Tout nombre impair est premier.",
37
+ "$0$ est diviseur de tous les nombres entiers.",
38
+ "$1$ est un nombre premier.",
39
+ "Tout nombre premier est impair.",
40
+ "Il n'existe pas de nombre premier qui soit pair.",
41
+ ];
42
+ const wrongAffirmationsCorrections = [
43
+ "C'est faux, par exemple $9$ est divisible par $1$, par $3$ et par lui-même, donc il n'a pas uniquement deux diviseurs.",
44
+ "C'est faux, $0$ est un diviseur de lui-même, mais d'aucun autre entier naturel.",
45
+ "C'est faux, car $1$ n'a qu'un seul diviseur, lui-même.",
46
+ "C'est faux, car $2$ est un nombre premier pair.",
47
+ "C'est faux, $2$ est un nombre premier pair.",
48
+ ];
49
+ const getPropositions = (n, { rightAffirmationsIndexes, wrongAffirmationsIndexes }) => {
50
+ const propositions = [];
51
+ for (const i of rightAffirmationsIndexes) {
52
+ addValidProp(propositions, rightAffirmations[i], "raw");
53
+ }
54
+ for (const i of wrongAffirmationsIndexes) {
55
+ addWrongProp(propositions, wrongAffirmations[i], "raw");
56
+ }
57
+ return shuffleProps(propositions, n);
58
+ };
59
+ const getInstruction = () => {
60
+ return `Parmi les affirmations suivantes, laquelle ou lesquelles sont vraies ?`;
61
+ };
62
+ const getHint = () => {
63
+ return `Un nombre $k$ est un diviseur d'un nombre $n$ si on peut l'écrire sous la forme $n = k \\times m$, où $m$ est un entier naturel.`;
64
+ };
65
+ const getCorrection = (identifiers) => {
66
+ const { rightAffirmationsIndexes, wrongAffirmationsIndexes } = identifiers;
67
+ return `Voici le(s) affirmation(s) correcte(s) :
68
+
69
+ ${rightAffirmationsIndexes
70
+ .map((i) => `- ${rightAffirmations[i]}\n \n ${rightAffirmationsCorrections[i]}\n \n `)
71
+ .join("")}
72
+
73
+ \n \n \n
74
+ ${wrongAffirmationsIndexes.length === 0
75
+ ? ""
76
+ : `Le(s) affirmation(s) incorrecte(s) sont donc les suivantes :
77
+
78
+ ${wrongAffirmationsIndexes
79
+ .map((i) => `- ${wrongAffirmations[i]}\n \n ${wrongAffirmationsCorrections[i]}\n \n `)
80
+ .join("")}`}`;
81
+ };
82
+ const getPrimeNumbersAffirmationsQuestion = () => {
83
+ const rightAnswersCount = randint(1, 5);
84
+ const wrongAnswersCount = 4 - rightAnswersCount;
85
+ const rightIndexes = randTupleInt(rightAnswersCount, {
86
+ from: 0,
87
+ to: rightAffirmations.length,
88
+ allDifferent: true,
89
+ });
90
+ const wrongIndexes = wrongAnswersCount > 0
91
+ ? randTupleInt(wrongAnswersCount, {
92
+ from: 0,
93
+ to: wrongAffirmations.length,
94
+ allDifferent: true,
95
+ })
96
+ : [];
97
+ const identifiers = {
98
+ rightAffirmationsIndexes: rightIndexes,
99
+ wrongAffirmationsIndexes: wrongIndexes,
100
+ };
101
+ return getQuestionFromIdentifiers(identifiers);
102
+ };
103
+ const getQuestionFromIdentifiers = (identifiers) => {
104
+ return {
105
+ instruction: getInstruction(identifiers),
106
+ answerFormat: "tex",
107
+ identifiers,
108
+ hint: getHint(identifiers),
109
+ correction: getCorrection(identifiers),
110
+ };
111
+ };
112
+ export const primeNumbersAffirmations = {
113
+ id: "primeNumbersAffirmations",
114
+ label: "Sélectionner les affirmations correctes concernant les nombres premiers",
115
+ isSingleStep: true,
116
+ generator: (nb, opts) => getDistinctQuestions(() => getPrimeNumbersAffirmationsQuestion(opts), nb),
117
+ qcmTimer: 60,
118
+ freeTimer: 60,
119
+ getPropositions,
120
+ subject: "Mathématiques",
121
+ getInstruction,
122
+ getHint,
123
+ getCorrection,
124
+ getQuestionFromIdentifiers,
125
+ hasHintAndCorrection: true,
126
+ answerType: "QCM",
127
+ isQCM: true,
128
+ };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ num1: number;
4
+ num2: number;
5
+ denum1: number;
6
+ denum2: number;
7
+ };
8
+ export declare const fractionEquality: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=fractionEquality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fractionEquality.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/fractionEquality.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAqHF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAiBlD,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp,
2
+ // GeneratorOption,
3
+ // GeneratorOptionTarget,
4
+ // GeneratorOptionType,
5
+ } from "../../../../exercises/exercise.js";
6
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
7
+ import { randint } from "../../../../math/utils/random/randint.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
10
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
11
+ const getPropositions = (n, { answer, ...identifiers }) => {
12
+ const propositions = [];
13
+ const { denum1, denum2, num1, num2 } = identifiers;
14
+ addValidProp(propositions, num1 * denum2 === num2 * denum1 ? "Oui" : "Non", "raw");
15
+ tryToAddWrongProp(propositions, "Oui", "raw");
16
+ tryToAddWrongProp(propositions, "Non", "raw");
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { denum1, denum2, num1, num2 } = identifiers;
21
+ return num1 * denum2 === num2 * denum1 ? "Oui" : "Non";
22
+ };
23
+ const getInstruction = (identifiers) => {
24
+ const { denum1, denum2, num1, num2 } = identifiers;
25
+ return `L'égalité suivante est-elle vraie ?
26
+
27
+ $$
28
+ ${frac(num1, denum1).toTex()} = ${frac(num2, denum2).toTex()}
29
+ $$`;
30
+ };
31
+ const getHint = () => {
32
+ return `Deux fractions $\\frac{a}{b}$ et $\\frac{c}{d}$ sont égales si et seulement si :
33
+
34
+ $$
35
+ a\\times d = b\\times c
36
+ $$`;
37
+ };
38
+ const getCorrection = (identifiers) => {
39
+ const { denum1, denum2, num1, num2 } = identifiers;
40
+ const equal = num1 * denum2 === num2 * denum1;
41
+ return `Deux fractions $\\frac{a}{b}$ et $\\frac{c}{d}$ sont égales si et seulement si :
42
+
43
+ $$
44
+ a\\times d = b\\times c
45
+ $$
46
+
47
+ Ici, on a :
48
+
49
+ - $${multiply(num1, denum2).toSimplificationTex()}$
50
+
51
+ - $${multiply(num2, denum1).toSimplificationTex()}$
52
+
53
+ ${equal
54
+ ? `Les deux fractions sont donc bien égales.`
55
+ : `Les deux fractions ne sont donc pas égales.`}
56
+ `;
57
+ };
58
+ const getFractionEqualityQuestion = () => {
59
+ const isEqual = coinFlip();
60
+ let num1 = randint(2, 11);
61
+ let denum1 = randint(2, 11, [num1]);
62
+ let num2;
63
+ let denum2;
64
+ const ratio = randint(2, 7);
65
+ if (isEqual) {
66
+ num2 = num1 * ratio;
67
+ denum2 = denum1 * ratio;
68
+ }
69
+ else {
70
+ num2 = num1 * ratio + randint(-1, 2, [0]);
71
+ denum2 = denum1 * ratio + randint(-1, 2, [0]);
72
+ }
73
+ if (coinFlip())
74
+ [num1, denum1, num2, denum2] = [num2, denum2, num1, denum1];
75
+ const identifiers = {
76
+ num1,
77
+ num2,
78
+ denum1,
79
+ denum2,
80
+ };
81
+ return getQuestionFromIdentifiers(identifiers);
82
+ };
83
+ const getQuestionFromIdentifiers = (identifiers) => {
84
+ return {
85
+ answer: getAnswer(identifiers),
86
+ instruction: getInstruction(identifiers),
87
+ keys: [],
88
+ answerFormat: "raw",
89
+ identifiers,
90
+ hint: getHint(identifiers),
91
+ correction: getCorrection(identifiers),
92
+ };
93
+ };
94
+ // type Options = {
95
+ // numberType: string[];
96
+ // };
97
+ // const options: GeneratorOption[] = [
98
+ // {
99
+ // id: "numberType",
100
+ // label: "Type de nombres",
101
+ // target: GeneratorOptionTarget.generation,
102
+ // type: GeneratorOptionType.multiselect,
103
+ // defaultValue: ["Entier", "Décimal"],
104
+ // values: ["Entier", "Décimal"],
105
+ // },
106
+ // ];
107
+ export const fractionEquality = {
108
+ id: "fractionEquality",
109
+ label: "Vérifier une égalité du type $\\frac{a}{b} = \\frac{c}{d}$",
110
+ isSingleStep: true,
111
+ generator: (nb, opts) => getDistinctQuestions(() => getFractionEqualityQuestion(opts), nb),
112
+ qcmTimer: 60,
113
+ freeTimer: 60,
114
+ getPropositions,
115
+ subject: "Mathématiques",
116
+ getInstruction,
117
+ getHint,
118
+ getCorrection,
119
+ getAnswer,
120
+ getQuestionFromIdentifiers,
121
+ hasHintAndCorrection: true,
122
+ answerType: "QCU",
123
+ };
@@ -18,4 +18,5 @@ export * from "./fractionForbiddenValue.js";
18
18
  export * from "./simplifyToFraction.js";
19
19
  export * from "./evalFractionExpression.js";
20
20
  export * from "./fractionsMix.js";
21
+ export * from "./fractionEquality.js";
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
@@ -18,3 +18,4 @@ export * from "./fractionForbiddenValue.js";
18
18
  export * from "./simplifyToFraction.js";
19
19
  export * from "./evalFractionExpression.js";
20
20
  export * from "./fractionsMix.js";
21
+ export * from "./fractionEquality.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ situationIndex: number;
4
+ values: number[][];
5
+ };
6
+ export declare const fourthProportionalFromProblem: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=fourthProportionalFromProblem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fourthProportionalFromProblem.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/fourthProportionalFromProblem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAyBrC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;CACpB,CAAC;AA6cF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAoB/D,CAAC"}