math-exercises 1.4.7 → 1.4.9

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 (87) hide show
  1. package/lib/exercises/exercises.d.ts.map +1 -1
  2. package/lib/exercises/exercises.js +6 -0
  3. package/lib/exercises/probaStat/ballsBasicProbas.d.ts +4 -0
  4. package/lib/exercises/probaStat/ballsBasicProbas.d.ts.map +1 -0
  5. package/lib/exercises/probaStat/ballsBasicProbas.js +70 -0
  6. package/lib/exercises/probaStat/cardBasicProbas.d.ts +4 -0
  7. package/lib/exercises/probaStat/cardBasicProbas.d.ts.map +1 -0
  8. package/lib/exercises/probaStat/cardBasicProbas.js +103 -0
  9. package/lib/exercises/probaStat/diceBasicProbas.d.ts +4 -0
  10. package/lib/exercises/probaStat/diceBasicProbas.d.ts.map +1 -0
  11. package/lib/exercises/probaStat/diceBasicProbas.js +77 -0
  12. package/lib/exercises/utils/cardsData.d.ts +22 -0
  13. package/lib/exercises/utils/cardsData.d.ts.map +1 -0
  14. package/lib/exercises/utils/cardsData.js +26 -0
  15. package/lib/utils/enumToArray.d.ts +8 -0
  16. package/lib/utils/enumToArray.d.ts.map +1 -0
  17. package/lib/utils/enumToArray.js +16 -0
  18. package/lib/utils/probaFlip.d.ts +5 -0
  19. package/lib/utils/probaFlip.d.ts.map +1 -1
  20. package/lib/utils/probaFlip.js +5 -0
  21. package/lib/utils/probaLawFlip.d.ts +2 -0
  22. package/lib/utils/probaLawFlip.d.ts.map +1 -0
  23. package/lib/utils/probaLawFlip.js +19 -0
  24. package/lib/utils/randomEnumValue.d.ts +2 -0
  25. package/lib/utils/randomEnumValue.d.ts.map +1 -0
  26. package/lib/utils/randomEnumValue.js +9 -0
  27. package/package.json +1 -1
  28. package/lib/exercises/calculLitteral/equation/evaluateExpression.d.ts +0 -4
  29. package/lib/exercises/calculLitteral/equation/evaluateExpression.d.ts.map +0 -1
  30. package/lib/exercises/calculLitteral/equation/evaluateExpression.js +0 -61
  31. package/lib/exercises/calculLitteral/equation/firstDegreeGeneralEquation.d.ts +0 -4
  32. package/lib/exercises/calculLitteral/equation/firstDegreeGeneralEquation.d.ts.map +0 -1
  33. package/lib/exercises/calculLitteral/equation/firstDegreeGeneralEquation.js +0 -32
  34. package/lib/exercises/functions/affines/template.d.ts +0 -4
  35. package/lib/exercises/functions/affines/template.d.ts.map +0 -1
  36. package/lib/exercises/functions/affines/template.js +0 -51
  37. package/lib/exercises/geometry/cartesian/imageFunction.d.ts +0 -4
  38. package/lib/exercises/geometry/cartesian/imageFunction.d.ts.map +0 -1
  39. package/lib/exercises/geometry/cartesian/imageFunction.js +0 -65
  40. package/lib/exercises/geometry/cartesian/imageFunctionGeogebra.d.ts +0 -4
  41. package/lib/exercises/geometry/cartesian/imageFunctionGeogebra.d.ts.map +0 -1
  42. package/lib/exercises/geometry/cartesian/imageFunctionGeogebra.js +0 -89
  43. package/lib/exercises/geometry/cartesian/inverseImageFunction.d.ts +0 -4
  44. package/lib/exercises/geometry/cartesian/inverseImageFunction.d.ts.map +0 -1
  45. package/lib/exercises/geometry/cartesian/inverseImageFunction.js +0 -62
  46. package/lib/exercises/geometry/cartesian/inverseImageFunctionGeogebra.d.ts +0 -4
  47. package/lib/exercises/geometry/cartesian/inverseImageFunctionGeogebra.d.ts.map +0 -1
  48. package/lib/exercises/geometry/cartesian/inverseImageFunctionGeogebra.js +0 -154
  49. package/lib/exercises/geometry/cartesian/leadingCoefficient.d.ts +0 -4
  50. package/lib/exercises/geometry/cartesian/leadingCoefficient.d.ts.map +0 -1
  51. package/lib/exercises/geometry/cartesian/leadingCoefficient.js +0 -93
  52. package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV1.d.ts +0 -4
  53. package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV1.d.ts.map +0 -1
  54. package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV1.js +0 -59
  55. package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV2.d.ts +0 -4
  56. package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV2.d.ts.map +0 -1
  57. package/lib/exercises/geometry/cartesian/leadingCoefficientCalculV2.js +0 -58
  58. package/lib/exercises/geometry/cartesian/signFunction.d.ts +0 -4
  59. package/lib/exercises/geometry/cartesian/signFunction.d.ts.map +0 -1
  60. package/lib/exercises/geometry/cartesian/signFunction.js +0 -84
  61. package/lib/exercises/limits/polynomeLimit.d.ts +0 -4
  62. package/lib/exercises/limits/polynomeLimit.d.ts.map +0 -1
  63. package/lib/exercises/limits/polynomeLimit.js +0 -134
  64. package/lib/exercises/proba/conditionalProbability.d.ts +0 -4
  65. package/lib/exercises/proba/conditionalProbability.d.ts.map +0 -1
  66. package/lib/exercises/proba/conditionalProbability.js +0 -99
  67. package/lib/exercises/proba/marginalAndConditionalFrequency.d.ts +0 -4
  68. package/lib/exercises/proba/marginalAndConditionalFrequency.d.ts.map +0 -1
  69. package/lib/exercises/proba/marginalAndConditionalFrequency.js +0 -106
  70. package/lib/exercises/proba/probabilityTree.d.ts +0 -4
  71. package/lib/exercises/proba/probabilityTree.d.ts.map +0 -1
  72. package/lib/exercises/proba/probabilityTree.js +0 -132
  73. package/lib/exercises/probaStat/frequencyTable.d.ts +0 -4
  74. package/lib/exercises/probaStat/frequencyTable.d.ts.map +0 -1
  75. package/lib/exercises/probaStat/frequencyTable.js +0 -76
  76. package/lib/exercises/sequences/arithmetic/arithmeticSum.d.ts +0 -1
  77. package/lib/exercises/sequences/arithmetic/arithmeticSum.d.ts.map +0 -1
  78. package/lib/exercises/sequences/arithmetic/arithmeticSum.js +0 -1
  79. package/lib/exercises/sets/intervalsUnion.d.ts +0 -4
  80. package/lib/exercises/sets/intervalsUnion.d.ts.map +0 -1
  81. package/lib/exercises/sets/intervalsUnion.js +0 -55
  82. package/lib/exercises/utils/sum.test.d.ts +0 -2
  83. package/lib/exercises/utils/sum.test.d.ts.map +0 -1
  84. package/lib/exercises/utils/sum.test.js +0 -22
  85. package/lib/math/numbers/reals/squareRoot.d.ts +0 -19
  86. package/lib/math/numbers/reals/squareRoot.d.ts.map +0 -1
  87. package/lib/math/numbers/reals/squareRoot.js +0 -63
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFrequencyTable = exports.frequencyTable = void 0;
4
- const randint_1 = require("../../math/utils/random/randint");
5
- const round_1 = require("../../math/utils/round");
6
- const shuffle_1 = require("../../utils/shuffle");
7
- const getDistinctQuestions_1 = require("../utils/getDistinctQuestions");
8
- const uuid_1 = require("uuid");
9
- exports.frequencyTable = {
10
- id: 'frequencyTable',
11
- connector: '=',
12
- instruction: '',
13
- label: "Calcul de la moyenne d'une série de valeurs",
14
- levels: ['3ème', '2nde'],
15
- isSingleStep: false,
16
- sections: ['Statistiques'],
17
- generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getFrequencyTable, nb),
18
- keys: [],
19
- };
20
- function getFrequencyTable() {
21
- const getRandomUniqueValues = (count, min, max) => {
22
- const uniqueValues = new Set();
23
- while (uniqueValues.size < count) {
24
- uniqueValues.add((0, randint_1.randint)(min, max));
25
- }
26
- return Array.from(uniqueValues).sort((a, b) => a - b);
27
- };
28
- const randomValeurs = getRandomUniqueValues(5, 1, 20);
29
- const randomEffectives = [1, 2, 3, 4, 5].map((el) => (0, randint_1.randint)(1, 6));
30
- const sumEffectives = randomEffectives.reduce((sum, value) => sum + value, 0);
31
- let average = 0;
32
- for (let i = 0; i < randomValeurs.length; i++)
33
- average += randomValeurs[i] * randomEffectives[i];
34
- average /= sumEffectives;
35
- average = (0, round_1.round)(average, 2);
36
- const getPropositions = (n) => {
37
- const res = [];
38
- res.push({
39
- id: (0, uuid_1.v4)() + '',
40
- statement: average + '',
41
- isRightAnswer: true,
42
- format: 'tex',
43
- });
44
- for (let i = 0; i < n - 1; i++) {
45
- let isDuplicate;
46
- let proposition;
47
- do {
48
- proposition = {
49
- id: (0, uuid_1.v4)() + '',
50
- statement: (0, round_1.round)(average + (0, randint_1.randint)(-average, 20 - average, [0]) + (0, randint_1.randint)(1, 100) / 100, 2) + '',
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, shuffle_1.shuffle)(res);
59
- };
60
- const question = {
61
- instruction: `On considère le tableau d'effectifs suivant :
62
-
63
- | | | | | | |
64
- |-|-|-|-|-|-|
65
- |Valeur|${randomValeurs[0]}|${randomValeurs[1]}|${randomValeurs[2]}|${randomValeurs[3]}|${randomValeurs[4]}|
66
- |Effectif|${randomEffectives[0]}|${randomEffectives[1]}|${randomEffectives[2]}|${randomEffectives[3]}|${randomEffectives[4]}|
67
-
68
- Calculer la moyenne de cette série de valeurs.`,
69
- answer: average + '',
70
- keys: [],
71
- getPropositions,
72
- answerFormat: 'tex',
73
- };
74
- return question;
75
- }
76
- exports.getFrequencyTable = getFrequencyTable;
@@ -1 +0,0 @@
1
- //# sourceMappingURL=arithmeticSum.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"arithmeticSum.d.ts","sourceRoot":"","sources":["../../../../src/exercises/sequences/arithmetic/arithmeticSum.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,4 +0,0 @@
1
- import { Exercise, Question } from '../../exercises/exercise';
2
- export declare const intervalsUnion: Exercise;
3
- export declare function getIntervalsUnionQuestion(): Question;
4
- //# sourceMappingURL=intervalsUnion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intervalsUnion.d.ts","sourceRoot":"","sources":["../../../src/exercises/sets/intervalsUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAK3E,eAAO,MAAM,cAAc,EAAE,QAW5B,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,QAAQ,CA2CpD"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIntervalsUnionQuestion = exports.intervalsUnion = void 0;
4
- const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
5
- const shuffle_1 = require("../../utils/shuffle");
6
- const uuid_1 = require("uuid");
7
- exports.intervalsUnion = {
8
- id: 'intervalsUnion',
9
- connector: '=',
10
- instruction: '',
11
- label: "Déterminer l'union de deux intervalles",
12
- levels: ['2nde', '2ndPro', '1reTech', 'CAP'],
13
- isSingleStep: true,
14
- sections: ['Intervalles'],
15
- generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getIntervalsUnionQuestion, nb),
16
- qcmTimer: 60,
17
- freeTimer: 60,
18
- };
19
- function getIntervalsUnionQuestion() {
20
- const getPropositions = (n) => {
21
- const res = [];
22
- res.push({
23
- id: (0, uuid_1.v4)(),
24
- statement: ``,
25
- isRightAnswer: true,
26
- format: 'tex',
27
- });
28
- const missing = n - res.length;
29
- for (let i = 0; i < missing; i++) {
30
- let isDuplicate;
31
- let proposition;
32
- do {
33
- const wrongAnswer = '';
34
- proposition = {
35
- id: (0, uuid_1.v4)() + ``,
36
- statement: wrongAnswer,
37
- isRightAnswer: false,
38
- format: 'tex',
39
- };
40
- isDuplicate = res.some((p) => p.statement === proposition.statement);
41
- } while (isDuplicate);
42
- res.push(proposition);
43
- }
44
- return (0, shuffle_1.shuffle)(res);
45
- };
46
- const question = {
47
- answer: ``,
48
- instruction: ``,
49
- keys: [],
50
- getPropositions,
51
- answerFormat: 'tex',
52
- };
53
- return question;
54
- }
55
- exports.getIntervalsUnionQuestion = getIntervalsUnionQuestion;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=sum.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sum.test.d.ts","sourceRoot":"","sources":["../../../src/exercises/utils/sum.test.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const exercises_1 = require("../exercises");
4
- test('all exos', () => {
5
- console.log(exercises_1.exercises.length);
6
- exercises_1.exercises.forEach((exo) => {
7
- console.log(exo.id);
8
- try {
9
- expect(exo.sections.length).not.toBe(0);
10
- expect(exo.levels.length).not.toBe(0);
11
- const questions = exo.generator(30);
12
- questions.forEach((question) => {
13
- const props = question.getPropositions(4);
14
- expect(props.length).toBe(4);
15
- expect(props.filter((prop) => prop.isRightAnswer).length).toBe(1);
16
- });
17
- }
18
- catch (err) {
19
- console.log(exo.id);
20
- }
21
- });
22
- });
@@ -1,19 +0,0 @@
1
- import { Node } from '../../../tree/nodes/node';
2
- import { Real } from './real';
3
- export declare abstract class SquareRootConstructor {
4
- /**
5
- * @returns simplifiable square root type sqrt(c)=a*sqrt(b)
6
- */
7
- static randomSimplifiable({ allowPerfectSquare, maxSquare }: {
8
- allowPerfectSquare?: boolean | undefined;
9
- maxSquare?: number | undefined;
10
- }): SquareRoot;
11
- }
12
- export declare class SquareRoot extends Real {
13
- operand: number;
14
- constructor(operand: number);
15
- simplify(): Real;
16
- toTex(): string;
17
- toTree(): Node;
18
- }
19
- //# sourceMappingURL=squareRoot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"squareRoot.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/reals/squareRoot.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAG7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,8BAAsB,qBAAqB;IACzC;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,EAAE,kBAA0B,EAAE,SAAc,EAAE;;;KAAA,GAAG,UAAU;CAStF;AAED,qBAAa,UAAW,SAAQ,IAAI;IAClC,OAAO,EAAE,MAAM,CAAC;gBACJ,OAAO,EAAE,MAAM;IAK3B,QAAQ,IAAI,IAAI;IA+BhB,KAAK,IAAI,MAAM;IAIf,MAAM,IAAI,IAAI;CAGf"}
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SquareRoot = exports.SquareRootConstructor = void 0;
4
- const isSquare_1 = require("../../../math/utils/arithmetic/isSquare");
5
- const primeFactors_1 = require("../../../math/utils/arithmetic/primeFactors");
6
- const randint_1 = require("../../../math/utils/random/randint");
7
- const sqrtNode_1 = require("../../../tree/nodes/functions/sqrtNode");
8
- const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
9
- const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
10
- const real_1 = require("./real");
11
- class SquareRootConstructor {
12
- /**
13
- * @returns simplifiable square root type sqrt(c)=a*sqrt(b)
14
- */
15
- static randomSimplifiable({ allowPerfectSquare = false, maxSquare = 11 }) {
16
- const a = (0, randint_1.randint)(2, maxSquare);
17
- let b;
18
- let bMin = allowPerfectSquare ? 1 : 2;
19
- do {
20
- b = (0, randint_1.randint)(bMin, maxSquare);
21
- } while (b % (a * a) === 0 || (0, isSquare_1.isSquare)(b));
22
- return new SquareRoot(a * a * b);
23
- }
24
- }
25
- exports.SquareRootConstructor = SquareRootConstructor;
26
- class SquareRoot extends real_1.Real {
27
- constructor(operand) {
28
- super(Math.sqrt(operand), `\\sqrt{${operand}}`);
29
- this.operand = operand;
30
- }
31
- simplify() {
32
- const factors = (0, primeFactors_1.primeFactors)(this.operand);
33
- // finds primes with even exponents
34
- const multiples = [1];
35
- for (let i = 0; i < factors.length - 1; i++) {
36
- if (factors[i] === factors[i + 1]) {
37
- multiples.push(factors[i]);
38
- factors.splice(i, 2);
39
- i--;
40
- }
41
- }
42
- const outsideSqrt = multiples.reduce((x, y) => x * y);
43
- const insideSqrt = factors.length === 0 ? 1 : factors.reduce((x, y) => x * y);
44
- const simplified = insideSqrt !== 1
45
- ? new real_1.Real(outsideSqrt * Math.sqrt(insideSqrt), `${outsideSqrt === 1 ? '' : `${outsideSqrt}`}\\sqrt{${insideSqrt}}`)
46
- : new real_1.Real(outsideSqrt, outsideSqrt + '');
47
- simplified.toTree = () => {
48
- return insideSqrt !== 1
49
- ? outsideSqrt === 1
50
- ? new sqrtNode_1.SqrtNode(new numberNode_1.NumberNode(insideSqrt))
51
- : new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(outsideSqrt), new sqrtNode_1.SqrtNode(new numberNode_1.NumberNode(insideSqrt)))
52
- : new numberNode_1.NumberNode(outsideSqrt);
53
- };
54
- return simplified;
55
- }
56
- toTex() {
57
- return this.tex;
58
- }
59
- toTree() {
60
- return new sqrtNode_1.SqrtNode(new numberNode_1.NumberNode(this.operand));
61
- }
62
- }
63
- exports.SquareRoot = SquareRoot;