math-exercises 3.0.141 → 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 (43) hide show
  1. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.d.ts +9 -0
  2. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.d.ts.map +1 -0
  3. package/lib/exercises/math/calcul/arithmetics/findLeftoverInContext.js +111 -0
  4. package/lib/exercises/math/calcul/arithmetics/index.d.ts +1 -0
  5. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/arithmetics/index.js +1 -0
  7. package/lib/exercises/math/calcul/fractions/fractionEquality.d.ts +10 -0
  8. package/lib/exercises/math/calcul/fractions/fractionEquality.d.ts.map +1 -0
  9. package/lib/exercises/math/calcul/fractions/fractionEquality.js +123 -0
  10. package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
  11. package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
  12. package/lib/exercises/math/calcul/fractions/index.js +1 -0
  13. package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.js +3 -3
  14. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.js +10 -1
  16. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts +4 -1
  17. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/equation/equationSimpleSquare.js +32 -9
  19. package/lib/exercises/math/calculLitteral/equation/index.d.ts +2 -0
  20. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  21. package/lib/exercises/math/calculLitteral/equation/index.js +2 -0
  22. package/lib/exercises/math/calculLitteral/equation/proportionEquation.d.ts +11 -0
  23. package/lib/exercises/math/calculLitteral/equation/proportionEquation.d.ts.map +1 -0
  24. package/lib/exercises/math/calculLitteral/equation/proportionEquation.js +152 -0
  25. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts +12 -0
  26. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts.map +1 -0
  27. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.js +197 -0
  28. package/lib/exercises/math/calculLitteral/factorisation/factoType2.d.ts.map +1 -1
  29. package/lib/exercises/math/calculLitteral/factorisation/factoType2.js +30 -4
  30. package/lib/exercises/math/calculLitteral/factorisation/factoType3.d.ts.map +1 -1
  31. package/lib/exercises/math/calculLitteral/factorisation/factoType3.js +30 -4
  32. package/lib/exercises/math/calculLitteral/factorisation/factoType4.d.ts.map +1 -1
  33. package/lib/exercises/math/calculLitteral/factorisation/factoType4.js +30 -5
  34. package/lib/exercises/math/calculLitteral/ordering/compareAMinusB.js +1 -1
  35. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
  36. package/lib/exercises/math/geometry/areas/rightTriangleArea.js +41 -0
  37. package/lib/exercises/math/powers/powersOfTenMixOperations.js +1 -1
  38. package/lib/index.d.ts +22 -1
  39. package/lib/index.d.ts.map +1 -1
  40. package/lib/utils/strings/randomFirstname.d.ts +5 -0
  41. package/lib/utils/strings/randomFirstname.d.ts.map +1 -0
  42. package/lib/utils/strings/randomFirstname.js +41 -0
  43. package/package.json +1 -1
@@ -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
+ };
@@ -16,4 +16,5 @@ export * from "./findPrimeInList.js";
16
16
  export * from "./findRightPrimeDecomposition.js";
17
17
  export * from "./primeNumberIdentification.js";
18
18
  export * from "./primeNumbersAffirmations.js";
19
+ export * from "./findLeftoverInContext.js";
19
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;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,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"}
@@ -16,3 +16,4 @@ export * from "./findPrimeInList.js";
16
16
  export * from "./findRightPrimeDecomposition.js";
17
17
  export * from "./primeNumberIdentification.js";
18
18
  export * from "./primeNumbersAffirmations.js";
19
+ export * from "./findLeftoverInContext.js";
@@ -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";
@@ -286,10 +286,10 @@ const getPropositions = (_, { answer, ...identifiers }) => {
286
286
  const answerFromIdentifiers = getAnswer(identifiers);
287
287
  ["Oui", "Non"].forEach((strProp) => {
288
288
  if (strProp === answerFromIdentifiers) {
289
- addValidProp(propositions, strProp);
289
+ addValidProp(propositions, strProp, "raw");
290
290
  }
291
291
  else {
292
- tryToAddWrongProp(propositions, strProp);
292
+ tryToAddWrongProp(propositions, strProp, "raw");
293
293
  }
294
294
  });
295
295
  return propositions;
@@ -324,7 +324,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
324
324
  answer: getAnswer(identifiers),
325
325
  instruction: getInstruction(identifiers),
326
326
  keys: [],
327
- answerFormat: "tex",
327
+ answerFormat: "raw",
328
328
  identifiers,
329
329
  hint: getHint(identifiers),
330
330
  correction: getCorrection(identifiers),
@@ -1 +1 @@
1
- {"version":3,"file":"rectangleSideAfterReduction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/rectangleSideAfterReduction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CAGnB,CAAC;AAqPF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAoB7D,CAAC"}
1
+ {"version":3,"file":"rectangleSideAfterReduction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/rectangleSideAfterReduction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CAGnB,CAAC;AA4PF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAoB7D,CAAC"}
@@ -1,4 +1,7 @@
1
- import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile, } from "../../../../exercises/exercise.js";
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, propWhile,
2
+ // GetHint,
3
+ // GetCorrection,
4
+ } from "../../../../exercises/exercise.js";
2
5
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
6
  import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
7
  import { randfloat } from "../../../../math/utils/random/randfloat.js";
@@ -135,6 +138,12 @@ const isAnswerValid = (ans, { answer }) => {
135
138
  return handleVEAError(err);
136
139
  }
137
140
  };
141
+ // const getHint: GetHint<Identifiers> = (identifiers) => {
142
+ // return ``;
143
+ // };
144
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
145
+ // return ``;
146
+ // };
138
147
  const getRectangleSideAfterReductionQuestion = () => {
139
148
  const askedSize = randint(0, 4);
140
149
  let a;
@@ -2,6 +2,9 @@ import { Exercise } from "../../../../exercises/exercise.js";
2
2
  type Identifiers = {
3
3
  randNbr: number;
4
4
  };
5
- export declare const equationSimpleSquare: Exercise<Identifiers>;
5
+ type Options = {
6
+ solutionType: string[];
7
+ };
8
+ export declare const equationSimpleSquare: Exercise<Identifiers, Options>;
6
9
  export {};
7
10
  //# sourceMappingURL=equationSimpleSquare.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"equationSimpleSquare.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationSimpleSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAwBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAoKF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAatD,CAAC"}
1
+ {"version":3,"file":"equationSimpleSquare.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/equationSimpleSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAwBrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAgLF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAqBF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgB/D,CAAC"}
@@ -1,4 +1,4 @@
1
- import { addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
1
+ import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, propWhile, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Rational } from "../../../../math/numbers/rationals/rational.js";
4
4
  import { SquareRoot } from "../../../../math/numbers/reals/real.js";
@@ -8,11 +8,11 @@ import { OppositeNode } from "../../../../tree/nodes/functions/oppositeNode.js";
8
8
  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
- import { diceFlip } from "../../../../utils/alea/diceFlip.js";
12
11
  import { isInt } from "../../../../utils/isInt.js";
13
12
  import { random } from "../../../../utils/alea/random.js";
14
13
  import { discreteSetParser } from "../../../../tree/parsers/discreteSetParser.js";
15
14
  import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
15
+ import { doWhile } from "../../../../utils/doWhile.js";
16
16
  const squares = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((el) => el ** 2);
17
17
  const higherFactor = (n) => {
18
18
  for (let i = Math.floor(Math.sqrt(n)); i > 0; i--)
@@ -73,15 +73,18 @@ Ainsi, $${answer}$.
73
73
  `}
74
74
  `;
75
75
  };
76
- const getEquationSimpleSquare = () => {
76
+ const getEquationSimpleSquare = (opts) => {
77
77
  let randNbr;
78
- const rand = diceFlip(10);
79
- if (rand === 1)
78
+ const type = random(opts?.solutionType ?? ["Entiers", "Racines carrées", "Ensemble vide"]);
79
+ if (type === "Ensemble vide") {
80
80
  randNbr = randint(-20, 0);
81
- else if (rand < 6)
81
+ }
82
+ else if (type === "Racines carrées") {
83
+ randNbr = doWhile(() => randint(2, 100), (x) => Math.sqrt(x) === Math.floor(Math.sqrt(x)));
84
+ }
85
+ else {
82
86
  randNbr = random(squares);
83
- else
84
- randNbr = randint(2, 100);
87
+ }
85
88
  const identifiers = { randNbr };
86
89
  return getQuestionFromIdentifiers(identifiers);
87
90
  };
@@ -144,12 +147,30 @@ const isAnswerValid = (ans, { answer }) => {
144
147
  return handleVEAError(err);
145
148
  }
146
149
  };
150
+ const options = [
151
+ {
152
+ id: "solutionType",
153
+ label: "Type de solutions",
154
+ target: GeneratorOptionTarget.generation,
155
+ type: GeneratorOptionType.multiselect,
156
+ defaultValue: ["Entiers", "Racines carrées", "Ensemble vide"],
157
+ values: ["Entiers", "Racines carrées", "Ensemble vide"],
158
+ },
159
+ ];
160
+ const validateOptions = (opts) => {
161
+ if (opts?.solutionType?.length === 0)
162
+ return {
163
+ valid: false,
164
+ message: "Veuillez choisir au moins un type de solution.",
165
+ };
166
+ return { valid: true, message: "" };
167
+ };
147
168
  export const equationSimpleSquare = {
148
169
  id: "equationSimpleSquare",
149
170
  connector: "=",
150
171
  label: "Résoudre une équation du second degré du type $x^2 = a$",
151
172
  isSingleStep: false,
152
- generator: (nb) => getDistinctQuestions(getEquationSimpleSquare, nb),
173
+ generator: (nb, opts) => getDistinctQuestions(() => getEquationSimpleSquare(opts), nb),
153
174
  qcmTimer: 60,
154
175
  freeTimer: 60,
155
176
  getPropositions,
@@ -157,4 +178,6 @@ export const equationSimpleSquare = {
157
178
  subject: "Mathématiques",
158
179
  hasHintAndCorrection: true,
159
180
  getQuestionFromIdentifiers,
181
+ options,
182
+ validateOptions,
160
183
  };
@@ -16,4 +16,6 @@ export * from "./choseOperationToSolveEquation.js";
16
16
  export * from "./factorizeEquation.js";
17
17
  export * from "./equationFromProblem.js";
18
18
  export * from "./isEqualityTrue.js";
19
+ export * from "./proportionEquation.js";
20
+ export * from "./solveByFactorizingWithIdRmq3.js";
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC"}
@@ -16,3 +16,5 @@ export * from "./choseOperationToSolveEquation.js";
16
16
  export * from "./factorizeEquation.js";
17
17
  export * from "./equationFromProblem.js";
18
18
  export * from "./isEqualityTrue.js";
19
+ export * from "./proportionEquation.js";
20
+ export * from "./solveByFactorizingWithIdRmq3.js";
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ aIds: NodeIdentifiers;
5
+ bIds: NodeIdentifiers;
6
+ cIds: NodeIdentifiers;
7
+ dIds: NodeIdentifiers;
8
+ };
9
+ export declare const proportionEquation: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=proportionEquation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proportionEquation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/proportionEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AA6JF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAmBpD,CAAC"}
@@ -0,0 +1,152 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
4
+ import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
7
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
8
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { isVariableNode, VariableNode, } from "../../../../tree/nodes/variables/variableNode.js";
10
+ import { arrayRotation } from "../../../../utils/arrays/rotation.js";
11
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
12
+ import { alignTex } from "../../../../utils/latex/alignTex.js";
13
+ const getPropositions = (n, { answer, aIds, bIds, cIds, dIds }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ const ids = [aIds, bIds, cIds, dIds];
17
+ for (let i = 0; i < 3; i++) {
18
+ const rotated = arrayRotation(ids, i + 1);
19
+ tryToAddWrongProp(propositions, getAnswerNode({
20
+ aIds: rotated[0],
21
+ bIds: rotated[1],
22
+ cIds: rotated[2],
23
+ dIds: rotated[3],
24
+ }).toTex());
25
+ }
26
+ propWhile(propositions, n, () => {
27
+ tryToAddWrongProp(propositions, RationalConstructor.randomIrreductible().toTree().toTex());
28
+ });
29
+ return shuffleProps(propositions, n);
30
+ };
31
+ const getAnswerNode = (identifiers) => {
32
+ const { aIds, bIds, cIds, dIds } = identifiers;
33
+ const values = [aIds, bIds, cIds, dIds].map((e) => reifyAlgebraic(e));
34
+ //a/b=c/d
35
+ //a=cb/d, b=ad/c, c=ad/b, d=cb/a
36
+ const xIndex = values.findIndex((x) => isVariableNode(x));
37
+ return frac(multiply(values[(xIndex + 2) % 4], values[xIndex % 2 === 0 ? xIndex + 1 : xIndex - 1]), values[3 - xIndex]).simplify();
38
+ };
39
+ const getAnswer = (identifiers) => {
40
+ return getAnswerNode(identifiers).toTex();
41
+ };
42
+ const getInstruction = (identifiers) => {
43
+ const { aIds, bIds, cIds, dIds } = identifiers;
44
+ const [a, b, c, d] = [aIds, bIds, cIds, dIds].map((e) => reifyAlgebraic(e).toTex());
45
+ return `Déterminer la valeur de $x$ solution de l'équation suivante :
46
+
47
+ $$
48
+ \\frac{${a}}{${b}}=\\frac{${c}}{${d}}
49
+ $$`;
50
+ };
51
+ const getHint = () => {
52
+ return `Si deux fractions sont égales :
53
+
54
+ $$
55
+ \\frac{a}{b}=\\frac{c}{d}
56
+ $$
57
+
58
+ alors on a :
59
+
60
+ $$
61
+ a\\times d = b\\times c
62
+ $$`;
63
+ };
64
+ const getCorrection = (identifiers) => {
65
+ const { aIds, bIds, cIds, dIds } = identifiers;
66
+ const values = [aIds, bIds, cIds, dIds].map((e) => reifyAlgebraic(e));
67
+ const xIndex = values.findIndex((x) => isVariableNode(x));
68
+ const answerRaw = frac(multiply(values[(xIndex + 2) % 4], values[xIndex % 2 === 0 ? xIndex + 1 : xIndex - 1]), values[3 - xIndex]);
69
+ return `Puisque :
70
+
71
+ $$
72
+ \\frac{${values[0].toTex()}}{${values[1].toTex()}}=\\frac{${values[2].toTex()}}{${values[3].toTex()}}
73
+ $$
74
+
75
+ alors :
76
+
77
+ $$
78
+ ${multiply(values[0], values[3]).toTex()}= ${multiply(values[1], values[2]).toTex()}
79
+ $$
80
+
81
+ On a donc :
82
+
83
+ ${alignTex([
84
+ ["x", "=", answerRaw.toTex()],
85
+ ["", "=", answerRaw.simplify().toTex()],
86
+ ])}
87
+ `;
88
+ };
89
+ const getKeys = () => {
90
+ return [];
91
+ };
92
+ const isAnswerValid = (ans, { answer }) => {
93
+ try {
94
+ return rationalVEA(ans, answer, {
95
+ allowNonIrreductible: true,
96
+ allowDecimal: true,
97
+ });
98
+ }
99
+ catch (err) {
100
+ return handleVEAError(err);
101
+ }
102
+ };
103
+ const getProportionEquationQuestion = () => {
104
+ const x = new VariableNode("x");
105
+ const values = [];
106
+ const numbers = [];
107
+ const xIndex = randint(0, 4);
108
+ for (let i = 0; i < 4; i++) {
109
+ if (i === xIndex)
110
+ values[i] = x.toIdentifiers();
111
+ else {
112
+ numbers[i] = randint(1, 12, i % 2 !== 0 ? [1, numbers[i - 1]] : []);
113
+ values[i] = numbers[i].toTree().toIdentifiers();
114
+ }
115
+ }
116
+ const identifiers = {
117
+ aIds: values[0],
118
+ bIds: values[1],
119
+ cIds: values[2],
120
+ dIds: values[3],
121
+ };
122
+ return getQuestionFromIdentifiers(identifiers);
123
+ };
124
+ const getQuestionFromIdentifiers = (identifiers) => {
125
+ return {
126
+ answer: getAnswer(identifiers),
127
+ instruction: getInstruction(identifiers),
128
+ keys: getKeys(identifiers),
129
+ answerFormat: "tex",
130
+ identifiers,
131
+ hint: getHint(identifiers),
132
+ correction: getCorrection(identifiers),
133
+ };
134
+ };
135
+ export const proportionEquation = {
136
+ id: "proportionEquation",
137
+ connector: "=",
138
+ label: "Résoudre une équation de proportionnalité du type $\\frac ab = \\frac xc$",
139
+ isSingleStep: true,
140
+ generator: (nb, opts) => getDistinctQuestions(() => getProportionEquationQuestion(opts), nb),
141
+ qcmTimer: 60,
142
+ freeTimer: 60,
143
+ getPropositions,
144
+ isAnswerValid,
145
+ subject: "Mathématiques",
146
+ getInstruction,
147
+ getHint,
148
+ getCorrection,
149
+ getAnswer,
150
+ getQuestionFromIdentifiers,
151
+ hasHintAndCorrection: true,
152
+ };
@@ -0,0 +1,12 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ aIds: NodeIdentifiers;
5
+ bIds: NodeIdentifiers;
6
+ };
7
+ type Options = {
8
+ useSetAsAnswer: boolean;
9
+ };
10
+ export declare const solveByFactorizingWithIdRmq3: Exercise<Identifiers, Options>;
11
+ export {};
12
+ //# sourceMappingURL=solveByFactorizingWithIdRmq3.d.ts.map