math-exercises 1.3.25 → 1.3.27

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 (50) hide show
  1. package/lib/exercises/calcul/fractions/fractionToPercentToDecimal.d.ts +3 -0
  2. package/lib/exercises/calcul/fractions/fractionToPercentToDecimal.d.ts.map +1 -1
  3. package/lib/exercises/calcul/fractions/fractionToPercentToDecimal.js +54 -38
  4. package/lib/exercises/calcul/mentalCaluls.ts/mentalAddAndSub.d.ts +4 -0
  5. package/lib/exercises/calcul/mentalCaluls.ts/mentalAddAndSub.d.ts.map +1 -0
  6. package/lib/exercises/calcul/mentalCaluls.ts/mentalAddAndSub.js +46 -0
  7. package/lib/exercises/calcul/mentalCaluls.ts/mentalDivisions.d.ts +4 -0
  8. package/lib/exercises/calcul/mentalCaluls.ts/mentalDivisions.d.ts.map +1 -0
  9. package/lib/exercises/calcul/mentalCaluls.ts/mentalDivisions.js +64 -0
  10. package/lib/exercises/calcul/mentalCaluls.ts/mentalMultiplications.d.ts +4 -0
  11. package/lib/exercises/calcul/mentalCaluls.ts/mentalMultiplications.d.ts.map +1 -0
  12. package/lib/exercises/calcul/mentalCaluls.ts/mentalMultiplications.js +51 -0
  13. package/lib/exercises/calcul/mentalCaluls.ts/mentalPercentage.d.ts +4 -0
  14. package/lib/exercises/calcul/mentalCaluls.ts/mentalPercentage.d.ts.map +1 -0
  15. package/lib/exercises/calcul/mentalCaluls.ts/mentalPercentage.js +67 -0
  16. package/lib/exercises/derivation/derivative/firstDegreeDerivative.d.ts +4 -0
  17. package/lib/exercises/derivation/derivative/firstDegreeDerivative.d.ts.map +1 -0
  18. package/lib/exercises/derivation/derivative/firstDegreeDerivative.js +29 -0
  19. package/lib/exercises/derivation/derivative/inverseFunctionDerivative.d.ts +4 -0
  20. package/lib/exercises/derivation/derivative/inverseFunctionDerivative.d.ts.map +1 -0
  21. package/lib/exercises/derivation/derivative/inverseFunctionDerivative.js +27 -0
  22. package/lib/exercises/derivation/derivative/powerFunctionDerivative.d.ts +4 -0
  23. package/lib/exercises/derivation/derivative/powerFunctionDerivative.d.ts.map +1 -0
  24. package/lib/exercises/derivation/derivative/powerFunctionDerivative.js +35 -0
  25. package/lib/exercises/derivation/derivative/rootFunctionDerivative.d.ts +4 -0
  26. package/lib/exercises/derivation/derivative/rootFunctionDerivative.d.ts.map +1 -0
  27. package/lib/exercises/derivation/derivative/rootFunctionDerivative.js +40 -0
  28. package/lib/exercises/derivation/derivative/secondDegreeDerivative.d.ts +4 -0
  29. package/lib/exercises/derivation/derivative/secondDegreeDerivative.d.ts.map +1 -0
  30. package/lib/exercises/derivation/derivative/secondDegreeDerivative.js +33 -0
  31. package/lib/exercises/derivation/derivative/usualderivative.d.ts.map +1 -1
  32. package/lib/exercises/derivation/derivative/usualderivative.js +22 -54
  33. package/lib/exercises/exercise.d.ts +2 -0
  34. package/lib/exercises/exercise.d.ts.map +1 -1
  35. package/lib/exercises/exercises.d.ts.map +1 -1
  36. package/lib/exercises/exercises.js +28 -5
  37. package/lib/exercises/geometry/cartesian/derivativeNumberReading.d.ts.map +1 -1
  38. package/lib/exercises/geometry/cartesian/derivativeNumberReading.js +9 -18
  39. package/lib/exercises/geometry/cartesian/leadingCoefficient.d.ts.map +1 -1
  40. package/lib/exercises/geometry/cartesian/leadingCoefficient.js +26 -4
  41. package/lib/exercises/proba/conditionalProbability.js +6 -6
  42. package/lib/exercises/proba/marginalAndConditionalFrequency.d.ts.map +1 -1
  43. package/lib/exercises/proba/marginalAndConditionalFrequency.js +8 -1
  44. package/lib/exercises/proba/probabilityTree.d.ts.map +1 -1
  45. package/lib/exercises/proba/probabilityTree.js +42 -7
  46. package/lib/exercises/utils/getDistinctQuestions.d.ts +1 -0
  47. package/lib/exercises/utils/getDistinctQuestions.d.ts.map +1 -1
  48. package/lib/exercises/utils/getDistinctQuestions.js +15 -2
  49. package/lib/tree/nodes/operators/divideNode.js +1 -1
  50. package/package.json +1 -1
@@ -1 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const fractionToPercentToDecimal: Exercise;
3
+ export declare function getFractionToPercentToDecimal(): Question;
1
4
  //# sourceMappingURL=fractionToPercentToDecimal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fractionToPercentToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/fractions/fractionToPercentToDecimal.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"fractionToPercentToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/fractions/fractionToPercentToDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,eAAO,MAAM,0BAA0B,EAAE,QASxC,CAAC;AAEF,wBAAgB,6BAA6B,IAAI,QAAQ,CAqDxD"}
@@ -1,53 +1,69 @@
1
1
  "use strict";
2
- /*import { Exercise, Question } from "../../../exercises/exercise";
3
- import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions";
4
- import { randint } from "../../../math/utils/random/randint";
5
- import { round } from "../../../math/utils/round";
6
-
7
- export const fractionToPercentToDecimal: Exercise = {
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFractionToPercentToDecimal = exports.fractionToPercentToDecimal = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const randint_1 = require("../../../math/utils/random/randint");
6
+ const round_1 = require("../../../math/utils/round");
7
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
8
+ const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
9
+ const simplify_1 = require("../../../tree/parsers/simplify");
10
+ exports.fractionToPercentToDecimal = {
8
11
  id: 'fractionToPercentToDecimal',
9
12
  connector: '\\iff',
10
13
  instruction: '',
11
- label: 'Résoudre une équation du premier degré du type ax + b = cx',
14
+ label: "Passer d'une écriture d'un nombre à une autre (décimale, fractionnaire, sous forme de pourcentage).",
12
15
  levels: ['2', '1'],
13
- section: 'Pourcentages',
16
+ section: 'Fractions',
14
17
  isSingleStep: false,
15
- generator: (nb: number) => getDistinctQuestions(getFractionToPercentToDecimal, nb),
18
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getFractionToPercentToDecimal, nb),
16
19
  };
17
-
18
- const pgcd = (a: number, b: number): number => {
19
- if (b === 0)
20
- return a;
21
- return pgcd(b, a % b);
22
- }
23
-
24
- export function getFractionToPercentToDecimal(): Question {
25
-
26
- const a = randint(1, 100);
27
- const b = randint(1, 100);
28
- const percent = round(a/b, 4) * 100;
29
- const decimal = round(a/b, 2);
30
- const flip = randint(1,7);
31
-
20
+ function getFractionToPercentToDecimal() {
21
+ const denominator = 2 ** (0, randint_1.randint)(0, 5) * 5 ** (0, randint_1.randint)(0, 5);
22
+ const numerator = (0, randint_1.randint)(1, denominator);
23
+ const fraction = new fractionNode_1.FractionNode(new numberNode_1.NumberNode(numerator), new numberNode_1.NumberNode(denominator));
24
+ const decimal = numerator / denominator;
25
+ const percent = (0, round_1.round)((numerator / denominator) * 100, 2);
26
+ const rand = (0, randint_1.randint)(1, 7);
32
27
  let instruction;
33
- let answer = "";
34
-
35
- switch (flip){
28
+ let answer = '';
29
+ switch (rand) {
36
30
  case 1: {
37
- instruction = `Convertir le nombre suivant $${decimal}$ en pourcentage et en fraction`;
38
- answer = `\\{${percent}\\%\\ ; \\frac{${a/pgcd(a,b)}}{${b/pgcd(a,b)}}\\}`;
31
+ instruction = `Convertir le nombre suivant $${decimal}$ en pourcentage`;
32
+ answer = `${percent}\\%`;
33
+ break;
39
34
  }
40
-
41
35
  case 2: {
42
-
36
+ instruction = `Convertir le nombre suivant $${decimal}$ en fraction`;
37
+ answer = `${(0, simplify_1.simplifyNode)(fraction).toTex()}`;
38
+ break;
39
+ }
40
+ case 3: {
41
+ instruction = `Convertir le nombre suivant $${percent}\\%$ en décimal`;
42
+ answer = `${decimal}`;
43
+ break;
44
+ }
45
+ case 4: {
46
+ instruction = `Convertir le nombre suivant $${percent}\\%$ en fraction`;
47
+ answer = `${(0, simplify_1.simplifyNode)(fraction).toTex()}`;
48
+ break;
49
+ }
50
+ case 5: {
51
+ instruction = `Convertir le nombre suivant $${fraction.toTex()}$ en décimal`;
52
+ answer = `${decimal}`;
53
+ break;
54
+ }
55
+ case 6: {
56
+ instruction = `Convertir le nombre suivant $${fraction.toTex()}$ en pourcentage`;
57
+ answer = `${percent}\\%`;
58
+ break;
43
59
  }
44
60
  }
45
-
46
- const question: Question = {
61
+ const question = {
47
62
  instruction,
48
- startStatement: `s = `,
63
+ //startStatement: `${simplifyNode(fraction).toTex()}`,
49
64
  answer,
50
- };
51
-
52
- return question;
53
- }*/
65
+ keys: ['percent'],
66
+ };
67
+ return question;
68
+ }
69
+ exports.getFractionToPercentToDecimal = getFractionToPercentToDecimal;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const mentalAddAndSub: Exercise;
3
+ export declare function getMentalAddAndSub(): Question;
4
+ //# sourceMappingURL=mentalAddAndSub.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentalAddAndSub.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/mentalCaluls.ts/mentalAddAndSub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,eAAO,MAAM,eAAe,EAAE,QAU7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,QAAQ,CA4B7C"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMentalAddAndSub = exports.mentalAddAndSub = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const randint_1 = require("../../../math/utils/random/randint");
6
+ const round_1 = require("../../../math/utils/round");
7
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
8
+ const addNode_1 = require("../../../tree/nodes/operators/addNode");
9
+ const coinFlip_1 = require("../../../utils/coinFlip");
10
+ exports.mentalAddAndSub = {
11
+ id: 'mentalAddAndSub',
12
+ connector: '=',
13
+ instruction: 'Calculer :',
14
+ label: "Effectuer mentalement des calculs d'additions et de soustractions simples",
15
+ levels: ['6', '5', '4', '3', '2', '1', '0'],
16
+ section: 'Calculs',
17
+ isSingleStep: true,
18
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMentalAddAndSub, nb),
19
+ keys: [],
20
+ };
21
+ function getMentalAddAndSub() {
22
+ let numbers = [];
23
+ const nbrOperations = (0, coinFlip_1.coinFlip)() ? 2 : 3;
24
+ numbers[0] = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(1, 10) : (0, randint_1.randint)(10, 100) / 10;
25
+ numbers[1] = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(-100, 100) / 10 : (0, randint_1.randint)(-1000, 1000) / 100;
26
+ let sum = numbers[0] + numbers[1];
27
+ if (nbrOperations === 3) {
28
+ numbers[2] = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(-100, 100) / 10 : (0, randint_1.randint)(-1000, 1000) / 100;
29
+ sum += numbers[2];
30
+ sum = (0, round_1.round)(sum * 10, 0);
31
+ numbers[2] = (0, round_1.round)(sum / 10 - numbers[0] - numbers[1], 2);
32
+ sum = numbers[0] + numbers[1] + numbers[2];
33
+ }
34
+ const allNumbersNodes = numbers.map((nb) => new numberNode_1.NumberNode(nb));
35
+ let statementTree = new addNode_1.AddNode(allNumbersNodes[0], allNumbersNodes[1]);
36
+ for (let i = 2; i < nbrOperations; i++)
37
+ statementTree = new addNode_1.AddNode(statementTree, allNumbersNodes[i]);
38
+ statementTree.shuffle();
39
+ const question = {
40
+ startStatement: statementTree.toTex(),
41
+ answer: (0, round_1.round)(sum, 2) + '',
42
+ keys: [],
43
+ };
44
+ return question;
45
+ }
46
+ exports.getMentalAddAndSub = getMentalAddAndSub;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const mentalDivisions: Exercise;
3
+ export declare function getMentalDivisions(): Question;
4
+ //# sourceMappingURL=mentalDivisions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentalDivisions.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/mentalCaluls.ts/mentalDivisions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,eAAO,MAAM,eAAe,EAAE,QAU7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,QAAQ,CAuD7C"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMentalDivisions = exports.mentalDivisions = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const randint_1 = require("../../../math/utils/random/randint");
6
+ const round_1 = require("../../../math/utils/round");
7
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
8
+ const divideNode_1 = require("../../../tree/nodes/operators/divideNode");
9
+ const coinFlip_1 = require("../../../utils/coinFlip");
10
+ exports.mentalDivisions = {
11
+ id: 'mentalDivisions',
12
+ connector: '=',
13
+ instruction: 'Calculer :',
14
+ label: 'Effectuer mentalement des calculs de divisions simples',
15
+ levels: ['6', '5', '4', '3', '2', '1', '0'],
16
+ section: 'Calculs',
17
+ isSingleStep: true,
18
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMentalDivisions, nb),
19
+ keys: [],
20
+ };
21
+ function getMentalDivisions() {
22
+ let a = 1, b = 1, c = 1;
23
+ const rand = (0, randint_1.randint)(1, 7);
24
+ switch (rand) {
25
+ case 1: // random / 10 ou random / 100
26
+ a = (0, randint_1.randint)(1, 100);
27
+ b = (0, coinFlip_1.coinFlip)() ? 10 : 100;
28
+ break;
29
+ case 2: // ex : 0.28 / 0.7 ou 0.6 / 0.2
30
+ b = (0, randint_1.randint)(1, 10) / 10;
31
+ a = (0, coinFlip_1.coinFlip)() ? (0, round_1.round)((b * (0, randint_1.randint)(2, 10)) / 10, 2) : (0, round_1.round)(b * (0, randint_1.randint)(2, 10), 1);
32
+ break;
33
+ case 3: // ex : 25 / 50
34
+ b = (0, randint_1.randint)(1, 10) * 10;
35
+ a = (b / 10) * (0, randint_1.randint)(-9, 10, [-1, 0, 1]);
36
+ break;
37
+ case 4: // ex : ex : 55 / 1.1
38
+ b = (0, randint_1.randint)(1, 16) / 10;
39
+ a = b * (0, randint_1.randint)(2, 10) * 10;
40
+ a = (0, round_1.round)(a, 0);
41
+ break;
42
+ case 5: // ex : 5.6 / -7
43
+ b = (0, randint_1.randint)(-9, 10, [-1, 0, 1]);
44
+ a = (0, round_1.round)((Math.abs(b) / 10) * (0, randint_1.randint)(2, 10), 1);
45
+ break;
46
+ case 6: // ex 24 / (12 / 2)
47
+ c = (0, randint_1.randint)(1, 10);
48
+ b = c * (0, randint_1.randint)(2, 10);
49
+ a = (b / c) * (0, randint_1.randint)(2, 10);
50
+ break;
51
+ }
52
+ const allNumbersNodes = rand === 6 ? [a, b, c].map((nb) => new numberNode_1.NumberNode(nb)) : [a, b].map((nb) => new numberNode_1.NumberNode(nb));
53
+ const statementTree = rand === 6
54
+ ? new divideNode_1.DivideNode(allNumbersNodes[0], new divideNode_1.DivideNode(allNumbersNodes[1], allNumbersNodes[2]))
55
+ : new divideNode_1.DivideNode(allNumbersNodes[0], allNumbersNodes[1]);
56
+ const answer = rand === 6 ? a / (b / c) : a / b;
57
+ const question = {
58
+ startStatement: statementTree.toTex(),
59
+ answer: (0, round_1.round)(answer, 2) + '',
60
+ keys: [],
61
+ };
62
+ return question;
63
+ }
64
+ exports.getMentalDivisions = getMentalDivisions;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const mentalMultiplications: Exercise;
3
+ export declare function getMentalMultiplications(): Question;
4
+ //# sourceMappingURL=mentalMultiplications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentalMultiplications.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/mentalCaluls.ts/mentalMultiplications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,eAAO,MAAM,qBAAqB,EAAE,QAUnC,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,QAAQ,CAmCnD"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMentalMultiplications = exports.mentalMultiplications = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const randint_1 = require("../../../math/utils/random/randint");
6
+ const round_1 = require("../../../math/utils/round");
7
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
8
+ const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
9
+ const coinFlip_1 = require("../../../utils/coinFlip");
10
+ exports.mentalMultiplications = {
11
+ id: 'mentalMultiplications',
12
+ connector: '=',
13
+ instruction: 'Calculer :',
14
+ label: 'Effectuer mentalement des calculs de multiplications simples',
15
+ levels: ['6', '5', '4', '3', '2', '1', '0'],
16
+ section: 'Calculs',
17
+ isSingleStep: true,
18
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMentalMultiplications, nb),
19
+ keys: [],
20
+ };
21
+ function getMentalMultiplications() {
22
+ const a = (0, randint_1.randint)(-9, 10, [-1, 0, 1]);
23
+ const b = (0, coinFlip_1.coinFlip)()
24
+ ? (0, randint_1.randint)(-99, 100, [-10, 0, 10]) / 10
25
+ : (0, coinFlip_1.coinFlip)()
26
+ ? (0, randint_1.randint)(2, 10) * 10 + (0, randint_1.randint)(-1, 2, [0])
27
+ : (0, randint_1.randint)(2, 10) + (0, randint_1.randint)(-1, 2, [0]) / 10;
28
+ const c = (0, randint_1.randint)(2, 9, [3, 6, 7]);
29
+ const d = (0, randint_1.randint)(2, 11, [c]) / c;
30
+ const f = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(2, 10) / 10 : (0, randint_1.randint)(2, 100) / 100;
31
+ let numbers = [a, b, c, d, f];
32
+ const allNumbersNodes = numbers.map((nb) => new numberNode_1.NumberNode(nb));
33
+ let statementTree;
34
+ let answer;
35
+ if ((0, coinFlip_1.coinFlip)()) {
36
+ statementTree = new multiplyNode_1.MultiplyNode(allNumbersNodes[0], allNumbersNodes[1]);
37
+ answer = numbers[0] * numbers[1];
38
+ }
39
+ else {
40
+ statementTree = new multiplyNode_1.MultiplyNode(allNumbersNodes[2], new multiplyNode_1.MultiplyNode(allNumbersNodes[3], allNumbersNodes[4]));
41
+ answer = numbers[2] * numbers[3] * numbers[4];
42
+ }
43
+ statementTree.shuffle();
44
+ const question = {
45
+ startStatement: statementTree.toTex(),
46
+ answer: (0, round_1.round)(answer, 2) + '',
47
+ keys: [],
48
+ };
49
+ return question;
50
+ }
51
+ exports.getMentalMultiplications = getMentalMultiplications;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const mentalPercentage: Exercise;
3
+ export declare function getMentalPercentage(): Question;
4
+ //# sourceMappingURL=mentalPercentage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentalPercentage.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/mentalCaluls.ts/mentalPercentage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,gBAAgB,EAAE,QAU9B,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,QAAQ,CA6D9C"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMentalPercentage = exports.mentalPercentage = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const randint_1 = require("../../../math/utils/random/randint");
6
+ const coinFlip_1 = require("../../../utils/coinFlip");
7
+ exports.mentalPercentage = {
8
+ id: 'mentalPercentage',
9
+ connector: '=',
10
+ instruction: '',
11
+ label: 'Effectuer mentalement des calculs de pourcentages simples',
12
+ levels: ['5', '4', '3', '2', '1', '0'],
13
+ section: 'Pourcentages',
14
+ isSingleStep: true,
15
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getMentalPercentage, nb),
16
+ keys: [],
17
+ };
18
+ function getMentalPercentage() {
19
+ let a = 1, b = 1;
20
+ const rand = (0, randint_1.randint)(1, 10);
21
+ switch (rand) {
22
+ case 1: // 10% de 70%
23
+ a = 10 * (0, randint_1.randint)(1, 3);
24
+ b = (0, randint_1.randint)(1, 200);
25
+ break;
26
+ case 2: // 30% de 9
27
+ a = (0, randint_1.randint)(1, 10);
28
+ b = (0, randint_1.randint)(1, 10) * a;
29
+ a *= 10;
30
+ break;
31
+ case 3: // 32% de 10
32
+ a = (0, randint_1.randint)(1, 100);
33
+ b = 10 ** (0, randint_1.randint)(1, 3);
34
+ break;
35
+ case 4: // 14% de 50 ou 230% de 20
36
+ a = (0, coinFlip_1.coinFlip)() ? (0, randint_1.randint)(1, 100) : (0, randint_1.randint)(11, 30) * 10;
37
+ b = (0, coinFlip_1.coinFlip)() ? 20 : 50;
38
+ break;
39
+ case 5: // 12.5% de 72
40
+ a = (0, coinFlip_1.coinFlip)() ? 12.5 : 12.5 + 100;
41
+ b = 8 * (0, randint_1.randint)(1, 25);
42
+ break;
43
+ case 6: // 15% de 90
44
+ a = (0, coinFlip_1.coinFlip)() ? 15 * (0, randint_1.randint)(1, 6) : 30 * (0, randint_1.randint)(1, 4, [2]) + 100;
45
+ b = 3 * (0, randint_1.randint)(1, 10) * 10;
46
+ break;
47
+ case 7: // 20% de x
48
+ a = 20 * (0, randint_1.randint)(1, 12, [5]);
49
+ b = 5 * (0, randint_1.randint)(1, 21);
50
+ break;
51
+ case 8: // 75% de x
52
+ a = 25 * (0, randint_1.randint)(1, 8, [4]);
53
+ b = 4 * (0, randint_1.randint)(1, 75);
54
+ break;
55
+ case 9: //0.5 % de 1000
56
+ a = (0, randint_1.randint)(1, 10) / 10;
57
+ b = 1000;
58
+ break;
59
+ }
60
+ const question = {
61
+ instruction: `Calculer $${a}\\%$ de $${b}$`,
62
+ answer: (a * b) / 100 + '',
63
+ keys: [],
64
+ };
65
+ return question;
66
+ }
67
+ exports.getMentalPercentage = getMentalPercentage;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const firstDegreeDerivative: Exercise;
3
+ export declare function getFirstDegreeDerivative(): Question;
4
+ //# sourceMappingURL=firstDegreeDerivative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firstDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/firstDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,qBAAqB,EAAE,QAUnC,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,QAAQ,CAYnD"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFirstDegreeDerivative = exports.firstDegreeDerivative = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const polynomial_1 = require("../../../math/polynomials/polynomial");
6
+ const randint_1 = require("../../../math/utils/random/randint");
7
+ exports.firstDegreeDerivative = {
8
+ id: 'firstDegreeDerivative',
9
+ connector: '=',
10
+ instruction: '',
11
+ label: "Dérivée d'un polynôme de degré 1",
12
+ levels: ['1', '0'],
13
+ section: 'Dérivation',
14
+ isSingleStep: false,
15
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getFirstDegreeDerivative, nb),
16
+ keys: ['x'],
17
+ };
18
+ function getFirstDegreeDerivative() {
19
+ const [a, b] = [(0, randint_1.randint)(-9, 10), (0, randint_1.randint)(-9, 10)];
20
+ const polynomial = new polynomial_1.Polynomial([b, a]);
21
+ const question = {
22
+ instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) = ${polynomial.toString()}$ `,
23
+ startStatement: `f'(x)`,
24
+ answer: a + '',
25
+ keys: [],
26
+ };
27
+ return question;
28
+ }
29
+ exports.getFirstDegreeDerivative = getFirstDegreeDerivative;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const inverseFunctionDerivative: Exercise;
3
+ export declare function getInverseFunctionDerivative(): Question;
4
+ //# sourceMappingURL=inverseFunctionDerivative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inverseFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/inverseFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAI9D,eAAO,MAAM,yBAAyB,EAAE,QAUvC,CAAC;AAEF,wBAAgB,4BAA4B,IAAI,QAAQ,CAWvD"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInverseFunctionDerivative = exports.inverseFunctionDerivative = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const randint_1 = require("../../../math/utils/random/randint");
6
+ exports.inverseFunctionDerivative = {
7
+ id: 'inverseFunctionDerivative',
8
+ connector: '=',
9
+ instruction: '',
10
+ label: "Dérivée d'une fonction inverse",
11
+ levels: ['1', '0'],
12
+ section: 'Dérivation',
13
+ isSingleStep: false,
14
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getInverseFunctionDerivative, nb),
15
+ keys: ['x'],
16
+ };
17
+ function getInverseFunctionDerivative() {
18
+ const a = (0, randint_1.randint)(-10, 10, [0]);
19
+ const question = {
20
+ instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) =\\frac{${a}}{x}$ `,
21
+ startStatement: `f'(x)`,
22
+ answer: `\\frac{${-a}}{x^2}`,
23
+ keys: ['x'],
24
+ };
25
+ return question;
26
+ }
27
+ exports.getInverseFunctionDerivative = getInverseFunctionDerivative;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const powerFunctionDerivative: Exercise;
3
+ export declare function getPowerFunctionDerivative(): Question;
4
+ //# sourceMappingURL=powerFunctionDerivative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powerFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/powerFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS9D,eAAO,MAAM,uBAAuB,EAAE,QAUrC,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,QAAQ,CAoBrD"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPowerFunctionDerivative = exports.powerFunctionDerivative = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const randint_1 = require("../../../math/utils/random/randint");
6
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
7
+ const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
8
+ const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
9
+ const variableNode_1 = require("../../../tree/nodes/variables/variableNode");
10
+ const simplify_1 = require("../../../tree/parsers/simplify");
11
+ exports.powerFunctionDerivative = {
12
+ id: 'powerFunctionDerivative',
13
+ connector: '=',
14
+ instruction: '',
15
+ label: "Dérivée d'une fonction puissance",
16
+ levels: ['1', '0'],
17
+ section: 'Dérivation',
18
+ isSingleStep: false,
19
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getPowerFunctionDerivative, nb),
20
+ keys: ['x'],
21
+ };
22
+ function getPowerFunctionDerivative() {
23
+ const a = (0, randint_1.randint)(-10, 10, [0]);
24
+ const n = (0, randint_1.randint)(2, 10);
25
+ const statement = (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new powerNode_1.PowerNode(new variableNode_1.VariableNode('x'), new numberNode_1.NumberNode(n))));
26
+ const answerStatement = (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a * n), new powerNode_1.PowerNode(new variableNode_1.VariableNode('x'), new numberNode_1.NumberNode(n - 1))));
27
+ const question = {
28
+ instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) =${statement.toTex()}$ `,
29
+ startStatement: `f'(x)`,
30
+ answer: answerStatement.toTex(),
31
+ keys: ['x'],
32
+ };
33
+ return question;
34
+ }
35
+ exports.getPowerFunctionDerivative = getPowerFunctionDerivative;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const rootFunctionDerivative: Exercise;
3
+ export declare function getRootFunctionDerivative(): Question;
4
+ //# sourceMappingURL=rootFunctionDerivative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rootFunctionDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/rootFunctionDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,sBAAsB,EAAE,QAUpC,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CAqBpD"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRootFunctionDerivative = exports.rootFunctionDerivative = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const randint_1 = require("../../../math/utils/random/randint");
6
+ const round_1 = require("../../../math/utils/round");
7
+ exports.rootFunctionDerivative = {
8
+ id: 'rootFunctionDerivative',
9
+ connector: '=',
10
+ instruction: '',
11
+ label: "Dérivée d'une fonction racine",
12
+ levels: ['1', '0'],
13
+ section: 'Dérivation',
14
+ isSingleStep: false,
15
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getRootFunctionDerivative, nb),
16
+ keys: ['x'],
17
+ };
18
+ function getRootFunctionDerivative() {
19
+ const a = (0, randint_1.randint)(-10, 10, [0]);
20
+ let instruction = `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) =$ `;
21
+ let answer = '';
22
+ if (a === 1)
23
+ instruction += `$\\sqrt{x}$`;
24
+ else if (a === -1)
25
+ instruction += `$-\\sqrt{x}$`;
26
+ else
27
+ instruction += `$${a}\\sqrt{x}$`;
28
+ if (a / 2 === (0, round_1.round)(a / 2, 0))
29
+ answer = `\\frac{${a / 2}}{\\sqrt{x}}`;
30
+ else
31
+ answer = `\\frac{${a}}{2\\sqrt{x}}`;
32
+ const question = {
33
+ instruction,
34
+ startStatement: `f'(x)`,
35
+ answer,
36
+ keys: ['x'],
37
+ };
38
+ return question;
39
+ }
40
+ exports.getRootFunctionDerivative = getRootFunctionDerivative;
@@ -0,0 +1,4 @@
1
+ import { Exercise, Question } from '../../../exercises/exercise';
2
+ export declare const secondDegreeDerivative: Exercise;
3
+ export declare function getSecondDegreeDerivative(): Question;
4
+ //# sourceMappingURL=secondDegreeDerivative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secondDegreeDerivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/secondDegreeDerivative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK9D,eAAO,MAAM,sBAAsB,EAAE,QAUpC,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CAiBpD"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSecondDegreeDerivative = exports.secondDegreeDerivative = void 0;
4
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
5
+ const polynomial_1 = require("../../../math/polynomials/polynomial");
6
+ const randint_1 = require("../../../math/utils/random/randint");
7
+ exports.secondDegreeDerivative = {
8
+ id: 'secondDegreeDerivative',
9
+ connector: '=',
10
+ instruction: '',
11
+ label: "Dérivée d'un polynôme de degré 2",
12
+ levels: ['1', '0'],
13
+ section: 'Dérivation',
14
+ isSingleStep: false,
15
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSecondDegreeDerivative, nb),
16
+ keys: ['x'],
17
+ };
18
+ function getSecondDegreeDerivative() {
19
+ const coefficients = [];
20
+ coefficients.push((0, randint_1.randint)(-9, 10, [0]));
21
+ for (let i = 1; i <= 2; i++)
22
+ coefficients.push((0, randint_1.randint)(-9, 10));
23
+ const polynomial = new polynomial_1.Polynomial(coefficients);
24
+ const derivative = polynomial.derivate();
25
+ const question = {
26
+ instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) = ${polynomial.toString()}$ `,
27
+ startStatement: `f'(x)`,
28
+ answer: derivative.toString(),
29
+ keys: ['x'],
30
+ };
31
+ return question;
32
+ }
33
+ exports.getSecondDegreeDerivative = getSecondDegreeDerivative;
@@ -1 +1 @@
1
- {"version":3,"file":"usualderivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/usualderivative.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGpD,eAAO,MAAM,eAAe,EAAE,QAU7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,QAAQ,CAsD7C"}
1
+ {"version":3,"file":"usualderivative.d.ts","sourceRoot":"","sources":["../../../../src/exercises/derivation/derivative/usualderivative.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AASpD,eAAO,MAAM,eAAe,EAAE,QAU7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,QAAQ,CAmB7C"}
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUsualDerivative = exports.usualDerivative = void 0;
4
- const polynomial_1 = require("../../../math/polynomials/polynomial");
5
4
  const randint_1 = require("../../../math/utils/random/randint");
6
- const round_1 = require("../../../math/utils/round");
7
5
  const getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
6
+ const firstDegreeDerivative_1 = require("./firstDegreeDerivative");
7
+ const inverseFunctionDerivative_1 = require("./inverseFunctionDerivative");
8
+ const powerFunctionDerivative_1 = require("./powerFunctionDerivative");
9
+ const rootFunctionDerivative_1 = require("./rootFunctionDerivative");
10
+ const secondDegreeDerivative_1 = require("./secondDegreeDerivative");
11
+ const thirdDegreeDerivative_1 = require("./thirdDegreeDerivative");
8
12
  exports.usualDerivative = {
9
13
  id: 'usualDerivative',
10
14
  connector: '=',
@@ -17,58 +21,22 @@ exports.usualDerivative = {
17
21
  keys: ['x'],
18
22
  };
19
23
  function getUsualDerivative() {
20
- const a = (0, randint_1.randint)(-10, 10, [0]);
21
- const b = (0, randint_1.randint)(-10, 10);
22
- const c = (0, randint_1.randint)(-10, 10);
23
- const flip = (0, randint_1.randint)(1, 6);
24
- let instruction = `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) =$ `;
25
- let answer = '';
26
- switch (flip) {
27
- case 1: {
28
- // f(x) = c
29
- instruction += `$${c}$`;
30
- answer = `0`;
31
- break;
32
- }
33
- case 2: {
34
- // f(x) = ax + b
35
- instruction += `$${new polynomial_1.Polynomial([b, a]).toString()}$`;
36
- answer = `${a}`;
37
- break;
38
- }
39
- case 3: {
40
- // f(x) = ax² + bx + c
41
- instruction += `$${new polynomial_1.Polynomial([c, b, a]).toString()}$`;
42
- answer = `${new polynomial_1.Polynomial([b, 2 * a]).toString()}`;
43
- break;
44
- }
45
- case 4: {
46
- //f(x) = a/x
47
- instruction += `$\\frac{${a}}{x}$`;
48
- answer = `\\frac{${-a}}{x^2}`;
49
- break;
50
- }
51
- case 5: {
52
- // f(x) = a * sqrt(x)
53
- if (a === 1)
54
- instruction += `$\\sqrt{x}$`;
55
- else if (a === -1)
56
- instruction += `$-\\sqrt{x}$`;
57
- else
58
- instruction += `$${a}\\sqrt{x}$`;
59
- if (a / 2 === (0, round_1.round)(a / 2, 0))
60
- answer = `\\frac{${a / 2}}{\\sqrt{x}}`;
61
- else
62
- answer = `\\frac{${a}}{2\\sqrt{x}}`;
63
- break;
64
- }
24
+ const rand = (0, randint_1.randint)(1, 7);
25
+ switch (rand) {
26
+ case 1:
27
+ return (0, firstDegreeDerivative_1.getFirstDegreeDerivative)();
28
+ case 2:
29
+ return (0, secondDegreeDerivative_1.getSecondDegreeDerivative)();
30
+ case 3:
31
+ return (0, thirdDegreeDerivative_1.getThirdDegreeDerivative)();
32
+ case 4:
33
+ return (0, inverseFunctionDerivative_1.getInverseFunctionDerivative)();
34
+ case 5:
35
+ return (0, powerFunctionDerivative_1.getPowerFunctionDerivative)();
36
+ case 6:
37
+ return (0, rootFunctionDerivative_1.getRootFunctionDerivative)();
38
+ default:
39
+ throw Error('erreur');
65
40
  }
66
- const question = {
67
- instruction,
68
- startStatement: `f'(x)`,
69
- answer,
70
- keys: ['x'],
71
- };
72
- return question;
73
41
  }
74
42
  exports.getUsualDerivative = getUsualDerivative;
@@ -4,6 +4,8 @@ export interface Question {
4
4
  startStatement?: string;
5
5
  answer: string;
6
6
  keys?: string[];
7
+ commands?: string[];
8
+ coords?: number[];
7
9
  }
8
10
  export interface Exercise {
9
11
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"exercise.d.ts","sourceRoot":"","sources":["../../src/exercises/exercise.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAElC,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,GAAG,GAAG,OAAO,GAAG,UAAU,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,QAAQ,EAAE,CAAC;CAC/D"}
1
+ {"version":3,"file":"exercise.d.ts","sourceRoot":"","sources":["../../src/exercises/exercise.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAElC,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,GAAG,GAAG,OAAO,GAAG,UAAU,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,QAAQ,EAAE,CAAC;CAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAoEA,eAAO,MAAM,SAAS,iCA+GrB,CAAC"}
1
+ {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AA8EA,eAAO,MAAM,SAAS,iCAuHrB,CAAC"}
@@ -6,10 +6,15 @@ const addAndSubWithoutRelatives_1 = require("./calcul/addAndSubWithoutRelatives"
6
6
  const fractionAndIntegerDivision_1 = require("./calcul/fractions/fractionAndIntegerDivision");
7
7
  const fractionAndIntegerProduct_1 = require("./calcul/fractions/fractionAndIntegerProduct");
8
8
  const fractionAndIntegerSum_1 = require("./calcul/fractions/fractionAndIntegerSum");
9
+ const fractionToPercentToDecimal_1 = require("./calcul/fractions/fractionToPercentToDecimal");
9
10
  const fractionsDivision_1 = require("./calcul/fractions/fractionsDivision");
10
11
  const fractionsProduct_1 = require("./calcul/fractions/fractionsProduct");
11
12
  const fractionsSum_1 = require("./calcul/fractions/fractionsSum");
12
13
  const simplifyFraction_1 = require("./calcul/fractions/simplifyFraction");
14
+ const mentalAddAndSub_1 = require("./calcul/mentalCaluls.ts/mentalAddAndSub");
15
+ const mentalDivisions_1 = require("./calcul/mentalCaluls.ts/mentalDivisions");
16
+ const mentalMultiplications_1 = require("./calcul/mentalCaluls.ts/mentalMultiplications");
17
+ const mentalPercentage_1 = require("./calcul/mentalCaluls.ts/mentalPercentage");
13
18
  const operationsPriorities_1 = require("./calcul/operations/operationsPriorities");
14
19
  const operationsPrioritiesWithoutRelative_1 = require("./calcul/operations/operationsPrioritiesWithoutRelative");
15
20
  const rounding_1 = require("./calcul/rounding/rounding");
@@ -29,8 +34,15 @@ const factoIdRmq1_1 = require("./calculLitteral/factorisation/factoIdRmq1");
29
34
  const factoIdRmq2_1 = require("./calculLitteral/factorisation/factoIdRmq2");
30
35
  const factoIdRmq3_1 = require("./calculLitteral/factorisation/factoIdRmq3");
31
36
  const factoType1Exercise_1 = require("./calculLitteral/factorisation/factoType1Exercise");
37
+ const firstDegreeDerivative_1 = require("./derivation/derivative/firstDegreeDerivative");
38
+ const inverseFunctionDerivative_1 = require("./derivation/derivative/inverseFunctionDerivative");
39
+ const powerFunctionDerivative_1 = require("./derivation/derivative/powerFunctionDerivative");
40
+ const rootFunctionDerivative_1 = require("./derivation/derivative/rootFunctionDerivative");
41
+ const secondDegreeDerivative_1 = require("./derivation/derivative/secondDegreeDerivative");
32
42
  const thirdDegreeDerivative_1 = require("./derivation/derivative/thirdDegreeDerivative");
33
43
  const usualderivative_1 = require("./derivation/derivative/usualderivative");
44
+ const derivativeNumberReading_1 = require("./geometry/cartesian/derivativeNumberReading");
45
+ const leadingCoefficient_1 = require("./geometry/cartesian/leadingCoefficient");
34
46
  const midpoint_1 = require("./geometry/cartesian/midpoint");
35
47
  const scalarProductViaCoords_1 = require("./geometry/vectors/scalarProductViaCoords");
36
48
  const applyPercent_1 = require("./percent/applyPercent");
@@ -43,6 +55,8 @@ const powersPower_1 = require("./powers/powersPower");
43
55
  const powersProduct_1 = require("./powers/powersProduct");
44
56
  const scientificToDecimal_1 = require("./powers/scientificToDecimal");
45
57
  const conditionalProbability_1 = require("./proba/conditionalProbability");
58
+ const marginalAndConditionalFrequency_1 = require("./proba/marginalAndConditionalFrequency");
59
+ const probabilityTree_1 = require("./proba/probabilityTree");
46
60
  const arithmeticExplicitFormulaUsage_1 = require("./sequences/arithmetic/arithmeticExplicitFormulaUsage");
47
61
  const arithmeticFindExplicitFormula_1 = require("./sequences/arithmetic/arithmeticFindExplicitFormula");
48
62
  const arithmeticFindReason_1 = require("./sequences/arithmetic/arithmeticFindReason");
@@ -148,11 +162,20 @@ exports.exercises = [
148
162
  reciprocalPercentage_1.reciprocalPercentage,
149
163
  averageEvolutionRate_1.averageEvolutionRate,
150
164
  usualderivative_1.usualDerivative,
165
+ firstDegreeDerivative_1.firstDegreeDerivative,
166
+ secondDegreeDerivative_1.secondDegreeDerivative,
151
167
  thirdDegreeDerivative_1.thirdDegreeDerivative,
168
+ inverseFunctionDerivative_1.inverseFunctionDerivative,
169
+ rootFunctionDerivative_1.rootFunctionDerivative,
170
+ powerFunctionDerivative_1.powerFunctionDerivative,
152
171
  conditionalProbability_1.conditionalProbability,
153
- // leadingCoefficient,
154
- // derivativeNumberReading,
155
- //derivativeNumberReading2,
156
- // probabilityTree,
157
- // marginalAndConditionalFrequency,
172
+ leadingCoefficient_1.leadingCoefficient,
173
+ derivativeNumberReading_1.derivativeNumberReading,
174
+ probabilityTree_1.probabilityTree,
175
+ fractionToPercentToDecimal_1.fractionToPercentToDecimal,
176
+ marginalAndConditionalFrequency_1.marginalAndConditionalFrequency,
177
+ mentalAddAndSub_1.mentalAddAndSub,
178
+ mentalMultiplications_1.mentalMultiplications,
179
+ mentalDivisions_1.mentalDivisions,
180
+ mentalPercentage_1.mentalPercentage,
158
181
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"derivativeNumberReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/derivativeNumberReading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS9D,eAAO,MAAM,uBAAuB,EAAE,QASrC,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,QAAQ,CA8CrD"}
1
+ {"version":3,"file":"derivativeNumberReading.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/derivativeNumberReading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAS9D,eAAO,MAAM,uBAAuB,EAAE,QASrC,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,QAAQ,CAoCrD"}
@@ -19,22 +19,6 @@ exports.derivativeNumberReading = {
19
19
  generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getDerivativeNumberReading, nb),
20
20
  };
21
21
  function getDerivativeNumberReading() {
22
- /*let xA = randint(-4, 5);
23
- let polynome: Polynomial;
24
- let yA: number;
25
-
26
- do {
27
- polynome = new Polynomial([randint(-4, 5), randint(-4, 5), randint(-4, 5), randint(-4, 5, [0])]);
28
- yA = polynome.coefficients[0];
29
- for (let index = 1; index < 4; index++) yA += polynome.coefficients[index] * Math.pow(xA, index);
30
- } while (yA < -5 || yA > 5);
31
-
32
- const pointA = new Point('A', new NumberNode(xA), new NumberNode(yA));
33
- const slope = polynome.derivate().coefficients[2] * xA;
34
- const droite = DroiteConstructor.fromPointAndSlope(pointA, new NumberNode(slope));
35
-
36
- let instruction = `$f(x) = ${polynome}$, $${pointA.toTexWithCoords()}$, $f'(${xA}) = ${slope}$`;
37
- */
38
22
  let xA, yA, xB, yB;
39
23
  let pointA, pointB;
40
24
  do {
@@ -49,11 +33,18 @@ function getDerivativeNumberReading() {
49
33
  const c = (0, mathjs_1.evaluate)(droite.a.toMathString()) - a * Math.pow(xA, 2) - b * xA;
50
34
  const d = yA - (a / 3) * Math.pow(xA, 3) - (b / 2) * Math.pow(xA, 2) - xA * c;
51
35
  const polynome = new polynomial_1.Polynomial([d, c, b / 2, a / 3]);
52
- let instruction = `$f(x) = ${polynome.toTex()}$, $${pointA.toTexWithCoords()}$, $${pointB.toTexWithCoords()}$, $f'(${xA}) = ${droite.getLeadingCoefficient()}$`;
36
+ const instruction = `Ci-dessous sont tracées la courbe de la fonction f et la tangente à cette courbe au point d'abscisse $${xA}$.$\\\\$ Déterminer le coefficient directeur de la tangente qui passe par ce point.`;
37
+ const commands = [
38
+ polynome.toString(),
39
+ `g(x) = (${droite.a.toMathString()}) * x + (${droite.b.toMathString()})`,
40
+ `(${xA},${yA})`,
41
+ ];
53
42
  const question = {
54
43
  instruction,
55
- //startStatement: 'a',
44
+ startStatement: 'a',
56
45
  answer: droite.getLeadingCoefficient(),
46
+ commands,
47
+ coords: [xA - 5, xA + 5, yA - 5, yA + 5],
57
48
  };
58
49
  return question;
59
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"leadingCoefficient.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/leadingCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAO9D,eAAO,MAAM,kBAAkB,EAAE,QAShC,CAAC;AAEF,wBAAgB,6BAA6B,IAAI,QAAQ,CAuBxD"}
1
+ {"version":3,"file":"leadingCoefficient.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/cartesian/leadingCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQ9D,eAAO,MAAM,kBAAkB,EAAE,QAShC,CAAC;AAEF,wBAAgB,6BAA6B,IAAI,QAAQ,CA4CxD"}
@@ -6,10 +6,11 @@ const droite_1 = require("../../../math/geometry/droite");
6
6
  const point_1 = require("../../../math/geometry/point");
7
7
  const randint_1 = require("../../../math/utils/random/randint");
8
8
  const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
9
+ const mathjs_1 = require("mathjs");
9
10
  exports.leadingCoefficient = {
10
11
  id: 'leadingCoefficient',
11
12
  connector: '=',
12
- instruction: '',
13
+ instruction: 'Déterminer le coefficient directeur de la droite représentée ci-dessous :',
13
14
  label: 'Déterminer le coefficient directeur',
14
15
  levels: ['3', '2', '1'],
15
16
  isSingleStep: false,
@@ -27,11 +28,32 @@ function getLeadingCoefficientQuestion() {
27
28
  pointB = new point_1.Point('B', new numberNode_1.NumberNode(xB), new numberNode_1.NumberNode(yB));
28
29
  } while (xB - xA === 0);
29
30
  const droite = droite_1.DroiteConstructor.fromTwoPoints(pointA, pointB, 'D');
30
- let instruction = `Quel est le coefficient directeur de la droite $${droite.toEquationExpression()}$`;
31
+ const a = droite.a.toMathString();
32
+ const b = droite.b.toMathString();
33
+ const aValue = (0, mathjs_1.evaluate)(a);
34
+ const bValue = (0, mathjs_1.evaluate)(b);
35
+ let xmin, xmax, ymin, ymax;
36
+ if (bValue > 0) {
37
+ ymax = bValue + 1;
38
+ ymin = -1;
39
+ }
40
+ else {
41
+ ymin = bValue - 1;
42
+ ymax = 1;
43
+ }
44
+ if (-bValue / aValue > 0) {
45
+ xmax = -bValue / aValue + 1;
46
+ xmin = -1;
47
+ }
48
+ else {
49
+ xmin = -bValue / aValue - 1;
50
+ xmax = 1;
51
+ }
31
52
  const question = {
32
- instruction,
33
- //startStatement: pointA.toTexWithCoords() + ' ' + pointB.toTexWithCoords(),
34
53
  answer: droite.getLeadingCoefficient(),
54
+ keys: [],
55
+ commands: [`f(x) = (${a}) * x + (${b})`],
56
+ coords: [xmin, xmax, ymin, ymax],
35
57
  };
36
58
  return question;
37
59
  }
@@ -29,37 +29,37 @@ function getConditionalProbability() {
29
29
  case 1: {
30
30
  instruction += `$p(A) = ${pA / 100}, p(A \\cap B) = ${pAB / 100}$.$\\\\$Déterminer $p_A(B)$.`;
31
31
  startStatement = `p_A(B)`;
32
- answer = `${pB_A}`.replace('.', ',');
32
+ answer = `${pB_A}`;
33
33
  break;
34
34
  }
35
35
  case 2: {
36
36
  instruction += `$p(B) = ${pB / 100}, p(B \\cap A) = ${pAB / 100}$.$\\\\$Déterminer $p_B(A)$.`;
37
37
  startStatement = `p_B(A)`;
38
- answer = `${pA_B}`.replace('.', ',');
38
+ answer = `${pA_B}`;
39
39
  break;
40
40
  }
41
41
  case 3: {
42
42
  instruction += `$p(A) = ${pA / 100}, p_A(B) = ${pB_A}$.$\\\\$Déterminer $p(A \\cap B)$.`;
43
43
  startStatement = `p(A \\cap B)`;
44
- answer = `${pAB / 100}`.replace('.', ',');
44
+ answer = `${pAB / 100}`;
45
45
  break;
46
46
  }
47
47
  case 4: {
48
48
  instruction += `$p(B) = ${pB / 100}, p_B(A) = ${pA_B}$.$\\\\$Déterminer $p(A \\cap B)$.`;
49
49
  startStatement = `p(A \\cap B)`;
50
- answer = `${pAB / 100}`.replace('.', ',');
50
+ answer = `${pAB / 100}`;
51
51
  break;
52
52
  }
53
53
  case 5: {
54
54
  instruction += `$p(A \\cap B) = ${pAB / 100}, p_B(A) = ${pA_B}$.$\\\\$Déterminer $p(B)$.`;
55
55
  startStatement = `p(B)`;
56
- answer = `${pB / 100}`.replace('.', ',');
56
+ answer = `${pB / 100}`;
57
57
  break;
58
58
  }
59
59
  case 6: {
60
60
  instruction += `$p(A \\cap B) = ${pAB / 100}, p_A(B) = ${pB_A}$.$\\\\$Déterminer $p(A)$.`;
61
61
  startStatement = `p(A)`;
62
- answer = `${pA / 100}`.replace('.', ',');
62
+ answer = `${pA / 100}`;
63
63
  break;
64
64
  }
65
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"marginalAndConditionalFrequency.d.ts","sourceRoot":"","sources":["../../../src/exercises/proba/marginalAndConditionalFrequency.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGjD,eAAO,MAAM,+BAA+B,EAAE,QAU7C,CAAC;AAEF,wBAAgB,kCAAkC,IAAI,QAAQ,CA4D7D"}
1
+ {"version":3,"file":"marginalAndConditionalFrequency.d.ts","sourceRoot":"","sources":["../../../src/exercises/proba/marginalAndConditionalFrequency.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGjD,eAAO,MAAM,+BAA+B,EAAE,QAU7C,CAAC;AAEF,wBAAgB,kCAAkC,IAAI,QAAQ,CAmE7D"}
@@ -63,7 +63,14 @@ function getMarginalAndConditionalFrequency() {
63
63
  ];
64
64
  Calculs = Calculs.map((el) => (0, round_1.round)(el, 2));
65
65
  const question = {
66
- instruction: `$|\\;\\;\\;| A | B | \\\\ | C | ${x1} | ${x2} | \\\\| D | ${x3} | ${x4} |\\\\$ Calculer la fréquence ${freqString[rand]}`,
66
+ instruction: `On considère le tableau d'effectifs suivant :
67
+
68
+ | |A|B|
69
+ |-|-|-|
70
+ |C|${x1}|${x2}|
71
+ |D|${x3}|${x4}|
72
+
73
+ Calculer la fréquence ${freqString[rand]}.`,
67
74
  startStatement: `${frequences[rand]}`,
68
75
  answer: Calculs[rand].toString(),
69
76
  keys: ['f', 'cap', 'underscore'],
@@ -1 +1 @@
1
- {"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../src/exercises/proba/probabilityTree.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGjD,eAAO,MAAM,eAAe,EAAE,QAS7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,QAAQ,CAqD7C"}
1
+ {"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../src/exercises/proba/probabilityTree.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGjD,eAAO,MAAM,eAAe,EAAE,QAS7B,CAAC;AAEF,wBAAgB,kBAAkB,IAAI,QAAQ,CAyF7C"}
@@ -17,15 +17,19 @@ exports.probabilityTree = {
17
17
  generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getProbabilityTree, nb),
18
18
  };
19
19
  function getProbabilityTree() {
20
- const A = (0, randint_1.randint)(4, 9);
21
- const B = (0, randint_1.randint)(4, 10 - A);
20
+ const A = (0, randint_1.randint)(2, 9);
21
+ const B = (0, randint_1.randint)(2, 10 - A);
22
+ const AC = (0, randint_1.randint)(2, 9);
23
+ const AD = (0, randint_1.randint)(2, 10 - AC);
24
+ const BC = (0, randint_1.randint)(2, 9);
25
+ const BD = (0, randint_1.randint)(2, 10 - BC);
22
26
  const pA = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(A / (A + B)));
23
27
  const pB = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(B / (A + B)));
24
- const pA_C = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode((A - 1) / (A + B - 1)));
25
- const pA_D = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(B / (A + B - 1)));
26
- const pB_C = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(A / (A + B - 1)));
27
- const pB_D = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode((B - 1) / (A + B - 1)));
28
- let instruction = `$P(A) = ${pA.toTex()}, P(B) = ${pB.toTex()}$.$\\\\$ $P_A(C) = ${pA_C.toTex()}, P_A(D) = ${pA_D.toTex()}, P_B(C) = ${pB_C.toTex()}, P_B(D) = ${pB_D.toTex()}$.`;
28
+ const pA_C = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(AC / (AC + AD)));
29
+ const pA_D = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(AD / (AC + AD)));
30
+ const pB_C = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(BC / (BC + BD)));
31
+ const pB_D = (0, simplify_1.simplifyNode)(new numberNode_1.NumberNode(BD / (BC + BD)));
32
+ let instruction = `En utilisant l'arbre de probabilité suivant, `;
29
33
  let startStatement = '';
30
34
  let answer = '';
31
35
  const rand = (0, randint_1.randint)(1, 5);
@@ -55,11 +59,42 @@ function getProbabilityTree() {
55
59
  break;
56
60
  }
57
61
  }
62
+ let commands = [
63
+ 'Racine = Point({0,0})',
64
+ 'A = Point({2,2})',
65
+ 'B = Point({2,-2})',
66
+ 'AC = Point({5,3})',
67
+ 'AD = Point({5,1})',
68
+ 'BC = Point({5,-1})',
69
+ 'BD = Point({5,-3})',
70
+ 'Segment(Racine,A)',
71
+ 'Segment(A,AC)',
72
+ 'Segment(A,AD)',
73
+ 'Segment(Racine,B)',
74
+ 'Segment(B,BC)',
75
+ 'Segment(B,BD)',
76
+ 'ShowAxes(false)',
77
+ 'ShowGrid(false)',
78
+ `Text("${pA.toTex()}", (0.5, 2.5), true, true)`,
79
+ `Text("${pA_C.toTex()}", (3, 4), true, true)`,
80
+ `Text("${pA_D.toTex()}", (3, 1.5), true, true)`,
81
+ `Text("${pB.toTex()}", (0.5, -1), true, true)`,
82
+ `Text("${pB_C.toTex()}", (3, 0), true, true)`,
83
+ `Text("${pB_D.toTex()}", (3, -2.5), true, true)`,
84
+ 'Text("A", (1.85 , 2.5))',
85
+ 'Text("B", (1.85 , -2.7))',
86
+ 'Text("C", (5.5 , 2.85))',
87
+ 'Text("D", (5.5 , 0.85))',
88
+ 'Text("C", (5.5 , -1.1))',
89
+ 'Text("D", (5.5 , -3.1))',
90
+ ];
58
91
  const question = {
59
92
  instruction,
60
93
  startStatement,
61
94
  answer,
62
95
  keys: [],
96
+ commands,
97
+ coords: [-2, 8, -4, 4],
63
98
  };
64
99
  return question;
65
100
  }
@@ -1,3 +1,4 @@
1
1
  import { Question } from '../exercise';
2
+ export declare function equalTab<T>(array1: T[], array2: T[]): boolean;
2
3
  export declare const getDistinctQuestions: (generator: Function, nb: number) => Question[];
3
4
  //# sourceMappingURL=getDistinctQuestions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDistinctQuestions.d.ts","sourceRoot":"","sources":["../../../src/exercises/utils/getDistinctQuestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,eAAO,MAAM,oBAAoB,cAAe,QAAQ,MAAM,MAAM,KAAG,QAAQ,EAW9E,CAAC"}
1
+ {"version":3,"file":"getDistinctQuestions.d.ts","sourceRoot":"","sources":["../../../src/exercises/utils/getDistinctQuestions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,WAKnD;AAED,eAAO,MAAM,oBAAoB,cAAe,QAAQ,MAAM,MAAM,KAAG,QAAQ,EAkB9E,CAAC"}
@@ -1,13 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDistinctQuestions = void 0;
3
+ exports.getDistinctQuestions = exports.equalTab = void 0;
4
+ function equalTab(array1, array2) {
5
+ if (!array1 || !array2)
6
+ return false;
7
+ if (array1.length !== array2.length)
8
+ return false;
9
+ for (let i = 0; i < array1.length; i++)
10
+ if (array1[i] !== array2[i])
11
+ return false;
12
+ return true;
13
+ }
14
+ exports.equalTab = equalTab;
4
15
  const getDistinctQuestions = (generator, nb) => {
5
16
  const res = [];
6
17
  for (let i = 0; i < nb; i++) {
7
18
  let question;
8
19
  do {
9
20
  question = generator();
10
- } while (res.some((q) => q.instruction === question.instruction && q.startStatement === question.startStatement));
21
+ } while (res.some((q) => q.instruction === question.instruction &&
22
+ q.startStatement === question.startStatement &&
23
+ equalTab(q.commands, question.commands)));
11
24
  res.push(question);
12
25
  }
13
26
  return res;
@@ -24,7 +24,7 @@ class DivideNode extends operatorNode_1.OperatorNode {
24
24
  let needBrackets = rightTex[0] === '-';
25
25
  if (this.rightChild.type === node_1.NodeType.operator) {
26
26
  const operatorRightChild = this.rightChild;
27
- needBrackets || (needBrackets = [operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract].includes(operatorRightChild.id));
27
+ needBrackets || (needBrackets = [operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract, operatorNode_1.OperatorIds.divide].includes(operatorRightChild.id));
28
28
  }
29
29
  if (needBrackets)
30
30
  rightTex = `(${rightTex})`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.3.25",
3
+ "version": "1.3.27",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [