math-exercises 1.4.4 → 1.4.5

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 (51) hide show
  1. package/lib/exercises/calcul/fractions/fractionToPercentToDecimal.js +1 -1
  2. package/lib/exercises/exercise.d.ts +2 -2
  3. package/lib/exercises/exercise.d.ts.map +1 -1
  4. package/lib/exercises/exercises.d.ts +2 -1
  5. package/lib/exercises/exercises.d.ts.map +1 -1
  6. package/lib/exercises/exercises.js +16 -2
  7. package/lib/exercises/functions/affines/leadingCoefficient.d.ts.map +1 -1
  8. package/lib/exercises/functions/affines/leadingCoefficient.js +2 -1
  9. package/lib/exercises/geometry/euclidean/pythagore.d.ts.map +1 -1
  10. package/lib/exercises/geometry/euclidean/pythagore.js +2 -1
  11. package/lib/exercises/limits/polynomLimit.d.ts +4 -0
  12. package/lib/exercises/limits/polynomLimit.d.ts.map +1 -0
  13. package/lib/exercises/limits/polynomLimit.js +66 -0
  14. package/lib/exercises/limits/polynomLimitNoFI.d.ts +4 -0
  15. package/lib/exercises/limits/polynomLimitNoFI.d.ts.map +1 -0
  16. package/lib/exercises/limits/polynomLimitNoFI.js +67 -0
  17. package/lib/exercises/limits/rationalFracForbiddenValueLimit.d.ts +4 -0
  18. package/lib/exercises/limits/rationalFracForbiddenValueLimit.d.ts.map +1 -0
  19. package/lib/exercises/limits/rationalFracForbiddenValueLimit.js +82 -0
  20. package/lib/exercises/limits/rationalFracLimit.d.ts +4 -0
  21. package/lib/exercises/limits/rationalFracLimit.d.ts.map +1 -0
  22. package/lib/exercises/limits/rationalFracLimit.js +84 -0
  23. package/lib/exercises/powers/calculateNegativePower.d.ts +4 -0
  24. package/lib/exercises/powers/calculateNegativePower.d.ts.map +1 -0
  25. package/lib/exercises/powers/calculateNegativePower.js +76 -0
  26. package/lib/exercises/powers/calculatePower.d.ts +4 -0
  27. package/lib/exercises/powers/calculatePower.d.ts.map +1 -0
  28. package/lib/exercises/powers/calculatePower.js +80 -0
  29. package/lib/exercises/powers/decimalToScientific.d.ts +4 -0
  30. package/lib/exercises/powers/decimalToScientific.d.ts.map +1 -0
  31. package/lib/exercises/powers/decimalToScientific.js +90 -0
  32. package/lib/exercises/powers/powerDefinition.d.ts +4 -0
  33. package/lib/exercises/powers/powerDefinition.d.ts.map +1 -0
  34. package/lib/exercises/powers/powerDefinition.js +69 -0
  35. package/lib/exercises/powers/scientificToDecimal.d.ts.map +1 -1
  36. package/lib/exercises/powers/scientificToDecimal.js +10 -11
  37. package/lib/index.d.ts.map +1 -1
  38. package/lib/index.js +2 -0
  39. package/lib/math/numbers/decimals/decimal.d.ts +4 -1
  40. package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
  41. package/lib/math/numbers/decimals/decimal.js +45 -2
  42. package/lib/math/numbers/integer/integer.js +1 -1
  43. package/lib/math/numbers/rationals/rational.d.ts.map +1 -1
  44. package/lib/math/numbers/rationals/rational.js +5 -2
  45. package/lib/math/polynomials/polynomial.d.ts +1 -0
  46. package/lib/math/polynomials/polynomial.d.ts.map +1 -1
  47. package/lib/math/polynomials/polynomial.js +25 -0
  48. package/lib/utils/probaFlip.d.ts +2 -0
  49. package/lib/utils/probaFlip.d.ts.map +1 -0
  50. package/lib/utils/probaFlip.js +7 -0
  51. package/package.json +1 -1
@@ -28,7 +28,7 @@ function getFractionToPercentToDecimal() {
28
28
  const decimal = numerator / denominator;
29
29
  const percent = (0, round_1.round)((numerator / denominator) * 100, 2);
30
30
  const rand = (0, randint_1.randint)(1, 7);
31
- let instruction;
31
+ let instruction = '';
32
32
  let answer = '';
33
33
  switch (rand) {
34
34
  case 1: {
@@ -9,7 +9,7 @@ export type Proposition = {
9
9
  format: 'tex' | 'raw';
10
10
  };
11
11
  export interface Question {
12
- instruction?: string;
12
+ instruction: string;
13
13
  startStatement?: string;
14
14
  answer: string;
15
15
  answerFormat: 'tex' | 'raw';
@@ -22,7 +22,7 @@ export interface Question {
22
22
  }
23
23
  export interface MathExercise {
24
24
  id: string;
25
- instruction: string;
25
+ instruction?: string;
26
26
  isSingleStep: boolean;
27
27
  label: string;
28
28
  sections: MathSection[];
@@ -1 +1 @@
1
- {"version":3,"file":"exercise.d.ts","sourceRoot":"","sources":["../../src/exercises/exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,eAAO,MAAM,iBAAiB,UAAW,WAAW,EAAE,aAAa,MAAM,WAAU,KAAK,GAAG,KAAK,SAS/F,CAAC;AAEF,eAAO,MAAM,YAAY,UAAW,WAAW,EAAE,KAAK,MAAM,kBAE3D,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAElC,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;CACvB,CAAC;AACF,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,KAAK,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,cAAc,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;IACvC,eAAe,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,WAAW,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,GAAG,GAAG,OAAO,GAAG,UAAU,CAAC;IACvC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;IACf,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,QAAQ,EAAE,CAAC;IAC9D,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,UAAU,GACV,SAAS,GACT,UAAU,GACV,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,iBAAiB,GACjB,SAAS,GACT,aAAa,GACb,YAAY,GACZ,SAAS,GACT,0BAA0B,GAC1B,WAAW,GACX,2BAA2B,GAC3B,eAAe,GACf,eAAe,GACf,kBAAkB,GAClB,WAAW,GACX,mBAAmB,GACnB,wBAAwB,GACxB,WAAW,GACX,uBAAuB,GACvB,uBAAuB,GACvB,aAAa,GACb,aAAa,GACb,SAAS,GACT,qBAAqB,GACrB,mBAAmB,GACnB,cAAc,GACd,YAAY,GACZ,cAAc,GACd,kBAAkB,GAClB,YAAY,GACZ,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,QAAQ,GACR,eAAe,GACf,UAAU,CAAC"}
1
+ {"version":3,"file":"exercise.d.ts","sourceRoot":"","sources":["../../src/exercises/exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,eAAO,MAAM,iBAAiB,UAAW,WAAW,EAAE,aAA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;IAC7B,UAAU,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,UAAU,GACV,SAAS,GACT,UAAU,GACV,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,iBAAiB,GACjB,SAAS,GACT,aAAa,GACb,YAAY,GACZ,SAAS,GACT,0BAA0B,GAC1B,WAAW,GACX,2BAA2B,GAC3B,eAAe,GACf,eAAe,GACf,kBAAkB,GAClB,WAAW,GACX,mBAAmB,GACnB,wBAAwB,GACxB,WAAW,GACX,uBAAuB,GACvB,uBAAuB,GACvB,aAAa,GACb,aAAa,GACb,SAAS,GACT,qBAAqB,GACrB,mBAAmB,GACnB,cAAc,GACd,YAAY,GACZ,cAAc,GACd,kBAAkB,GAClB,YAAY,GACZ,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,QAAQ,GACR,eAAe,GACf,UAAU,CAAC"}
@@ -1,2 +1,3 @@
1
- export declare const exercises: import("./exercise").MathExercise[];
1
+ import { MathExercise } from './exercise';
2
+ export declare const exercises: MathExercise[];
2
3
  //# sourceMappingURL=exercises.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAoLA,eAAO,MAAM,SAAS,qCAsQrB,CAAC"}
1
+ {"version":3,"file":"exercises.d.ts","sourceRoot":"","sources":["../../src/exercises/exercises.ts"],"names":[],"mappings":"AAkLA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAU1C,eAAO,MAAM,SAAS,EAAE,YAAY,EA4QnC,CAAC"}
@@ -115,7 +115,7 @@ const quartiles_1 = require("../exercises/probaStat/quartiles");
115
115
  const quartilesList_1 = require("../exercises/probaStat/quartilesList");
116
116
  const euclideanDivision_1 = require("../exercises/calcul/arithmetics/euclideanDivision");
117
117
  const thirdDegreeFunctionVariation_1 = require("../exercises/derivation/derivative/thirdDegreeFunctionVariation");
118
- const polynomeLimit_1 = require("../exercises/limits/polynomeLimit");
118
+ const polynomLimit_1 = require("../exercises/limits/polynomLimit");
119
119
  const constantPrimitive_1 = require("../exercises/primitve/constantPrimitive");
120
120
  const polynomialPrimitive_1 = require("../exercises/primitve/polynomialPrimitive");
121
121
  const sinCosPrimitive_1 = require("../exercises/primitve/sinCosPrimitive");
@@ -169,7 +169,14 @@ const sequencePolynomLimit_1 = require("./limits/sequencePolynomLimit");
169
169
  const sequenceRationalFracLimit_1 = require("./limits/sequenceRationalFracLimit");
170
170
  const sequencePolynomProductLimit_1 = require("./limits/sequencePolynomProductLimit");
171
171
  const sequencePolynomNoFILimit_1 = require("./limits/sequencePolynomNoFILimit");
172
+ const polynomLimitNoFI_1 = require("./limits/polynomLimitNoFI");
173
+ const rationalFracLimit_1 = require("./limits/rationalFracLimit");
174
+ const rationalFracForbiddenValueLimit_1 = require("./limits/rationalFracForbiddenValueLimit");
172
175
  const sequenceGeometricLimit_1 = require("./limits/sequenceGeometricLimit");
176
+ const calculatePower_1 = require("./powers/calculatePower");
177
+ const calculateNegativePower_1 = require("./powers/calculateNegativePower");
178
+ const decimalToScientific_1 = require("./powers/decimalToScientific");
179
+ const powerDefinition_1 = require("./powers/powerDefinition");
173
180
  exports.exercises = [
174
181
  /**
175
182
  * calcul litteral
@@ -268,7 +275,11 @@ exports.exercises = [
268
275
  powersPower_1.powersOfTenPower,
269
276
  powersProduct_1.powersOfTenProduct,
270
277
  scientificToDecimal_1.scientificToDecimal,
278
+ decimalToScientific_1.decimalToScientific,
271
279
  powersOfTenToDecimal_1.powersOfTenToDecimal,
280
+ calculatePower_1.calculatePower,
281
+ calculateNegativePower_1.calculateNegativePower,
282
+ powerDefinition_1.powerDefinition,
272
283
  /**
273
284
  * suites
274
285
  */
@@ -401,7 +412,10 @@ exports.exercises = [
401
412
  intervalsUnion_1.intervalsUnion,
402
413
  intervalsIntersection_1.intervalsIntersection,
403
414
  /**limites */
404
- polynomeLimit_1.polynomeLimit,
415
+ polynomLimit_1.polynomLimit,
416
+ polynomLimitNoFI_1.polynomLimitNoFI,
417
+ rationalFracLimit_1.rationalFracLimit,
418
+ rationalFracForbiddenValueLimit_1.rationalFracForbiddenValueLimit,
405
419
  sequencePolynomLimit_1.sequencePolynomLimit,
406
420
  sequencePolynomNoFILimit_1.sequencePolynomNoFILimit,
407
421
  sequenceRationalFracLimit_1.sequenceRationalFracLimit,
@@ -1 +1 @@
1
- {"version":3,"file":"leadingCoefficient.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/affines/leadingCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAY/E,eAAO,MAAM,kBAAkB,EAAE,YAWhC,CAAC;AAEF,wBAAgB,6BAA6B,IAAI,QAAQ,CAiFxD"}
1
+ {"version":3,"file":"leadingCoefficient.d.ts","sourceRoot":"","sources":["../../../../src/exercises/functions/affines/leadingCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAY/E,eAAO,MAAM,kBAAkB,EAAE,YAWhC,CAAC;AAEF,wBAAgB,6BAA6B,IAAI,QAAQ,CAkFxD"}
@@ -14,7 +14,7 @@ const uuid_1 = require("uuid");
14
14
  exports.leadingCoefficient = {
15
15
  id: 'leadingCoefficient',
16
16
  connector: '=',
17
- instruction: 'Déterminer le coefficient directeur de la droite représentée ci-dessous :',
17
+ instruction: '',
18
18
  label: 'Lire le coefficient directeur',
19
19
  levels: ['3ème', '2nde', '1reESM', '2ndPro', '1rePro', '1reTech'],
20
20
  isSingleStep: false,
@@ -83,6 +83,7 @@ function getLeadingCoefficientQuestion() {
83
83
  return (0, shuffle_1.shuffle)(res);
84
84
  };
85
85
  const question = {
86
+ instruction: 'Déterminer le coefficient directeur de la droite représentée ci-dessous : ',
86
87
  answer: droite.getLeadingCoefficient(),
87
88
  keys: [],
88
89
  commands: [`f(x) = (${a}) * x + (${b})`],
@@ -1 +1 @@
1
- {"version":3,"file":"pythagore.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/euclidean/pythagore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQ/E,eAAO,MAAM,SAAS,EAAE,YAWvB,CAAC;AAEF,wBAAgB,YAAY,IAAI,QAAQ,CA6EvC"}
1
+ {"version":3,"file":"pythagore.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/euclidean/pythagore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAQ/E,eAAO,MAAM,SAAS,EAAE,YAWvB,CAAC;AAEF,wBAAgB,YAAY,IAAI,QAAQ,CA8EvC"}
@@ -9,7 +9,7 @@ const uuid_1 = require("uuid");
9
9
  exports.pythagore = {
10
10
  id: 'pythagore',
11
11
  connector: '=',
12
- instruction: "Écrire l'égalité de Pythagore pour la figure suivante : ",
12
+ instruction: '',
13
13
  label: "Écrire l'égalité de Pythagore",
14
14
  levels: ['4ème', '3ème', '2nde'],
15
15
  isSingleStep: false,
@@ -76,6 +76,7 @@ function getPythagore() {
76
76
  return (0, shuffle_1.shuffle)(res);
77
77
  };
78
78
  const question = {
79
+ instruction: "Écrire l'égalité de Pythagore pour la figure suivante : ",
79
80
  answer: `${triangle.getSideAName()}^2=${triangle.getSideBName()}^2+${triangle.getSideCName()}^2`,
80
81
  keys: [...vertices, 'equal'],
81
82
  commands: triangle.generateCommands({}),
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../../exercises/exercise';
2
+ export declare const polynomLimit: MathExercise;
3
+ export declare function getPolynomLimitQuestion(): Question;
4
+ //# sourceMappingURL=polynomLimit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polynomLimit.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/polynomLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAQlG,eAAO,MAAM,YAAY,EAAE,YAW1B,CAAC;AAEF,wBAAgB,uBAAuB,IAAI,QAAQ,CAkDlD"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPolynomLimitQuestion = exports.polynomLimit = void 0;
4
+ const exercise_1 = require("../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
6
+ const polynomial_1 = require("../../math/polynomials/polynomial");
7
+ const randint_1 = require("../../math/utils/random/randint");
8
+ const coinFlip_1 = require("../../utils/coinFlip");
9
+ const shuffle_1 = require("../../utils/shuffle");
10
+ const uuid_1 = require("uuid");
11
+ exports.polynomLimit = {
12
+ id: 'polynomLimit',
13
+ connector: '=',
14
+ instruction: '',
15
+ label: "Limite d'une fonction polynomiale",
16
+ levels: ['TermSpé', 'MathComp'],
17
+ isSingleStep: true,
18
+ sections: ['Limites'],
19
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getPolynomLimitQuestion, nb),
20
+ qcmTimer: 60,
21
+ freeTimer: 60,
22
+ };
23
+ function getPolynomLimitQuestion() {
24
+ const poly = polynomial_1.PolynomialConstructor.random(4);
25
+ const to = (0, coinFlip_1.coinFlip)() ? '+\\infty' : '-\\infty';
26
+ const answer = poly.getLimit(to);
27
+ const getPropositions = (n) => {
28
+ const res = [];
29
+ res.push({
30
+ id: (0, uuid_1.v4)(),
31
+ statement: answer,
32
+ isRightAnswer: true,
33
+ format: 'tex',
34
+ });
35
+ (0, exercise_1.tryToAddWrongProp)(res, '+\\infty');
36
+ (0, exercise_1.tryToAddWrongProp)(res, '-\\infty');
37
+ (0, exercise_1.tryToAddWrongProp)(res, '0');
38
+ (0, exercise_1.tryToAddWrongProp)(res, poly.coefficients[poly.degree] + '');
39
+ const missing = n - res.length;
40
+ for (let i = 0; i < missing; i++) {
41
+ let isDuplicate;
42
+ let proposition;
43
+ do {
44
+ const wrongAnswer = (0, randint_1.randint)(-10, 10) + '';
45
+ proposition = {
46
+ id: (0, uuid_1.v4)() + ``,
47
+ statement: wrongAnswer,
48
+ isRightAnswer: false,
49
+ format: 'tex',
50
+ };
51
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
52
+ } while (isDuplicate);
53
+ res.push(proposition);
54
+ }
55
+ return (0, shuffle_1.shuffle)(res);
56
+ };
57
+ const question = {
58
+ answer: answer,
59
+ instruction: `Déterminer la limite en $${to}$ de la fonction $f$ définie par : $f(x) = ${poly.toTree().toTex()}$.`,
60
+ keys: ['infty'],
61
+ getPropositions,
62
+ answerFormat: 'tex',
63
+ };
64
+ return question;
65
+ }
66
+ exports.getPolynomLimitQuestion = getPolynomLimitQuestion;
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../../exercises/exercise';
2
+ export declare const polynomLimitNoFI: MathExercise;
3
+ export declare function getSequencePolynomNoFILimitQuestion(): Question;
4
+ //# sourceMappingURL=polynomLimitNoFI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polynomLimitNoFI.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/polynomLimitNoFI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAQlG,eAAO,MAAM,gBAAgB,EAAE,YAW9B,CAAC;AAEF,wBAAgB,mCAAmC,IAAI,QAAQ,CAoD9D"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSequencePolynomNoFILimitQuestion = exports.polynomLimitNoFI = void 0;
4
+ const exercise_1 = require("../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
6
+ const polynomial_1 = require("../../math/polynomials/polynomial");
7
+ const randint_1 = require("../../math/utils/random/randint");
8
+ const coinFlip_1 = require("../../utils/coinFlip");
9
+ const shuffle_1 = require("../../utils/shuffle");
10
+ const uuid_1 = require("uuid");
11
+ exports.polynomLimitNoFI = {
12
+ id: 'polynomLimitNoFI',
13
+ connector: '=',
14
+ instruction: '',
15
+ label: "Limite d'une fonction polynomiale (sans F.I.)",
16
+ levels: ['TermSpé', 'MathComp'],
17
+ isSingleStep: true,
18
+ sections: ['Limites'],
19
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSequencePolynomNoFILimitQuestion, nb),
20
+ qcmTimer: 60,
21
+ freeTimer: 60,
22
+ };
23
+ function getSequencePolynomNoFILimitQuestion() {
24
+ const length = (0, randint_1.randint)(2, 5);
25
+ const to = (0, coinFlip_1.coinFlip)() ? '+\\infty' : '-\\infty';
26
+ const poly = polynomial_1.PolynomialConstructor.randomNoFI(4, to, length);
27
+ const answer = poly.getLimit(to);
28
+ const getPropositions = (n) => {
29
+ const res = [];
30
+ res.push({
31
+ id: (0, uuid_1.v4)(),
32
+ statement: answer,
33
+ isRightAnswer: true,
34
+ format: 'tex',
35
+ });
36
+ (0, exercise_1.tryToAddWrongProp)(res, '+\\infty');
37
+ (0, exercise_1.tryToAddWrongProp)(res, '-\\infty');
38
+ (0, exercise_1.tryToAddWrongProp)(res, '0');
39
+ (0, exercise_1.tryToAddWrongProp)(res, poly.coefficients[poly.degree] + '');
40
+ const missing = n - res.length;
41
+ for (let i = 0; i < missing; i++) {
42
+ let isDuplicate;
43
+ let proposition;
44
+ do {
45
+ const wrongAnswer = (0, randint_1.randint)(-10, 10) + '';
46
+ proposition = {
47
+ id: (0, uuid_1.v4)() + ``,
48
+ statement: wrongAnswer,
49
+ isRightAnswer: false,
50
+ format: 'tex',
51
+ };
52
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
53
+ } while (isDuplicate);
54
+ res.push(proposition);
55
+ }
56
+ return (0, shuffle_1.shuffle)(res);
57
+ };
58
+ const question = {
59
+ answer: answer,
60
+ instruction: `Déterminer la limite en $${to}$ de la fonction $f$ définie par : $f(x) = ${poly.toTree().toTex()}$.`,
61
+ keys: ['infty'],
62
+ getPropositions,
63
+ answerFormat: 'tex',
64
+ };
65
+ return question;
66
+ }
67
+ exports.getSequencePolynomNoFILimitQuestion = getSequencePolynomNoFILimitQuestion;
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../../exercises/exercise';
2
+ export declare const rationalFracForbiddenValueLimit: MathExercise;
3
+ export declare function getSequenceRationalFracLimitQuestion(): Question;
4
+ //# sourceMappingURL=rationalFracForbiddenValueLimit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rationalFracForbiddenValueLimit.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/rationalFracForbiddenValueLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAclG,eAAO,MAAM,+BAA+B,EAAE,YAW7C,CAAC;AAEF,wBAAgB,oCAAoC,IAAI,QAAQ,CAmE/D"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSequenceRationalFracLimitQuestion = exports.rationalFracForbiddenValueLimit = void 0;
4
+ const exercise_1 = require("../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
6
+ const integer_1 = require("../../math/numbers/integer/integer");
7
+ const affine_1 = require("../../math/polynomials/affine");
8
+ const trinom_1 = require("../../math/polynomials/trinom");
9
+ const discreteSet_1 = require("../../math/sets/discreteSet");
10
+ const intervals_1 = require("../../math/sets/intervals/intervals");
11
+ const randint_1 = require("../../math/utils/random/randint");
12
+ const coinFlip_1 = require("../../utils/coinFlip");
13
+ const shuffle_1 = require("../../utils/shuffle");
14
+ const uuid_1 = require("uuid");
15
+ exports.rationalFracForbiddenValueLimit = {
16
+ id: 'rationalFracForbiddenValueLimit',
17
+ connector: '=',
18
+ instruction: '',
19
+ label: "Limite d'une fraction rationnelle avec valeur interdite",
20
+ levels: ['TermSpé', 'MathComp'],
21
+ isSingleStep: true,
22
+ sections: ['Limites'],
23
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSequenceRationalFracLimitQuestion, nb),
24
+ qcmTimer: 60,
25
+ freeTimer: 60,
26
+ };
27
+ function getSequenceRationalFracLimitQuestion() {
28
+ const polyDenum = new affine_1.Affine(1, (0, randint_1.randint)(-9, 10, [0]));
29
+ const forbiddenValue = -polyDenum.b;
30
+ const interval = new intervals_1.Interval('[[-10;10]]').difference(new discreteSet_1.DiscreteSet([new integer_1.Integer(forbiddenValue)]));
31
+ const polyNum = trinom_1.TrinomConstructor.randomFactorized(new intervals_1.Interval('[[-10;10]]'), interval, interval);
32
+ const numLimit = polyNum.calculate(-polyDenum.b);
33
+ const getSign = (nb) => {
34
+ return nb >= 0 ? '+' : '-';
35
+ };
36
+ const isRight = (0, coinFlip_1.coinFlip)();
37
+ const to = isRight ? `${forbiddenValue}` : `${forbiddenValue}`;
38
+ const from = isRight ? `x > ${forbiddenValue}` : `x<${forbiddenValue}`;
39
+ const answer = isRight ? `${getSign(numLimit)}\\infty` : `${getSign(-numLimit)}\\infty`;
40
+ const getPropositions = (n) => {
41
+ const res = [];
42
+ res.push({
43
+ id: (0, uuid_1.v4)(),
44
+ statement: answer,
45
+ isRightAnswer: true,
46
+ format: 'tex',
47
+ });
48
+ (0, exercise_1.tryToAddWrongProp)(res, '+\\infty');
49
+ (0, exercise_1.tryToAddWrongProp)(res, '-\\infty');
50
+ (0, exercise_1.tryToAddWrongProp)(res, '0');
51
+ (0, exercise_1.tryToAddWrongProp)(res, polyNum.coefficients[polyNum.degree].toString());
52
+ const missing = n - res.length;
53
+ for (let i = 0; i < missing; i++) {
54
+ let isDuplicate;
55
+ let proposition;
56
+ do {
57
+ const wrongAnswer = (0, randint_1.randint)(-10, 10) + '';
58
+ proposition = {
59
+ id: (0, uuid_1.v4)() + ``,
60
+ statement: wrongAnswer,
61
+ isRightAnswer: false,
62
+ format: 'tex',
63
+ };
64
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
65
+ } while (isDuplicate);
66
+ res.push(proposition);
67
+ }
68
+ return (0, shuffle_1.shuffle)(res);
69
+ };
70
+ const question = {
71
+ answer,
72
+ instruction: `Soit $f$ la fonction définie par : $f(x) = \\dfrac{${polyNum.toTree().toTex()}}{${polyDenum
73
+ .toTree()
74
+ .toTex()}}$. Déterminer $\\lim\\limits_{x \\to ${to}, ${from}}f(x).$
75
+ `,
76
+ keys: ['infty'],
77
+ getPropositions,
78
+ answerFormat: 'tex',
79
+ };
80
+ return question;
81
+ }
82
+ exports.getSequenceRationalFracLimitQuestion = getSequenceRationalFracLimitQuestion;
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../../exercises/exercise';
2
+ export declare const rationalFracLimit: MathExercise;
3
+ export declare function getSequenceRationalFracLimitQuestion(): Question;
4
+ //# sourceMappingURL=rationalFracLimit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rationalFracLimit.d.ts","sourceRoot":"","sources":["../../../src/exercises/limits/rationalFracLimit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAqB,MAAM,0BAA0B,CAAC;AAUlG,eAAO,MAAM,iBAAiB,EAAE,YAW/B,CAAC;AAEF,wBAAgB,oCAAoC,IAAI,QAAQ,CAoE/D"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSequenceRationalFracLimitQuestion = exports.rationalFracLimit = void 0;
4
+ const exercise_1 = require("../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
6
+ const rational_1 = require("../../math/numbers/rationals/rational");
7
+ const monom_1 = require("../../math/polynomials/monom");
8
+ const polynomial_1 = require("../../math/polynomials/polynomial");
9
+ const randint_1 = require("../../math/utils/random/randint");
10
+ const coinFlip_1 = require("../../utils/coinFlip");
11
+ const shuffle_1 = require("../../utils/shuffle");
12
+ const uuid_1 = require("uuid");
13
+ exports.rationalFracLimit = {
14
+ id: 'rationalFracLimit',
15
+ connector: '=',
16
+ instruction: '',
17
+ label: "Limite d'une fraction rationnelle",
18
+ levels: ['TermSpé', 'MathComp'],
19
+ isSingleStep: true,
20
+ sections: ['Limites'],
21
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSequenceRationalFracLimitQuestion, nb),
22
+ qcmTimer: 60,
23
+ freeTimer: 60,
24
+ };
25
+ function getSequenceRationalFracLimitQuestion() {
26
+ const polyNum = polynomial_1.PolynomialConstructor.randomWithLength(4, (0, randint_1.randint)(2, 5));
27
+ const polyDenum = polynomial_1.PolynomialConstructor.randomWithLength(4, (0, randint_1.randint)(2, 5));
28
+ const numLeadingCoeff = polyNum.coefficients[polyNum.degree];
29
+ const denumLeadingCoeff = polyDenum.coefficients[polyDenum.degree];
30
+ const to = (0, coinFlip_1.coinFlip)() ? '+\\infty' : '-\\infty';
31
+ let answer;
32
+ let leadingCoeffsRational = new rational_1.Rational(numLeadingCoeff, denumLeadingCoeff).simplify().toTree().toTex();
33
+ if (polyDenum.degree === polyNum.degree) {
34
+ answer = leadingCoeffsRational;
35
+ }
36
+ else if (polyDenum.degree > polyNum.degree) {
37
+ answer = '0';
38
+ }
39
+ else {
40
+ const tempPoly = new monom_1.Monom(polyNum.degree - polyDenum.degree, numLeadingCoeff * denumLeadingCoeff > 0 ? 1 : -1);
41
+ answer = tempPoly.getLimit(to);
42
+ }
43
+ const getPropositions = (n) => {
44
+ const res = [];
45
+ res.push({
46
+ id: (0, uuid_1.v4)(),
47
+ statement: answer,
48
+ isRightAnswer: true,
49
+ format: 'tex',
50
+ });
51
+ (0, exercise_1.tryToAddWrongProp)(res, '+\\infty');
52
+ (0, exercise_1.tryToAddWrongProp)(res, '-\\infty');
53
+ (0, exercise_1.tryToAddWrongProp)(res, '0');
54
+ (0, exercise_1.tryToAddWrongProp)(res, leadingCoeffsRational);
55
+ const missing = n - res.length;
56
+ for (let i = 0; i < missing; i++) {
57
+ let isDuplicate;
58
+ let proposition;
59
+ do {
60
+ const wrongAnswer = (0, randint_1.randint)(-10, 10) + '';
61
+ proposition = {
62
+ id: (0, uuid_1.v4)() + ``,
63
+ statement: wrongAnswer,
64
+ isRightAnswer: false,
65
+ format: 'tex',
66
+ };
67
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
68
+ } while (isDuplicate);
69
+ res.push(proposition);
70
+ }
71
+ return (0, shuffle_1.shuffle)(res);
72
+ };
73
+ const question = {
74
+ answer,
75
+ instruction: `Déterminer la limite en $${to}$ de la fonction $f$ définie par : $f(x) = \\dfrac{${polyNum
76
+ .toTree()
77
+ .toTex()}}{${polyDenum.toTree().toTex()}}$.`,
78
+ keys: ['infty'],
79
+ getPropositions,
80
+ answerFormat: 'tex',
81
+ };
82
+ return question;
83
+ }
84
+ exports.getSequenceRationalFracLimitQuestion = getSequenceRationalFracLimitQuestion;
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../../exercises/exercise';
2
+ export declare const calculateNegativePower: MathExercise;
3
+ export declare function getCalculatePowerQuestion(): Question;
4
+ //# sourceMappingURL=calculateNegativePower.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateNegativePower.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/calculateNegativePower.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,0BAA0B,CAAC;AAWhH,eAAO,MAAM,sBAAsB,EAAE,YAWpC,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CA2DpD"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCalculatePowerQuestion = exports.calculateNegativePower = void 0;
4
+ const exercise_1 = require("../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
6
+ const rational_1 = require("../../math/numbers/rationals/rational");
7
+ const randint_1 = require("../../math/utils/random/randint");
8
+ const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
9
+ const powerNode_1 = require("../../tree/nodes/operators/powerNode");
10
+ const uuid_1 = require("uuid");
11
+ exports.calculateNegativePower = {
12
+ id: 'calculateNegativePower',
13
+ connector: '=',
14
+ instruction: '',
15
+ label: 'Calculer une puissance négative',
16
+ levels: ['4ème', '3ème', '2ndPro', '2nde', 'CAP'],
17
+ isSingleStep: true,
18
+ sections: ['Puissances'],
19
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getCalculatePowerQuestion, nb),
20
+ qcmTimer: 60,
21
+ freeTimer: 60,
22
+ };
23
+ function getCalculatePowerQuestion() {
24
+ const int = (0, randint_1.randint)(0, 11);
25
+ const power = (0, randint_1.randint)(-5, 0);
26
+ const statement = new powerNode_1.PowerNode(new numberNode_1.NumberNode(int), new numberNode_1.NumberNode(power)).toTex();
27
+ const answer = new rational_1.Rational(1, int ** Math.abs(power)).simplify().toTree().toTex();
28
+ const getPropositions = (n) => {
29
+ const res = [];
30
+ res.push({
31
+ id: (0, uuid_1.v4)(),
32
+ statement: answer,
33
+ isRightAnswer: true,
34
+ format: 'tex',
35
+ });
36
+ (0, exercise_1.tryToAddWrongProp)(res, int * power + '');
37
+ (0, exercise_1.tryToAddWrongProp)(res, -(int ** Math.abs(power)) + '');
38
+ (0, exercise_1.tryToAddWrongProp)(res, int * power + '');
39
+ if (int < 0)
40
+ (0, exercise_1.tryToAddWrongProp)(res, -(int ** power) + '');
41
+ if (int === 0 || int === 1) {
42
+ (0, exercise_1.tryToAddWrongProp)(res, power + '');
43
+ (0, exercise_1.tryToAddWrongProp)(res, '0');
44
+ (0, exercise_1.tryToAddWrongProp)(res, '1');
45
+ (0, exercise_1.tryToAddWrongProp)(res, '-1');
46
+ (0, exercise_1.tryToAddWrongProp)(res, '2');
47
+ (0, exercise_1.tryToAddWrongProp)(res, -power + '');
48
+ }
49
+ const missing = n - res.length;
50
+ for (let i = 0; i < missing; i++) {
51
+ let isDuplicate;
52
+ let proposition;
53
+ do {
54
+ const wrongAnswer = new rational_1.Rational(1, int ** (0, randint_1.randint)(0, 6, [power])).simplify().toTree().toTex();
55
+ proposition = {
56
+ id: (0, uuid_1.v4)() + ``,
57
+ statement: wrongAnswer,
58
+ isRightAnswer: false,
59
+ format: 'tex',
60
+ };
61
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
62
+ } while (isDuplicate);
63
+ res.push(proposition);
64
+ }
65
+ return (0, exercise_1.shuffleProps)(res, n);
66
+ };
67
+ const question = {
68
+ answer,
69
+ instruction: `Calculer : $${statement}$`,
70
+ keys: [],
71
+ getPropositions,
72
+ answerFormat: 'tex',
73
+ };
74
+ return question;
75
+ }
76
+ exports.getCalculatePowerQuestion = getCalculatePowerQuestion;
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../../exercises/exercise';
2
+ export declare const calculatePower: MathExercise;
3
+ export declare function getCalculatePowerQuestion(): Question;
4
+ //# sourceMappingURL=calculatePower.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculatePower.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/calculatePower.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,0BAA0B,CAAC;AAShH,eAAO,MAAM,cAAc,EAAE,YAW5B,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CAgEpD"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCalculatePowerQuestion = exports.calculatePower = void 0;
4
+ const exercise_1 = require("../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
6
+ const randint_1 = require("../../math/utils/random/randint");
7
+ const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
8
+ const powerNode_1 = require("../../tree/nodes/operators/powerNode");
9
+ const uuid_1 = require("uuid");
10
+ exports.calculatePower = {
11
+ id: 'calculatePower',
12
+ connector: '=',
13
+ instruction: '',
14
+ label: 'Calculer une puissance',
15
+ levels: ['4ème', '3ème', '2ndPro', '2nde', 'CAP'],
16
+ isSingleStep: true,
17
+ sections: ['Puissances'],
18
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getCalculatePowerQuestion, nb),
19
+ qcmTimer: 60,
20
+ freeTimer: 60,
21
+ };
22
+ function getCalculatePowerQuestion() {
23
+ const int = (0, randint_1.randint)(-10, 11);
24
+ const power = (0, randint_1.randint)(0, 6);
25
+ const statement = new powerNode_1.PowerNode(new numberNode_1.NumberNode(int), new numberNode_1.NumberNode(power)).toTex();
26
+ const answer = int ** power + '';
27
+ const getPropositions = (n) => {
28
+ const res = [];
29
+ res.push({
30
+ id: (0, uuid_1.v4)(),
31
+ statement: answer,
32
+ isRightAnswer: true,
33
+ format: 'tex',
34
+ });
35
+ (0, exercise_1.tryToAddWrongProp)(res, int * power + '');
36
+ if (int < 0)
37
+ (0, exercise_1.tryToAddWrongProp)(res, -(int ** power) + '');
38
+ if (int === 0) {
39
+ (0, exercise_1.tryToAddWrongProp)(res, power + '');
40
+ (0, exercise_1.tryToAddWrongProp)(res, '1');
41
+ (0, exercise_1.tryToAddWrongProp)(res, -power + '');
42
+ (0, exercise_1.tryToAddWrongProp)(res, '-1');
43
+ (0, exercise_1.tryToAddWrongProp)(res, '2');
44
+ }
45
+ if (int === 1 || int === -1) {
46
+ (0, exercise_1.tryToAddWrongProp)(res, power + '');
47
+ (0, exercise_1.tryToAddWrongProp)(res, '0');
48
+ (0, exercise_1.tryToAddWrongProp)(res, '1');
49
+ (0, exercise_1.tryToAddWrongProp)(res, '-1');
50
+ (0, exercise_1.tryToAddWrongProp)(res, '2');
51
+ (0, exercise_1.tryToAddWrongProp)(res, -power + '');
52
+ }
53
+ const missing = n - res.length;
54
+ for (let i = 0; i < missing; i++) {
55
+ let isDuplicate;
56
+ let proposition;
57
+ do {
58
+ const wrongAnswer = int ** (0, randint_1.randint)(0, 6, [power]) + '';
59
+ proposition = {
60
+ id: (0, uuid_1.v4)() + ``,
61
+ statement: wrongAnswer,
62
+ isRightAnswer: false,
63
+ format: 'tex',
64
+ };
65
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
66
+ } while (isDuplicate);
67
+ res.push(proposition);
68
+ }
69
+ return (0, exercise_1.shuffleProps)(res, n);
70
+ };
71
+ const question = {
72
+ answer,
73
+ instruction: `Calculer : $${statement}$`,
74
+ keys: [],
75
+ getPropositions,
76
+ answerFormat: 'tex',
77
+ };
78
+ return question;
79
+ }
80
+ exports.getCalculatePowerQuestion = getCalculatePowerQuestion;
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../exercise';
2
+ export declare const decimalToScientific: MathExercise;
3
+ export declare function getDecimalToScientificQuestion(): Question;
4
+ //# sourceMappingURL=decimalToScientific.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimalToScientific.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/decimalToScientific.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,aAAa,CAAC;AAInG,eAAO,MAAM,mBAAmB,EAAE,YA0BjC,CAAC;AAEF,wBAAgB,8BAA8B,IAAI,QAAQ,CAyDzD"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDecimalToScientificQuestion = exports.decimalToScientific = void 0;
4
+ const decimal_1 = require("../../math/numbers/decimals/decimal");
5
+ const integer_1 = require("../../math/numbers/integer/integer");
6
+ const randint_1 = require("../../math/utils/random/randint");
7
+ const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
8
+ const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
9
+ const powerNode_1 = require("../../tree/nodes/operators/powerNode");
10
+ const probaFlip_1 = require("../../utils/probaFlip");
11
+ const exercise_1 = require("../exercise");
12
+ const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
13
+ const uuid_1 = require("uuid");
14
+ exports.decimalToScientific = {
15
+ id: 'decimalToScientific',
16
+ connector: '=',
17
+ instruction: '',
18
+ label: "Passer d'écriture décimal à écriture scientifique",
19
+ levels: [
20
+ '5ème',
21
+ '4ème',
22
+ '3ème',
23
+ '2nde',
24
+ 'CAP',
25
+ '2ndPro',
26
+ '1reESM',
27
+ '1rePro',
28
+ '1reSpé',
29
+ '1reTech',
30
+ 'TermPro',
31
+ 'TermTech',
32
+ ],
33
+ sections: ['Puissances'],
34
+ isSingleStep: true,
35
+ keys: [],
36
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getDecimalToScientificQuestion, nb),
37
+ qcmTimer: 60,
38
+ freeTimer: 60,
39
+ };
40
+ function getDecimalToScientificQuestion() {
41
+ //! manque le cas 0.000
42
+ const isZero = (0, probaFlip_1.probaFlip)(0.2);
43
+ let intPart, dec;
44
+ if (isZero) {
45
+ dec = decimal_1.DecimalConstructor.fromParts('0', decimal_1.DecimalConstructor.randomFracPart((0, randint_1.randint)(2, 5), (0, randint_1.randint)(1, 4)));
46
+ }
47
+ else {
48
+ intPart = integer_1.IntegerConstructor.random((0, randint_1.randint)(2, 5));
49
+ dec = decimal_1.DecimalConstructor.fromParts(intPart.toString(), decimal_1.DecimalConstructor.randomFracPart((0, randint_1.randint)(1, 5)));
50
+ }
51
+ const decTex = dec.toTree().toTex();
52
+ const answer = dec.toScientificNotation().toTex();
53
+ const getPropositions = (n) => {
54
+ const res = [];
55
+ res.push({
56
+ id: (0, uuid_1.v4)() + '',
57
+ statement: answer,
58
+ isRightAnswer: true,
59
+ format: 'tex',
60
+ });
61
+ const missing = n - res.length;
62
+ for (let i = 0; i < missing; i++) {
63
+ let isDuplicate;
64
+ let proposition;
65
+ do {
66
+ const wrongAnswer = new multiplyNode_1.MultiplyNode(dec.toScientificPart(), new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode((0, randint_1.randint)(-5, 5, [0, 1])))).toTex();
67
+ // const wrongAnswer = randint(-100, 100) + '';
68
+ proposition = {
69
+ id: (0, uuid_1.v4)() + '',
70
+ statement: wrongAnswer,
71
+ isRightAnswer: false,
72
+ format: 'tex',
73
+ };
74
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
75
+ } while (isDuplicate);
76
+ res.push(proposition);
77
+ }
78
+ return (0, exercise_1.shuffleProps)(res, n);
79
+ };
80
+ const question = {
81
+ instruction: `Donner l'écriture scientifique de : $${decTex}$`,
82
+ startStatement: decTex,
83
+ answer: answer,
84
+ keys: [],
85
+ getPropositions,
86
+ answerFormat: 'tex',
87
+ };
88
+ return question;
89
+ }
90
+ exports.getDecimalToScientificQuestion = getDecimalToScientificQuestion;
@@ -0,0 +1,4 @@
1
+ import { MathExercise, Question } from '../../exercises/exercise';
2
+ export declare const powerDefinition: MathExercise;
3
+ export declare function getPowerDefinitionQuestion(): Question;
4
+ //# sourceMappingURL=powerDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powerDefinition.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/powerDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAmC,MAAM,0BAA0B,CAAC;AAOhH,eAAO,MAAM,eAAe,EAAE,YAW7B,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,QAAQ,CAqDrD"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPowerDefinitionQuestion = exports.powerDefinition = void 0;
4
+ const exercise_1 = require("../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
6
+ const randint_1 = require("../../math/utils/random/randint");
7
+ const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
8
+ const powerNode_1 = require("../../tree/nodes/operators/powerNode");
9
+ const uuid_1 = require("uuid");
10
+ exports.powerDefinition = {
11
+ id: 'powerDefinition',
12
+ connector: '=',
13
+ instruction: '',
14
+ label: 'Écrire un produit sous forme de puissance',
15
+ levels: ['4ème', '3ème', '2ndPro', 'CAP'],
16
+ isSingleStep: true,
17
+ sections: ['Puissances'],
18
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getPowerDefinitionQuestion, nb),
19
+ qcmTimer: 60,
20
+ freeTimer: 60,
21
+ };
22
+ function getPowerDefinitionQuestion() {
23
+ const int = (0, randint_1.randint)(2, 11);
24
+ const power = (0, randint_1.randint)(2, 6);
25
+ let statement = '';
26
+ for (let i = 0; i < power; i++) {
27
+ statement += int + '';
28
+ if (i < power - 1)
29
+ statement += '\\times';
30
+ }
31
+ const answer = new powerNode_1.PowerNode(new numberNode_1.NumberNode(int), new numberNode_1.NumberNode(power)).toTex();
32
+ const getPropositions = (n) => {
33
+ const res = [];
34
+ res.push({
35
+ id: (0, uuid_1.v4)(),
36
+ statement: answer,
37
+ isRightAnswer: true,
38
+ format: 'tex',
39
+ });
40
+ (0, exercise_1.tryToAddWrongProp)(res, `${power}\\times${int}`);
41
+ (0, exercise_1.tryToAddWrongProp)(res, `${int}\\times${power}`);
42
+ const missing = n - res.length;
43
+ for (let i = 0; i < missing; i++) {
44
+ let isDuplicate;
45
+ let proposition;
46
+ do {
47
+ const wrongAnswer = new powerNode_1.PowerNode(new numberNode_1.NumberNode(int), new numberNode_1.NumberNode((0, randint_1.randint)(2, 7))).toTex();
48
+ proposition = {
49
+ id: (0, uuid_1.v4)() + ``,
50
+ statement: wrongAnswer,
51
+ isRightAnswer: false,
52
+ format: 'tex',
53
+ };
54
+ isDuplicate = res.some((p) => p.statement === proposition.statement);
55
+ } while (isDuplicate);
56
+ res.push(proposition);
57
+ }
58
+ return (0, exercise_1.shuffleProps)(res, n);
59
+ };
60
+ const question = {
61
+ answer,
62
+ instruction: `Écrire sous forme de puissance : $${statement}$`,
63
+ keys: [],
64
+ getPropositions,
65
+ answerFormat: 'tex',
66
+ };
67
+ return question;
68
+ }
69
+ exports.getPowerDefinitionQuestion = getPowerDefinitionQuestion;
@@ -1 +1 @@
1
- {"version":3,"file":"scientificToDecimal.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/scientificToDecimal.ts"],"names":[],"mappings":"AAAA;;MAEM;AASN,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIlE,eAAO,MAAM,mBAAmB,EAAE,YA0BjC,CAAC;AAEF,wBAAgB,8BAA8B,IAAI,QAAQ,CAsDzD"}
1
+ {"version":3,"file":"scientificToDecimal.d.ts","sourceRoot":"","sources":["../../../src/exercises/powers/scientificToDecimal.ts"],"names":[],"mappings":"AAAA;;MAEM;AASN,OAAO,EAAE,YAAY,EAAe,QAAQ,EAAqB,MAAM,aAAa,CAAC;AAIrF,eAAO,MAAM,mBAAmB,EAAE,YA0BjC,CAAC;AAEF,wBAAgB,8BAA8B,IAAI,QAAQ,CAoDzD"}
@@ -5,19 +5,19 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getScientificToDecimalQuestion = exports.scientificToDecimal = void 0;
7
7
  const decimal_1 = require("../../math/numbers/decimals/decimal");
8
- const integer_1 = require("../../math/numbers/integer/integer");
9
8
  const randint_1 = require("../../math/utils/random/randint");
10
9
  const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
11
10
  const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
12
11
  const powerNode_1 = require("../../tree/nodes/operators/powerNode");
13
12
  const shuffle_1 = require("../../utils/shuffle");
13
+ const exercise_1 = require("../exercise");
14
14
  const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
15
15
  const uuid_1 = require("uuid");
16
16
  exports.scientificToDecimal = {
17
17
  id: 'scientificToDecimal',
18
18
  connector: '=',
19
19
  instruction: '',
20
- label: 'Ecriture décimale de $a\\times 10^x$',
20
+ label: "Passer d'écriture scientifique à écriture décimal",
21
21
  levels: [
22
22
  '5ème',
23
23
  '4ème',
@@ -40,25 +40,24 @@ exports.scientificToDecimal = {
40
40
  freeTimer: 60,
41
41
  };
42
42
  function getScientificToDecimalQuestion() {
43
- const randPower = (0, randint_1.randint)(-6, 8);
44
- const int = integer_1.IntegerConstructor.random((0, randint_1.randint)(1, 4), [0]);
45
- const fracPart = decimal_1.DecimalConstructor.randomFracPart((0, randint_1.randint)(0, 4));
46
- const randDecimal = decimal_1.DecimalConstructor.fromParts(int + '', fracPart);
47
- const statement = new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(randDecimal.value), new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(randPower)));
48
- const answerTree = randDecimal.multiplyByPowerOfTen(randPower).toTree();
43
+ const decScientific = decimal_1.DecimalConstructor.randomScientific((0, randint_1.randint)(1, 4));
44
+ const tenPower = (0, randint_1.randint)(-5, 6, [0, 1]);
45
+ const answer = decScientific.multiplyByPowerOfTen(tenPower).toTree().toTex();
46
+ const statement = new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(decScientific.value), new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(tenPower)));
49
47
  const getPropositions = (n) => {
50
48
  const res = [];
51
49
  res.push({
52
50
  id: (0, uuid_1.v4)() + '',
53
- statement: answerTree.toTex(),
51
+ statement: answer,
54
52
  isRightAnswer: true,
55
53
  format: 'tex',
56
54
  });
55
+ (0, exercise_1.tryToAddWrongProp)(res, decScientific.multiplyByPowerOfTen(-tenPower).toTree().toTex());
57
56
  for (let i = 0; i < n - 1; i++) {
58
57
  let isDuplicate;
59
58
  let proposition;
60
59
  do {
61
- const wrongAnswerTree = randDecimal.multiplyByPowerOfTen((0, randint_1.randint)(-6, 8, [randPower])).toTree();
60
+ const wrongAnswerTree = decScientific.multiplyByPowerOfTen((0, randint_1.randint)(-6, 6, [tenPower])).toTree();
62
61
  const wrongAnswer = wrongAnswerTree.toTex();
63
62
  proposition = {
64
63
  id: (0, uuid_1.v4)() + '',
@@ -75,7 +74,7 @@ function getScientificToDecimalQuestion() {
75
74
  const question = {
76
75
  instruction: `Donner l'écriture décimale de : $${statement.toTex()}$`,
77
76
  startStatement: statement.toTex(),
78
- answer: answerTree.toTex(),
77
+ answer: answer,
79
78
  keys: [],
80
79
  getPropositions,
81
80
  answerFormat: 'tex',
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUjE,QAAA,MAAM,gBAAgB,gBAAiB,CAAC;AAExC,QAAA,MAAM,4BAA4B;aACT,WAAW;UAAQ,YAAY,EAAE;GAkBzD,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIjE,QAAA,MAAM,gBAAgB,gBAAiB,CAAC;AAExC,QAAA,MAAM,4BAA4B;aACT,WAAW;UAAQ,YAAY,EAAE;GAkBzD,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,CAAC"}
package/lib/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAllMathExercisesBySection = exports.allMathExercises = void 0;
4
4
  const exercises_1 = require("./exercises/exercises");
5
+ const decimalToScientific_1 = require("./exercises/powers/decimalToScientific");
5
6
  const allMathExercises = [...exercises_1.exercises];
6
7
  exports.allMathExercises = allMathExercises;
7
8
  const getAllMathExercisesBySection = () => {
@@ -23,3 +24,4 @@ const getAllMathExercisesBySection = () => {
23
24
  return data;
24
25
  };
25
26
  exports.getAllMathExercisesBySection = getAllMathExercisesBySection;
27
+ console.log(decimalToScientific_1.decimalToScientific.generator(10).forEach((q) => q.getPropositions(4)));
@@ -1,9 +1,10 @@
1
1
  import { Node } from '../../../tree/nodes/node';
2
2
  import { Nombre, NumberType } from '../nombre';
3
3
  export declare abstract class DecimalConstructor {
4
- static randomFracPart(precision: number): string;
4
+ static randomFracPart(precision: number, leadingZeros?: number): string;
5
5
  static random(min: number, max: number, precision?: number): Decimal;
6
6
  static fromParts(intPart: string, decimalPart: string): Decimal;
7
+ static randomScientific(precision?: number): Decimal;
7
8
  }
8
9
  export declare class Decimal implements Nombre {
9
10
  value: number;
@@ -20,6 +21,8 @@ export declare class Decimal implements Nombre {
20
21
  */
21
22
  round(precision: number): Nombre;
22
23
  multiplyByPowerOfTen(power: number): Decimal;
24
+ toScientificPart(): Node;
25
+ toScientificNotation(): Node;
23
26
  toTree(): Node;
24
27
  }
25
28
  //# sourceMappingURL=decimal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/C,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAQhD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;CAGhE;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;IAoEhC,oBAAoB,CAAC,KAAK,EAAE,MAAM;IAsBlC,gBAAgB,IAAI,IAAI;IAUxB,oBAAoB,IAAI,IAAI;IAgB5B,MAAM,IAAI,IAAI;CAGf"}
@@ -3,13 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Decimal = exports.DecimalConstructor = void 0;
4
4
  const randint_1 = require("../../../math/utils/random/randint");
5
5
  const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
6
+ const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
7
+ const powerNode_1 = require("../../../tree/nodes/operators/powerNode");
6
8
  const integer_1 = require("../integer/integer");
7
9
  const nombre_1 = require("../nombre");
8
10
  class DecimalConstructor {
9
- static randomFracPart(precision) {
11
+ static randomFracPart(precision, leadingZeros = 0) {
10
12
  let decimals = '';
11
13
  for (let i = 0; i < precision; i++) {
12
- decimals += (0, randint_1.randint)(i === precision - 1 ? 1 : 0, 10);
14
+ if (i < leadingZeros)
15
+ decimals += '0';
16
+ if (i === precision - 1 || (i === 0 && !leadingZeros))
17
+ decimals += (0, randint_1.randint)(1, 10);
18
+ else
19
+ decimals += (0, randint_1.randint)(0, 10);
13
20
  }
14
21
  return decimals;
15
22
  }
@@ -22,6 +29,13 @@ class DecimalConstructor {
22
29
  static fromParts(intPart, decimalPart) {
23
30
  return new Decimal(Number('' + intPart + '.' + decimalPart));
24
31
  }
32
+ //returns X.YYYY where X € [0, 9] and first Y is not zero if X is zero
33
+ static randomScientific(precision) {
34
+ let prec = precision ?? (0, randint_1.randint)(1, 4);
35
+ const int = (0, randint_1.randint)(0, 10) + '';
36
+ const decimals = DecimalConstructor.randomFracPart(prec, 0);
37
+ return DecimalConstructor.fromParts(int, decimals);
38
+ }
25
39
  }
26
40
  exports.DecimalConstructor = DecimalConstructor;
27
41
  class Decimal {
@@ -134,6 +148,35 @@ class Decimal {
134
148
  }
135
149
  return DecimalConstructor.fromParts(newIntPart, newFracPart);
136
150
  }
151
+ toScientificPart() {
152
+ const intString = this.intPart.toString();
153
+ const intSize = intString.length;
154
+ if (intSize === 0 && this.intPart !== 0)
155
+ return this.toTree();
156
+ if (this.intPart === 0) {
157
+ const firstNonZeroIndex = this.decimalPart.split('').findIndex((el) => Number(el) !== 0);
158
+ return new numberNode_1.NumberNode(Number('0.' + this.decimalPart.slice(firstNonZeroIndex)));
159
+ }
160
+ return new numberNode_1.NumberNode(Number(intString[0] + '.' + intString.slice(1) + this.decimalPart));
161
+ }
162
+ toScientificNotation() {
163
+ const intString = this.intPart.toString();
164
+ const intSize = intString.length;
165
+ if (intSize === 0)
166
+ return this.toTree();
167
+ const decNode = this.toScientificPart();
168
+ let leadingZeros = 0;
169
+ const nbs = this.decimalPart.split('').map(Number);
170
+ for (let i = 0; i < nbs.length; i++) {
171
+ if (nbs[i] !== 0)
172
+ break;
173
+ leadingZeros++;
174
+ }
175
+ const power = this.intPart === 0 ? -leadingZeros : intSize - 1;
176
+ if (power === 1)
177
+ return new multiplyNode_1.MultiplyNode(decNode, new numberNode_1.NumberNode(10));
178
+ return new multiplyNode_1.MultiplyNode(decNode, new powerNode_1.PowerNode(new numberNode_1.NumberNode(10), new numberNode_1.NumberNode(power)));
179
+ }
137
180
  toTree() {
138
181
  return new numberNode_1.NumberNode(this.value);
139
182
  }
@@ -9,7 +9,7 @@ const rational_1 = require("../rationals/rational");
9
9
  const primes_1 = require("./primes");
10
10
  class IntegerConstructor {
11
11
  static random(nbOfDigits, excludes) {
12
- return (0, randint_1.randint)(0, 10 ** nbOfDigits, excludes);
12
+ return (0, randint_1.randint)(10 ** (nbOfDigits - 1), 10 ** nbOfDigits, excludes);
13
13
  }
14
14
  static randomPrime(max = 20) {
15
15
  return (0, random_1.random)(primes_1.primes.filter((p) => p < 20));
@@ -1 +1 @@
1
- {"version":3,"file":"rational.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/rationals/rational.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB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Z,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,UAAU,CAAC;gBAEL,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAUlD,KAAK;IAIL,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgBvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB5B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAgB1B,QAAQ,IAAI,QAAQ;IAIpB,MAAM,IAAI,IAAI;IAKd,QAAQ,IAAI,MAAM;CAMnB"}
@@ -5,6 +5,7 @@ const coprimesOf_1 = require("../../../math/utils/arithmetic/coprimesOf");
5
5
  const gcd_1 = require("../../../math/utils/arithmetic/gcd");
6
6
  const lcd_1 = require("../../../math/utils/arithmetic/lcd");
7
7
  const randint_1 = require("../../../math/utils/random/randint");
8
+ const oppositeNode_1 = require("../../../tree/nodes/functions/oppositeNode");
8
9
  const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
9
10
  const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
10
11
  const coinFlip_1 = require("../../../utils/coinFlip");
@@ -54,11 +55,11 @@ class Rational {
54
55
  this.denum = denumerator;
55
56
  this.value = numerator / denumerator;
56
57
  this.isSimplified = Math.abs((0, gcd_1.gcd)(numerator, denumerator)) === 1;
57
- this.tex = `\\frac{${this.num}}{${this.denum}}`;
58
+ this.tex = `${this.num < 0 ? '-' : ''}\\frac{${this.num < 0 ? -this.num : this.num}}{${this.denum}}`;
58
59
  this.type = nombre_1.NumberType.Rational;
59
60
  }
60
61
  toTex() {
61
- return `\\frac{${this.num}}{${this.denum}}`;
62
+ return `${this.num < 0 ? '-' : ''}\\frac{${this.num < 0 ? -this.num : this.num}}{${this.denum}}`;
62
63
  }
63
64
  add(nb) {
64
65
  switch (nb.type) {
@@ -110,6 +111,8 @@ class Rational {
110
111
  return new Rational(-this.num, this.denum);
111
112
  }
112
113
  toTree() {
114
+ if (this.num < 0)
115
+ return new oppositeNode_1.OppositeNode(new fractionNode_1.FractionNode(new numberNode_1.NumberNode(-this.num), new numberNode_1.NumberNode(this.denum)));
113
116
  return new fractionNode_1.FractionNode(new numberNode_1.NumberNode(this.num), new numberNode_1.NumberNode(this.denum));
114
117
  }
115
118
  simplify() {
@@ -4,6 +4,7 @@ export declare abstract class PolynomialConstructor {
4
4
  static random(maxOrder: number, variable?: string): Polynomial;
5
5
  static randomWithLength(maxOrder: number, length: number, variable?: string): Polynomial;
6
6
  static randomWithLengthAndSameSigns(maxOrder: number, length: number, variable?: string): Polynomial;
7
+ static randomNoFI(maxOrder: number, to: '+\\infty' | '-\\infty', length?: number, variable?: string): Polynomial;
7
8
  }
8
9
  export declare class Polynomial {
9
10
  degree: number;
@@ -1 +1 @@
1
- {"version":3,"file":"polynomial.d.ts","sourceRoot":"","sources":["../../../src/math/polynomials/polynomial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAW7C,8BAAsB,qBAAqB;IACzC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAa5D,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IActD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;IAmBhF,MAAM,CAAC,4BAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAY;CAmB7F;AAED,qBAAa,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;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,qBAAa,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAY;IAS1D,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO;IAG9B,QAAQ,IAAI,MAAM,EAAE;IA8BpB,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAc9B,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAM7B,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU;IAkBnC,QAAQ,IAAI,UAAU;IAOtB,QAAQ,IAAI,UAAU;IAQtB,SAAS,IAAI,UAAU;IAMvB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAM5B,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM;IAiB7C,MAAM,IAAI,IAAI;IAmCd,KAAK,IAAI,MAAM;IAkBf,QAAQ,IAAI,MAAM;CAGnB"}
@@ -72,6 +72,31 @@ class PolynomialConstructor {
72
72
  coefficients.push(sign * (0, randint_1.randint)(0, 10, [0]));
73
73
  return new Polynomial(coefficients, variable);
74
74
  }
75
+ static randomNoFI(maxOrder, to, length, variable = 'x') {
76
+ if (maxOrder < 0) {
77
+ throw Error('Order must be a non-negative integer');
78
+ }
79
+ const order = (0, randint_1.randint)(1, maxOrder + 1);
80
+ const fixedLength = length ?? order;
81
+ if (to === '+\\infty') {
82
+ return PolynomialConstructor.randomWithLengthAndSameSigns(maxOrder, fixedLength, variable);
83
+ }
84
+ //en -infini les degrés de parité différentes doivent avoir un signe différent
85
+ const coefficients = [];
86
+ const otherTermDegrees = [];
87
+ const signEven = (0, coinFlip_1.coinFlip)() ? 1 : -1;
88
+ for (let i = 0; i < fixedLength - 1; i++) {
89
+ otherTermDegrees.push((0, randint_1.randint)(0, order));
90
+ }
91
+ for (let i = 0; i <= order - 1; i++) {
92
+ if (otherTermDegrees.includes(i))
93
+ coefficients.push((i % 2 === 0 ? signEven : -signEven) * (0, randint_1.randint)(0, 10, [0]));
94
+ else
95
+ coefficients.push(0);
96
+ }
97
+ coefficients.push((order % 2 === 0 ? signEven : -signEven) * (0, randint_1.randint)(0, 10, [0]));
98
+ return new Polynomial(coefficients, variable);
99
+ }
75
100
  }
76
101
  exports.PolynomialConstructor = PolynomialConstructor;
77
102
  class Polynomial {
@@ -0,0 +1,2 @@
1
+ export declare const probaFlip: (n: number) => boolean;
2
+ //# sourceMappingURL=probaFlip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probaFlip.d.ts","sourceRoot":"","sources":["../../src/utils/probaFlip.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,MAAO,MAAM,YAElC,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.probaFlip = void 0;
4
+ const probaFlip = (n) => {
5
+ return Math.random() < n;
6
+ };
7
+ exports.probaFlip = probaFlip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [