math-exercises 1.3.25 → 1.3.26

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.
@@ -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 = `,
49
- answer,
50
- };
51
-
52
- return question;
53
- }*/
63
+ //startStatement: `${simplifyNode(fraction).toTex()}`,
64
+ answer: answer.replace('.', ','),
65
+ keys: [],
66
+ };
67
+ return question;
68
+ }
69
+ exports.getFractionToPercentToDecimal = getFractionToPercentToDecimal;
@@ -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":"AAqEA,eAAO,MAAM,SAAS,iCA8GrB,CAAC"}
@@ -6,6 +6,7 @@ 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");
@@ -31,6 +32,8 @@ const factoIdRmq3_1 = require("./calculLitteral/factorisation/factoIdRmq3");
31
32
  const factoType1Exercise_1 = require("./calculLitteral/factorisation/factoType1Exercise");
32
33
  const thirdDegreeDerivative_1 = require("./derivation/derivative/thirdDegreeDerivative");
33
34
  const usualderivative_1 = require("./derivation/derivative/usualderivative");
35
+ const derivativeNumberReading_1 = require("./geometry/cartesian/derivativeNumberReading");
36
+ const leadingCoefficient_1 = require("./geometry/cartesian/leadingCoefficient");
34
37
  const midpoint_1 = require("./geometry/cartesian/midpoint");
35
38
  const scalarProductViaCoords_1 = require("./geometry/vectors/scalarProductViaCoords");
36
39
  const applyPercent_1 = require("./percent/applyPercent");
@@ -43,6 +46,8 @@ const powersPower_1 = require("./powers/powersPower");
43
46
  const powersProduct_1 = require("./powers/powersProduct");
44
47
  const scientificToDecimal_1 = require("./powers/scientificToDecimal");
45
48
  const conditionalProbability_1 = require("./proba/conditionalProbability");
49
+ const marginalAndConditionalFrequency_1 = require("./proba/marginalAndConditionalFrequency");
50
+ const probabilityTree_1 = require("./proba/probabilityTree");
46
51
  const arithmeticExplicitFormulaUsage_1 = require("./sequences/arithmetic/arithmeticExplicitFormulaUsage");
47
52
  const arithmeticFindExplicitFormula_1 = require("./sequences/arithmetic/arithmeticFindExplicitFormula");
48
53
  const arithmeticFindReason_1 = require("./sequences/arithmetic/arithmeticFindReason");
@@ -150,9 +155,9 @@ exports.exercises = [
150
155
  usualderivative_1.usualDerivative,
151
156
  thirdDegreeDerivative_1.thirdDegreeDerivative,
152
157
  conditionalProbability_1.conditionalProbability,
153
- // leadingCoefficient,
154
- // derivativeNumberReading,
155
- //derivativeNumberReading2,
156
- // probabilityTree,
157
- // marginalAndConditionalFrequency,
158
+ leadingCoefficient_1.leadingCoefficient,
159
+ derivativeNumberReading_1.derivativeNumberReading,
160
+ probabilityTree_1.probabilityTree,
161
+ fractionToPercentToDecimal_1.fractionToPercentToDecimal,
162
+ marginalAndConditionalFrequency_1.marginalAndConditionalFrequency,
158
163
  ];
@@ -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: 'Quel est le coefficient directeur de la droite suivante :',
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
  }
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.3.25",
3
+ "version": "1.3.26",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [