math-exercises 3.0.78 → 3.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/lib/exercises/math/calcul/arithmetics/getParityBetweenTwoNumbers.js +1 -1
  2. package/lib/exercises/math/calcul/arithmetics/index.d.ts +2 -0
  3. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  4. package/lib/exercises/math/calcul/arithmetics/index.js +2 -0
  5. package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.d.ts +11 -0
  6. package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.d.ts.map +1 -0
  7. package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.js +133 -0
  8. package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.d.ts +9 -0
  9. package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.d.ts.map +1 -0
  10. package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.js +174 -0
  11. package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
  12. package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/fractions/index.js +1 -0
  14. package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.d.ts +8 -0
  15. package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.d.ts.map +1 -0
  16. package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.js +104 -0
  17. package/lib/exercises/math/calcul/index.d.ts +1 -0
  18. package/lib/exercises/math/calcul/index.d.ts.map +1 -1
  19. package/lib/exercises/math/calcul/index.js +1 -0
  20. package/lib/exercises/math/calcul/rationals/index.d.ts +2 -0
  21. package/lib/exercises/math/calcul/rationals/index.d.ts.map +1 -0
  22. package/lib/exercises/math/calcul/rationals/index.js +1 -0
  23. package/lib/exercises/math/calcul/rationals/rationalNumbers.d.ts +11 -0
  24. package/lib/exercises/math/calcul/rationals/rationalNumbers.d.ts.map +1 -0
  25. package/lib/exercises/math/calcul/rationals/rationalNumbers.js +185 -0
  26. package/lib/exercises/math/dataRepresentations/index.js +1 -0
  27. package/lib/exercises/math/probaStat/averageLinearity.d.ts +16 -0
  28. package/lib/exercises/math/probaStat/averageLinearity.d.ts.map +1 -0
  29. package/lib/exercises/math/probaStat/averageLinearity.js +217 -0
  30. package/lib/exercises/math/probaStat/cumulativeSum.d.ts +9 -0
  31. package/lib/exercises/math/probaStat/cumulativeSum.d.ts.map +1 -0
  32. package/lib/exercises/math/probaStat/cumulativeSum.js +105 -0
  33. package/lib/exercises/math/probaStat/describeEvent.d.ts +15 -0
  34. package/lib/exercises/math/probaStat/describeEvent.d.ts.map +1 -0
  35. package/lib/exercises/math/probaStat/describeEvent.js +182 -0
  36. package/lib/exercises/math/probaStat/getSampleCountAndSize.d.ts +9 -0
  37. package/lib/exercises/math/probaStat/getSampleCountAndSize.d.ts.map +1 -0
  38. package/lib/exercises/math/probaStat/getSampleCountAndSize.js +95 -0
  39. package/lib/exercises/math/probaStat/index.d.ts +4 -0
  40. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  41. package/lib/exercises/math/probaStat/index.js +4 -0
  42. package/lib/index.d.ts +44 -0
  43. package/lib/index.d.ts.map +1 -1
  44. package/lib/math/numbers/decimals/decimal.d.ts +1 -1
  45. package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
  46. package/lib/math/numbers/decimals/decimal.js +5 -5
  47. package/lib/tree/nodes/numbers/numberNode.d.ts +3 -1
  48. package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
  49. package/lib/tree/nodes/numbers/numberNode.js +34 -2
  50. package/package.json +1 -1
@@ -0,0 +1,182 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { coinFlip } from "../../../utils/alea/coinFlip.js";
4
+ import { random } from "../../../utils/alea/random.js";
5
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
6
+ const getPropositions = (n, { answer, eventA, eventB, question }) => {
7
+ const propositions = [];
8
+ addValidProp(propositions, answer, "raw");
9
+ const flipComplement = (event) => ({
10
+ desc: event.desc,
11
+ isComplementary: !event.isComplementary,
12
+ });
13
+ const generateWrongAnswer = () => {
14
+ const templates = [
15
+ () => {
16
+ const descA = flipComplement(eventA).isComplementary
17
+ ? `ne pas ${eventA.desc}`
18
+ : eventA.desc;
19
+ const descB = eventB.isComplementary
20
+ ? `ne pas ${eventB.desc}`
21
+ : eventB.desc;
22
+ return `${descA} et ${descB}`;
23
+ },
24
+ () => {
25
+ const descA = eventA.isComplementary
26
+ ? `ne pas ${eventA.desc}`
27
+ : eventA.desc;
28
+ const descB = flipComplement(eventB).isComplementary
29
+ ? `ne pas ${eventB.desc}`
30
+ : eventB.desc;
31
+ return `${descA} ou ${descB}`;
32
+ },
33
+ () => {
34
+ const descA = flipComplement(eventA).isComplementary
35
+ ? `ne pas ${eventA.desc}`
36
+ : eventA.desc;
37
+ const descB = flipComplement(eventB).isComplementary
38
+ ? `ne pas ${eventB.desc}`
39
+ : eventB.desc;
40
+ const op = coinFlip() ? "et" : "ou";
41
+ return `${descA} ${op} ${descB}`;
42
+ },
43
+ () => {
44
+ const descA1 = eventA.isComplementary
45
+ ? `ne pas ${eventA.desc}`
46
+ : eventA.desc;
47
+ const descA2 = flipComplement(eventA).isComplementary
48
+ ? `ne pas ${eventA.desc}`
49
+ : eventA.desc;
50
+ const op = coinFlip() ? "et" : "ou";
51
+ return `${descA1} ${op} ${descA2}`;
52
+ },
53
+ () => {
54
+ return `ne pas ne pas ${eventA.desc}`.replace("ne pas ne pas", eventA.desc);
55
+ },
56
+ ];
57
+ return random(templates)();
58
+ };
59
+ while (propositions.length < n) {
60
+ const wrong = generateWrongAnswer();
61
+ tryToAddWrongProp(propositions, wrong, "raw");
62
+ }
63
+ return shuffleProps(propositions, n);
64
+ };
65
+ const getAnswer = ({ eventA, eventB, question }) => {
66
+ const describe = (e) => e.isComplementary ? `ne pas ${e.desc}` : `${e.desc}`;
67
+ if (question === "comp") {
68
+ return `ne pas ${eventA.desc}`;
69
+ }
70
+ else if (question === "union") {
71
+ return `${describe(eventA)} ou ${describe(eventB)}`;
72
+ }
73
+ else {
74
+ return `${describe(eventA)} et ${describe(eventB)}`;
75
+ }
76
+ };
77
+ const getInstruction = (identifiers) => {
78
+ const { eventA, eventB, question } = identifiers;
79
+ let instruction = `$A$ est l'évènement "${eventA.desc}" et $B$ est l'évènement "${eventB.desc}".\n\n`;
80
+ if (question === "comp") {
81
+ return instruction + `Décrire par une phrase l'évènement $\\overline{A}$.`;
82
+ }
83
+ const overlineA = eventA.isComplementary ? "\\overline{A}" : "A";
84
+ const overlineB = eventB.isComplementary ? "\\overline{B}" : "B";
85
+ const operator = question === "union" ? "\\cup" : "\\cap";
86
+ return (instruction +
87
+ `Décrire par une phrase l'évènement $${overlineA} ${operator} ${overlineB}$.`);
88
+ };
89
+ const getHint = ({ question }) => {
90
+ switch (question) {
91
+ case "comp":
92
+ return `Le contraire ($\\overline{A})$ d'un évènement $A$ signifie que l'évènement ne se réalise pas.`;
93
+ case "union":
94
+ return `L'union ($\\cup$) de deux événements signifie que l'un ou l'autre des évènements (ou les deux) se réalisent.`;
95
+ case "intersection":
96
+ return `L'intersection ($\\cap$) de deux événements signifie que les deux évènements se réalisent en même temps.`;
97
+ default:
98
+ return "";
99
+ }
100
+ };
101
+ const getCorrection = (identifiers) => {
102
+ const { eventA, eventB, question } = identifiers;
103
+ const answer = getAnswer(identifiers);
104
+ if (question === "comp") {
105
+ return `Le contraire de l'évènement "${eventA.desc}" est l'évènement "${answer}".`;
106
+ }
107
+ else if (question === "union") {
108
+ return `L'union signifie que l'un ou l'autre (ou les deux) évènement(s) se produit : "${answer}".`;
109
+ }
110
+ else {
111
+ return `L'intersection signifie que les deux évènements se produisent en même temps : "${answer}".`;
112
+ }
113
+ };
114
+ const getKeys = (identifiers) => {
115
+ return [];
116
+ };
117
+ const isAnswerValid = (ans, { answer }) => {
118
+ try {
119
+ throw Error("VEA not implemented");
120
+ }
121
+ catch (err) {
122
+ return handleVEAError(err);
123
+ }
124
+ };
125
+ const getDescribeEventQuestion = (ops) => {
126
+ const allEvents = [
127
+ "trouver des mures",
128
+ "trouver des fraises",
129
+ "trouver des pommes",
130
+ "perdre son parapluie",
131
+ "rater le bus",
132
+ "avoir un bonbon",
133
+ "avoir un bonbon au chocolat",
134
+ "avoir un bonbon à la menthe",
135
+ "avoir un bonbon à la fraise",
136
+ ];
137
+ const eventA = {
138
+ desc: random(allEvents),
139
+ isComplementary: coinFlip(),
140
+ };
141
+ const eventB = {
142
+ desc: random(allEvents.filter((e) => e !== eventA.desc)),
143
+ isComplementary: coinFlip(),
144
+ };
145
+ const questionTypes = [
146
+ "union",
147
+ "intersection",
148
+ "comp",
149
+ ];
150
+ const question = random(questionTypes);
151
+ const identifiers = { eventA, eventB, question };
152
+ return getQuestionFromIdentifiers(identifiers);
153
+ };
154
+ const getQuestionFromIdentifiers = (identifiers) => {
155
+ return {
156
+ answer: getAnswer(identifiers),
157
+ instruction: getInstruction(identifiers),
158
+ keys: getKeys(identifiers),
159
+ answerFormat: "raw",
160
+ identifiers,
161
+ hint: getHint(identifiers),
162
+ correction: getCorrection(identifiers),
163
+ };
164
+ };
165
+ export const describeEvent = {
166
+ id: "describeEvent",
167
+ label: "Décrire un évènement en une phrase à partir de sa notation",
168
+ isSingleStep: true,
169
+ generator: (nb, opts) => getDistinctQuestions(() => getDescribeEventQuestion(opts), nb),
170
+ qcmTimer: 60,
171
+ freeTimer: 60,
172
+ getPropositions,
173
+ isAnswerValid,
174
+ subject: "Mathématiques",
175
+ getInstruction,
176
+ getHint,
177
+ getCorrection,
178
+ getAnswer,
179
+ getQuestionFromIdentifiers,
180
+ hasHintAndCorrection: true,
181
+ answerType: "QCU",
182
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ expCount: number;
4
+ repCount: number;
5
+ isSize: boolean;
6
+ };
7
+ export declare const getSampleCountAndSize: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=getSampleCountAndSize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSampleCountAndSize.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/getSampleCountAndSize.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AA4FF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAiBvD,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../math/utils/random/randint.js";
4
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
5
+ import { coinFlip } from "../../../utils/alea/coinFlip.js";
6
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
7
+ const getPropositions = (n, { answer, expCount, isSize, repCount }) => {
8
+ const propositions = [];
9
+ addValidProp(propositions, answer);
10
+ tryToAddWrongProp(propositions, expCount.frenchify());
11
+ tryToAddWrongProp(propositions, repCount.frenchify());
12
+ while (propositions.length < n) {
13
+ let wrongValue;
14
+ wrongValue = randint(1, 200);
15
+ tryToAddWrongProp(propositions, wrongValue.frenchify());
16
+ }
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { expCount, repCount, isSize } = identifiers;
21
+ const answer = isSize ? expCount.frenchify() : repCount.frenchify();
22
+ return answer;
23
+ };
24
+ const getInstruction = (identifiers) => {
25
+ const { expCount, repCount, isSize } = identifiers;
26
+ const qst = isSize
27
+ ? "Quelle est la taille de chaque échantillon ?"
28
+ : "Quel est le nombre d'échantillons obtenus?";
29
+ return `On lance $${expCount}$ fois trois pièces simultanément.\n\n
30
+ On répète l'expérience $${repCount}$ fois.\n\n
31
+ ${qst}`;
32
+ };
33
+ const getHint = ({ isSize }) => {
34
+ return isSize
35
+ ? `La taille d'un échantillon correspond au nombre de répétitions à l'intérieur d'une même expérience.`
36
+ : `Le nombre d'échantillons correspond au nombre de fois qu'on répète l'expérience entière.`;
37
+ };
38
+ const getCorrection = ({ expCount, repCount, isSize, }) => {
39
+ if (isSize) {
40
+ return `Chaque fois qu'on répète l'expérience, on lance $${expCount}$ fois trois pièces.
41
+ La taille de chaque échantillon est donc $${expCount}$.`;
42
+ }
43
+ else {
44
+ return `On répète l'expérience complète $${repCount}$ fois.
45
+ On obtient donc $${repCount}$ échantillons.`;
46
+ }
47
+ };
48
+ const getKeys = (identifiers) => {
49
+ return [];
50
+ };
51
+ const isAnswerValid = (ans, { answer }) => {
52
+ try {
53
+ const ansNode = parseAlgebraic(ans);
54
+ const answerNode = parseAlgebraic(answer);
55
+ return answerNode.simplify().equals(ansNode.simplify());
56
+ }
57
+ catch (err) {
58
+ return handleVEAError(err);
59
+ }
60
+ };
61
+ const getGetSampleCountAndSizeQuestion = (ops) => {
62
+ const expCount = randint(1, 301);
63
+ const repCount = randint(1, 51);
64
+ const isSize = coinFlip();
65
+ const identifiers = { expCount, repCount, isSize };
66
+ return getQuestionFromIdentifiers(identifiers);
67
+ };
68
+ const getQuestionFromIdentifiers = (identifiers) => {
69
+ return {
70
+ answer: getAnswer(identifiers),
71
+ instruction: getInstruction(identifiers),
72
+ keys: getKeys(identifiers),
73
+ answerFormat: "tex",
74
+ identifiers,
75
+ hint: getHint(identifiers),
76
+ correction: getCorrection(identifiers),
77
+ };
78
+ };
79
+ export const getSampleCountAndSize = {
80
+ id: "getSampleCountAndSize",
81
+ label: "Distinguer taille et nombre d'échantillons",
82
+ isSingleStep: true,
83
+ generator: (nb, opts) => getDistinctQuestions(() => getGetSampleCountAndSizeQuestion(opts), nb),
84
+ qcmTimer: 60,
85
+ freeTimer: 60,
86
+ getPropositions,
87
+ isAnswerValid,
88
+ subject: "Mathématiques",
89
+ getInstruction,
90
+ getHint,
91
+ getCorrection,
92
+ getAnswer,
93
+ getQuestionFromIdentifiers,
94
+ hasHintAndCorrection: true,
95
+ };
@@ -1,3 +1,4 @@
1
+ export * from "./averageLinearity.js";
1
2
  export * from "./ballsBasicProbas.js";
2
3
  export * from "./cardBasicProbas.js";
3
4
  export * from "./conditionalProbability.js";
@@ -18,4 +19,7 @@ export * from "./unionIntersectionProba.js";
18
19
  export * from "./calculateMeanFromFrequencies.js";
19
20
  export * from "./mostLeastProbable.js";
20
21
  export * from "./checkEquiprobability.js";
22
+ export * from "./getSampleCountAndSize.js";
23
+ export * from "./describeEvent.js";
24
+ export * from "./cumulativeSum.js";
21
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from "./averageLinearity.js";
1
2
  export * from "./ballsBasicProbas.js";
2
3
  export * from "./cardBasicProbas.js";
3
4
  export * from "./conditionalProbability.js";
@@ -18,3 +19,6 @@ export * from "./unionIntersectionProba.js";
18
19
  export * from "./calculateMeanFromFrequencies.js";
19
20
  export * from "./mostLeastProbable.js";
20
21
  export * from "./checkEquiprobability.js";
22
+ export * from "./getSampleCountAndSize.js";
23
+ export * from "./describeEvent.js";
24
+ export * from "./cumulativeSum.js";
package/lib/index.d.ts CHANGED
@@ -41,6 +41,11 @@ declare const mathExercises: (Exercise<{
41
41
  n: number;
42
42
  }, {}> | Exercise<{
43
43
  a: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
44
+ }, {}> | Exercise<{
45
+ options: {
46
+ a: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
47
+ isDecimal: boolean;
48
+ }[];
44
49
  }, {}> | Exercise<{
45
50
  a: number;
46
51
  b: number;
@@ -95,6 +100,9 @@ declare const mathExercises: (Exercise<{
95
100
  a: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
96
101
  b: number;
97
102
  c: number;
103
+ }, {}> | Exercise<{
104
+ a: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
105
+ interval: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
98
106
  }, {}> | Exercise<{
99
107
  integerFirst: boolean;
100
108
  integer: number;
@@ -133,6 +141,9 @@ declare const mathExercises: (Exercise<{
133
141
  }> | Exercise<{
134
142
  num: number;
135
143
  denum: number;
144
+ }, {}> | Exercise<{
145
+ num: number;
146
+ denum: number;
136
147
  }, {}> | Exercise<{
137
148
  num: number;
138
149
  denum: number;
@@ -295,6 +306,11 @@ declare const mathExercises: (Exercise<{
295
306
  }, {}> | Exercise<{
296
307
  dec: number;
297
308
  pow: number;
309
+ }, {}> | Exercise<{
310
+ choices: {
311
+ node: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
312
+ irrationalUsed: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers | null;
313
+ }[];
298
314
  }, {}> | Exercise<{
299
315
  a: number;
300
316
  sign: number;
@@ -1738,6 +1754,16 @@ declare const mathExercises: (Exercise<{
1738
1754
  }, {}> | Exercise<{
1739
1755
  kIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
1740
1756
  uCoeffs: number[];
1757
+ }, {}> | Exercise<{
1758
+ kind: "factor";
1759
+ a: number;
1760
+ operator: "multiplication" | "division" | "soustraction" | "addition";
1761
+ factor: number;
1762
+ } | {
1763
+ kind: "series";
1764
+ series: number[];
1765
+ operator: "multiplication" | "division" | "soustraction" | "addition";
1766
+ factor: number;
1741
1767
  }, {}> | Exercise<{
1742
1768
  repartitions: number[];
1743
1769
  colorAskedIndex: number;
@@ -1909,6 +1935,24 @@ declare const mathExercises: (Exercise<{
1909
1935
  total: number;
1910
1936
  distribution: number[];
1911
1937
  observe: boolean;
1938
+ }, {}> | Exercise<{
1939
+ expCount: number;
1940
+ repCount: number;
1941
+ isSize: boolean;
1942
+ }, {}> | Exercise<{
1943
+ eventA: {
1944
+ desc: string;
1945
+ isComplementary: boolean;
1946
+ };
1947
+ eventB: {
1948
+ desc: string;
1949
+ isComplementary: boolean;
1950
+ };
1951
+ question: "union" | "intersection" | "comp";
1952
+ }, {}> | Exercise<{
1953
+ xVals: number[];
1954
+ yVals: number[];
1955
+ x: number;
1912
1956
  }, {}> | Exercise<{
1913
1957
  firstValue: number;
1914
1958
  askedRank: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
@@ -31,7 +31,7 @@ export declare class Decimal implements Nombre {
31
31
  toScientificPart(): number;
32
32
  toScientificNotation(decimals?: number): NumberNode | MultiplyNode;
33
33
  getDigitAtRank(rank: number): number;
34
- toRational(simplify?: boolean): Rational | import("../integer/integer.js").Integer;
34
+ toRational(shouldSimplify?: boolean): Rational | import("../integer/integer.js").Integer;
35
35
  toTree(): NumberNode;
36
36
  toPercentNode(): PercentNode;
37
37
  toLowerBound(tenthPower: number): Decimal;
@@ -1 +1 @@
1
- {"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,eAAO,MAAM,iBAAiB,UAAyC,CAAC;AACxE,8BAAsB,kBAAkB;IACtC,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b,YAAY,CAAC,UAAU,EAAE,MAAM;IAS/B,YAAY,CAAC,UAAU,EAAE,MAAM;CAShC"}
@@ -173,11 +173,11 @@ export class Decimal {
173
173
  return Number(this.decimalPart[-rank - 1]);
174
174
  }
175
175
  }
176
- toRational(simplify) {
177
- const ratio = new Rational(this.multiplyByPowerOfTen(this.precision).value, 10 ** this.precision);
178
- if (simplify)
179
- return ratio.simplify();
180
- return ratio;
176
+ toRational(shouldSimplify = true) {
177
+ const rational = new Rational(this.multiplyByPowerOfTen(this.precision).value, 10 ** this.precision);
178
+ if (shouldSimplify)
179
+ return rational.simplify();
180
+ return rational;
181
181
  }
182
182
  toTree() {
183
183
  return new NumberNode(this.value, this.tex);
@@ -1,6 +1,7 @@
1
1
  import { Node, NodeIds, NodeOptions, NodeType, ToTexOptions } from "../node.js";
2
2
  import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
3
3
  import { OppositeNode } from "../functions/oppositeNode.js";
4
+ import { MultiplyNode } from "../operators/multiplyNode.js";
4
5
  export declare function isNumberNode(a: Node): a is NumberNode;
5
6
  export declare function isNumberOrOppositeNumberNode(a: Node): a is NumberNode | OppositeNode<NumberNode>;
6
7
  export declare abstract class NumberNodeConstructor {
@@ -28,6 +29,7 @@ export declare class NumberNode implements AlgebraicNode {
28
29
  equals(node: AlgebraicNode): boolean;
29
30
  toDetailedEvaluation(vars: Record<string, AlgebraicNode>): this;
30
31
  derivative(varName?: string | undefined): AlgebraicNode;
31
- toFrac(): AlgebraicNode | NumberNode;
32
+ toFrac(shouldSimplify?: boolean): AlgebraicNode | NumberNode;
33
+ toPrimeDecomposition(usePowers?: boolean): AlgebraicNode | this | MultiplyNode;
32
34
  }
33
35
  //# sourceMappingURL=numberNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"numberNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/numbers/numberNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,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CAAC,MAAM,EAAE,MAAM,CAAC;IAGtC,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAQ/C,MAAM,CAAC,IAAI,EAAE,aAAa;IAG1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GACd,aAAa;IAGtC,MAAM,CAAC,cAAc,UAAO;IAI5B,oBAAoB,CAAC,SAAS,CAAC,EAAE,OAAO;CAsBzC"}
@@ -4,6 +4,11 @@ import { colorize } from "../../../utils/latex/colorize.js";
4
4
  import { isOppositeNode } from "../functions/oppositeNode.js";
5
5
  import { Decimal } from "../../../math/numbers/decimals/decimal.js";
6
6
  import { round } from "../../../math/utils/round.js";
7
+ import { isInt } from "../../../utils/isInt.js";
8
+ import { power } from "../operators/powerNode.js";
9
+ import { operatorComposition } from "../../../tree/utilities/operatorComposition.js";
10
+ import { MultiplyNode } from "../operators/multiplyNode.js";
11
+ import { primeDecomposition } from "../../../math/utils/arithmetic/primeDecomposition.js";
7
12
  export function isNumberNode(a) {
8
13
  return a.type === NodeType.number;
9
14
  }
@@ -83,7 +88,34 @@ export class NumberNode {
83
88
  derivative(varName) {
84
89
  return (0).toTree();
85
90
  }
86
- toFrac() {
87
- return new Decimal(this.value).toRational(true).toTree();
91
+ toFrac(shouldSimplify = true) {
92
+ return new Decimal(this.value).toRational(shouldSimplify).toTree();
93
+ }
94
+ toPrimeDecomposition(usePowers) {
95
+ if (!isInt(this.value)) {
96
+ throw new Error("Can't get the prime decomposition of a decimal");
97
+ }
98
+ const decomp = primeDecomposition(this.value);
99
+ if (!decomp.length)
100
+ return this;
101
+ let nodes = [];
102
+ if (usePowers) {
103
+ for (const d of decomp) {
104
+ if (d.power === 1)
105
+ nodes.push(d.value.toTree());
106
+ else
107
+ nodes.push(power(d.value, d.power));
108
+ }
109
+ }
110
+ else {
111
+ for (const d of decomp) {
112
+ for (let i = 0; i < d.power; i++) {
113
+ nodes.push(d.value.toTree());
114
+ }
115
+ }
116
+ }
117
+ if (nodes.length === 1)
118
+ return nodes[0];
119
+ return operatorComposition(MultiplyNode, nodes);
88
120
  }
89
121
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.78",
4
+ "version": "3.0.80",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [