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.
- package/lib/exercises/math/calcul/arithmetics/getParityBetweenTwoNumbers.js +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +2 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +2 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.d.ts +11 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.js +133 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.d.ts +9 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/isNumberInInterval.js +174 -0
- package/lib/exercises/math/calcul/fractions/index.d.ts +1 -0
- package/lib/exercises/math/calcul/fractions/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/index.js +1 -0
- package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.d.ts +8 -0
- package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.d.ts.map +1 -0
- package/lib/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.js +104 -0
- package/lib/exercises/math/calcul/index.d.ts +1 -0
- package/lib/exercises/math/calcul/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/index.js +1 -0
- package/lib/exercises/math/calcul/rationals/index.d.ts +2 -0
- package/lib/exercises/math/calcul/rationals/index.d.ts.map +1 -0
- package/lib/exercises/math/calcul/rationals/index.js +1 -0
- package/lib/exercises/math/calcul/rationals/rationalNumbers.d.ts +11 -0
- package/lib/exercises/math/calcul/rationals/rationalNumbers.d.ts.map +1 -0
- package/lib/exercises/math/calcul/rationals/rationalNumbers.js +185 -0
- package/lib/exercises/math/dataRepresentations/index.js +1 -0
- package/lib/exercises/math/probaStat/averageLinearity.d.ts +16 -0
- package/lib/exercises/math/probaStat/averageLinearity.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/averageLinearity.js +217 -0
- package/lib/exercises/math/probaStat/cumulativeSum.d.ts +9 -0
- package/lib/exercises/math/probaStat/cumulativeSum.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/cumulativeSum.js +105 -0
- package/lib/exercises/math/probaStat/describeEvent.d.ts +15 -0
- package/lib/exercises/math/probaStat/describeEvent.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/describeEvent.js +182 -0
- package/lib/exercises/math/probaStat/getSampleCountAndSize.d.ts +9 -0
- package/lib/exercises/math/probaStat/getSampleCountAndSize.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/getSampleCountAndSize.js +95 -0
- package/lib/exercises/math/probaStat/index.d.ts +4 -0
- package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/index.js +4 -0
- package/lib/index.d.ts +44 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.d.ts +1 -1
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +5 -5
- package/lib/tree/nodes/numbers/numberNode.d.ts +3 -1
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +34 -2
- package/package.json +1 -1
|
@@ -97,7 +97,7 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
97
97
|
};
|
|
98
98
|
export const getParityBetweenTwoNumbers = {
|
|
99
99
|
id: "getParityBetweenTwoNumbers",
|
|
100
|
-
label: "
|
|
100
|
+
label: "Déterminer le nombre de valeurs paires/impaires entre $a$ et $b$",
|
|
101
101
|
isSingleStep: true,
|
|
102
102
|
generator: (nb, opts) => getDistinctQuestions(() => getGetParityBetweenTwoNumbersQuestion(opts), nb),
|
|
103
103
|
qcmTimer: 60,
|
|
@@ -9,6 +9,7 @@ export * from "./ppcmCalcul.js";
|
|
|
9
9
|
export * from "./getParityBetweenTwoNumbers.js";
|
|
10
10
|
export * from "./primeNumberIdentification.js";
|
|
11
11
|
export * from "./imageOfSquareFunction.js";
|
|
12
|
+
export * from "./isNumberDecimal.js";
|
|
12
13
|
export * from "./isInequalityTrue.js";
|
|
13
14
|
export * from "./minNumberInequality.js";
|
|
14
15
|
export * from "./squareRootCalculation.js";
|
|
@@ -23,4 +24,5 @@ export * from "./compareSquaredValues.js";
|
|
|
23
24
|
export * from "./calculateWithAbsoluteValue.js";
|
|
24
25
|
export * from "./sqrtInequality.js";
|
|
25
26
|
export * from "./calculateDistanceWithAbsoluteValue.js";
|
|
27
|
+
export * from "./isNumberInInterval.js";
|
|
26
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,yCAAyC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,yCAAyC,CAAC;AACxD,cAAc,yBAAyB,CAAC"}
|
|
@@ -9,6 +9,7 @@ export * from "./ppcmCalcul.js";
|
|
|
9
9
|
export * from "./getParityBetweenTwoNumbers.js";
|
|
10
10
|
export * from "./primeNumberIdentification.js";
|
|
11
11
|
export * from "./imageOfSquareFunction.js";
|
|
12
|
+
export * from "./isNumberDecimal.js";
|
|
12
13
|
export * from "./isInequalityTrue.js";
|
|
13
14
|
export * from "./minNumberInequality.js";
|
|
14
15
|
export * from "./squareRootCalculation.js";
|
|
@@ -23,3 +24,4 @@ export * from "./compareSquaredValues.js";
|
|
|
23
24
|
export * from "./calculateWithAbsoluteValue.js";
|
|
24
25
|
export * from "./sqrtInequality.js";
|
|
25
26
|
export * from "./calculateDistanceWithAbsoluteValue.js";
|
|
27
|
+
export * from "./isNumberInInterval.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
options: {
|
|
5
|
+
a: NodeIdentifiers;
|
|
6
|
+
isDecimal: boolean;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
export declare const isNumberdecimal: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=isNumberDecimal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNumberDecimal.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/isNumberDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE;QACP,CAAC,EAAE,eAAe,CAAC;QACnB,SAAS,EAAE,OAAO,CAAC;KACpB,EAAE,CAAC;CACL,CAAC;AA8HF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAmBjD,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
4
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
7
|
+
import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
|
|
8
|
+
import { isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
9
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
10
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
const getPropositions = (n, { answer, options }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
for (const { a, isDecimal } of options) {
|
|
15
|
+
const prop = reifyAlgebraic(a).toTex();
|
|
16
|
+
if (isDecimal) {
|
|
17
|
+
addValidProp(propositions, prop);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
tryToAddWrongProp(propositions, prop);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return shuffleProps(propositions, n);
|
|
24
|
+
};
|
|
25
|
+
const getAnswer = (identifiers) => {
|
|
26
|
+
return "";
|
|
27
|
+
};
|
|
28
|
+
const getInstruction = (identifiers) => {
|
|
29
|
+
return "Parmi ces nombres, lesquels sont décimaux ?";
|
|
30
|
+
};
|
|
31
|
+
const getHint = (identifiers) => {
|
|
32
|
+
return "Un nombre est décimal s'il a un nombre fini de chiffres après la virgule.";
|
|
33
|
+
};
|
|
34
|
+
const getCorrection = (identifiers) => {
|
|
35
|
+
const { options } = identifiers;
|
|
36
|
+
let correction = "";
|
|
37
|
+
for (const { a, isDecimal } of options) {
|
|
38
|
+
const node = reifyAlgebraic(a);
|
|
39
|
+
const tex = node.toTex();
|
|
40
|
+
if (isFractionNode(node)) {
|
|
41
|
+
const denom = node.rightChild.toTex();
|
|
42
|
+
if (isDecimal) {
|
|
43
|
+
correction += `- $${tex} = ${node
|
|
44
|
+
.evaluate()
|
|
45
|
+
.frenchify()}$ est un nombre décimal car il s'écrit avec un nombre fini de chiffres après la virgule.\n\n`;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
correction += `- $${tex} \\approx ${node
|
|
49
|
+
.evaluate()
|
|
50
|
+
.frenchify()
|
|
51
|
+
.slice(0, 8)}\\ldots$ n'est pas un nombre décimal, car il s'écrit avec un nombre infini de chiffres après la virgule.\n\n`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
if (isDecimal) {
|
|
56
|
+
correction += `- $${tex}$ est un nombre décimal car il a un nombre fini de chiffres après sa virgule.\n\n`;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
correction += `- $${tex}$ est un nombre décimal car c'est un nombre entier. En effet, on peut écrire $${tex} = ${tex},0$.\n\n`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return correction;
|
|
64
|
+
};
|
|
65
|
+
const getKeys = (identifiers) => {
|
|
66
|
+
return [];
|
|
67
|
+
};
|
|
68
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
69
|
+
try {
|
|
70
|
+
throw Error("VEA not implemented");
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
return handleVEAError(err);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const generateNonDecimalNumber = () => {
|
|
77
|
+
const nonDecimals = [];
|
|
78
|
+
nonDecimals.push(randint(0, 100).toTree().toIdentifiers());
|
|
79
|
+
nonDecimals.push(RationalConstructor.randomPureRational().toTree().toIdentifiers());
|
|
80
|
+
return random(nonDecimals);
|
|
81
|
+
};
|
|
82
|
+
const generateDecimalNumber = () => {
|
|
83
|
+
const decimals = [];
|
|
84
|
+
decimals.push(randfloat(0, 100, 2).toTree().toIdentifiers());
|
|
85
|
+
decimals.push(new NumberNode(randfloat(0, 100, 2)).toFrac(true).toIdentifiers());
|
|
86
|
+
return random(decimals);
|
|
87
|
+
};
|
|
88
|
+
const getIsNumberdecimalQuestion = (ops) => {
|
|
89
|
+
let choices = [];
|
|
90
|
+
const decimal = generateDecimalNumber();
|
|
91
|
+
const nonDecimal = generateNonDecimalNumber();
|
|
92
|
+
choices.push({ a: decimal, isDecimal: true });
|
|
93
|
+
choices.push({ a: nonDecimal, isDecimal: false });
|
|
94
|
+
for (let i = 0; i < 2; i++) {
|
|
95
|
+
const isDecimal = coinFlip();
|
|
96
|
+
const randomNumber = isDecimal
|
|
97
|
+
? generateDecimalNumber()
|
|
98
|
+
: generateNonDecimalNumber();
|
|
99
|
+
choices.push({ a: randomNumber, isDecimal });
|
|
100
|
+
}
|
|
101
|
+
const identifiers = { options: choices };
|
|
102
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
103
|
+
};
|
|
104
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
105
|
+
return {
|
|
106
|
+
answer: getAnswer(identifiers),
|
|
107
|
+
instruction: getInstruction(identifiers),
|
|
108
|
+
keys: getKeys(identifiers),
|
|
109
|
+
answerFormat: "tex",
|
|
110
|
+
identifiers,
|
|
111
|
+
hint: getHint(identifiers),
|
|
112
|
+
correction: getCorrection(identifiers),
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export const isNumberdecimal = {
|
|
116
|
+
id: "isNumberDecimal",
|
|
117
|
+
label: "Dire si un nombre est décimal",
|
|
118
|
+
isSingleStep: true,
|
|
119
|
+
generator: (nb, opts) => getDistinctQuestions(() => getIsNumberdecimalQuestion(opts), nb),
|
|
120
|
+
qcmTimer: 60,
|
|
121
|
+
freeTimer: 60,
|
|
122
|
+
getPropositions,
|
|
123
|
+
isAnswerValid,
|
|
124
|
+
subject: "Mathématiques",
|
|
125
|
+
getInstruction,
|
|
126
|
+
getHint,
|
|
127
|
+
getCorrection,
|
|
128
|
+
getAnswer,
|
|
129
|
+
getQuestionFromIdentifiers,
|
|
130
|
+
hasHintAndCorrection: true,
|
|
131
|
+
answerType: "QCM",
|
|
132
|
+
isQCM: true,
|
|
133
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
a: NodeIdentifiers;
|
|
5
|
+
interval: NodeIdentifiers;
|
|
6
|
+
};
|
|
7
|
+
export declare const isNumberInInterval: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=isNumberInInterval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNumberInInterval.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/isNumberInInterval.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAO7C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAsLF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAkBpD,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
import { round } from "../../../../math/utils/round.js";
|
|
6
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
7
|
+
import { ClosureType } from "../../../../tree/nodes/sets/closure.js";
|
|
8
|
+
import { IntervalNode } from "../../../../tree/nodes/sets/intervalNode.js";
|
|
9
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
10
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
const getPropositions = (n, { answer }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
addValidProp(propositions, answer, "tex");
|
|
15
|
+
if (answer === "\\in") {
|
|
16
|
+
tryToAddWrongProp(propositions, "\\notin", "tex");
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
tryToAddWrongProp(propositions, "\\in", "tex");
|
|
20
|
+
}
|
|
21
|
+
return shuffleProps(propositions, n);
|
|
22
|
+
};
|
|
23
|
+
const getAnswer = (identifiers) => {
|
|
24
|
+
const { a, interval } = identifiers;
|
|
25
|
+
const aNode = reifyAlgebraic(a);
|
|
26
|
+
const intervalNode = reifyAlgebraic(interval);
|
|
27
|
+
if (intervalNode instanceof IntervalNode) {
|
|
28
|
+
const aValue = aNode.evaluate();
|
|
29
|
+
const aMin = intervalNode.a.evaluate();
|
|
30
|
+
const aMax = intervalNode.b.evaluate();
|
|
31
|
+
const leftClosed = intervalNode.isLeftClosed();
|
|
32
|
+
const rightClosed = intervalNode.isRightClosed();
|
|
33
|
+
if ((aValue > aMin || (leftClosed && aValue === aMin)) &&
|
|
34
|
+
(aValue < aMax || (rightClosed && aValue === aMax))) {
|
|
35
|
+
return "\\in";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return "\\notin";
|
|
39
|
+
};
|
|
40
|
+
const getInstruction = (identifiers) => {
|
|
41
|
+
const { a, interval } = identifiers;
|
|
42
|
+
const aNode = reifyAlgebraic(a);
|
|
43
|
+
const intervalNode = reifyAlgebraic(interval);
|
|
44
|
+
return `Compléter par le bon symbole :
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
$$
|
|
48
|
+
${aNode.toTex()} \\ \\ldots \\ ${intervalNode.toTex()}
|
|
49
|
+
$$`;
|
|
50
|
+
};
|
|
51
|
+
const getHint = (identifiers) => {
|
|
52
|
+
const { a, interval } = identifiers;
|
|
53
|
+
const aNode = reifyAlgebraic(a);
|
|
54
|
+
const intervalNode = reifyAlgebraic(interval);
|
|
55
|
+
return `Pour déterminer si $${aNode.toTex()}$ appartient à l'intervalle $${intervalNode.toTex()}$, il faut vérifier si cette valeur est comprise entre les bornes de l'intervalle.`;
|
|
56
|
+
};
|
|
57
|
+
const getCorrection = (identifiers) => {
|
|
58
|
+
const { a, interval } = identifiers;
|
|
59
|
+
const aNode = reifyAlgebraic(a);
|
|
60
|
+
const intervalNode = reifyAlgebraic(interval);
|
|
61
|
+
const aValue = aNode.evaluate();
|
|
62
|
+
const aMin = intervalNode.a.evaluate();
|
|
63
|
+
const aMax = intervalNode.b.evaluate();
|
|
64
|
+
const leftClosed = intervalNode.isLeftClosed();
|
|
65
|
+
const rightClosed = intervalNode.isRightClosed();
|
|
66
|
+
let minCondition, maxCondition;
|
|
67
|
+
if (leftClosed) {
|
|
68
|
+
minCondition = aValue >= aMin ? "vérifiée" : "non vérifiée";
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
minCondition = aValue > aMin ? "vérifiée" : "non vérifiée";
|
|
72
|
+
}
|
|
73
|
+
if (rightClosed) {
|
|
74
|
+
maxCondition = aValue <= aMax ? "vérifiée" : "non vérifiée";
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
maxCondition = aValue < aMax ? "vérifiée" : "non vérifiée";
|
|
78
|
+
}
|
|
79
|
+
const result = (aValue > aMin || (leftClosed && aValue === aMin)) &&
|
|
80
|
+
(aValue < aMax || (rightClosed && aValue === aMax));
|
|
81
|
+
return `Pour que le nombre $${aNode.toTex()}$ appartienne à l'intervalle $${intervalNode.toTex()}$, il faut qu'il soit ${leftClosed ? "supérieur ou égal" : "strictement supérieur"} à $${intervalNode.a.toTex()}$ et ${rightClosed ? "inférieur ou égal" : "strictement inférieur"} à $${intervalNode.b.toTex()}$.
|
|
82
|
+
|
|
83
|
+
Vérifions ces conditions :
|
|
84
|
+
- $${aNode.toTex()}$ ${leftClosed ? "$\\ge$" : "$>$"} $${intervalNode.a.toTex()}$ : condition ${minCondition}
|
|
85
|
+
- $${aNode.toTex()}$ ${rightClosed ? "$\\le$" : "$<$"} $${intervalNode.b.toTex()}$ : condition ${maxCondition}
|
|
86
|
+
|
|
87
|
+
${result
|
|
88
|
+
? `Les deux conditions sont vérifiées, donc $${aNode.toTex()} \\in ${intervalNode.toTex()}$.`
|
|
89
|
+
: `Au moins une condition n'est pas vérifiée, donc $${aNode.toTex()} \\notin ${intervalNode.toTex()}$.`}`;
|
|
90
|
+
};
|
|
91
|
+
const getKeys = (identifiers) => {
|
|
92
|
+
return [];
|
|
93
|
+
};
|
|
94
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
95
|
+
try {
|
|
96
|
+
return ans === answer;
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
return handleVEAError(err);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const getIsNumberInIntervalQuestion = (ops) => {
|
|
103
|
+
const lowerBound = coinFlip()
|
|
104
|
+
? randint(-10, 10)
|
|
105
|
+
: round(randfloat(-10, 10, 2), 2);
|
|
106
|
+
const width = randint(1, 20);
|
|
107
|
+
const upperBound = round(lowerBound + width, 2);
|
|
108
|
+
const closures = [
|
|
109
|
+
ClosureType.FF,
|
|
110
|
+
ClosureType.FO,
|
|
111
|
+
ClosureType.OF,
|
|
112
|
+
ClosureType.OO,
|
|
113
|
+
];
|
|
114
|
+
const closure = random(closures);
|
|
115
|
+
const isInside = coinFlip();
|
|
116
|
+
let a;
|
|
117
|
+
if (isInside) {
|
|
118
|
+
a = coinFlip()
|
|
119
|
+
? randint(Math.ceil(lowerBound), Math.floor(upperBound) - 1)
|
|
120
|
+
: randfloat(lowerBound, upperBound, 2);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
if (coinFlip()) {
|
|
124
|
+
const outisde = [];
|
|
125
|
+
a = coinFlip()
|
|
126
|
+
? randint(-20, Math.floor(lowerBound) - 1)
|
|
127
|
+
: randfloat(-20, lowerBound - 0.01, 2);
|
|
128
|
+
outisde.push(a);
|
|
129
|
+
a = coinFlip()
|
|
130
|
+
? randint(Math.ceil(upperBound) + 1, 20)
|
|
131
|
+
: randfloat(upperBound + 0.01, 20, 2);
|
|
132
|
+
outisde.push(a);
|
|
133
|
+
a = random(outisde);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
a = coinFlip() ? lowerBound : upperBound;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const interval = new IntervalNode(lowerBound.toTree(), upperBound.toTree(), closure);
|
|
140
|
+
const identifiers = {
|
|
141
|
+
a: a.toTree().toIdentifiers(),
|
|
142
|
+
interval: interval.toIdentifiers(),
|
|
143
|
+
};
|
|
144
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
145
|
+
};
|
|
146
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
147
|
+
return {
|
|
148
|
+
answer: getAnswer(identifiers),
|
|
149
|
+
instruction: getInstruction(identifiers),
|
|
150
|
+
keys: getKeys(identifiers),
|
|
151
|
+
answerFormat: "tex",
|
|
152
|
+
identifiers,
|
|
153
|
+
hint: getHint(identifiers),
|
|
154
|
+
correction: getCorrection(identifiers),
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
export const isNumberInInterval = {
|
|
158
|
+
id: "isNumberInInterval",
|
|
159
|
+
label: "Appartenance d'un nombre à un intervalle",
|
|
160
|
+
isSingleStep: true,
|
|
161
|
+
generator: (nb, opts) => getDistinctQuestions(() => getIsNumberInIntervalQuestion(opts), nb),
|
|
162
|
+
qcmTimer: 60,
|
|
163
|
+
freeTimer: 60,
|
|
164
|
+
getPropositions,
|
|
165
|
+
isAnswerValid,
|
|
166
|
+
subject: "Mathématiques",
|
|
167
|
+
getInstruction,
|
|
168
|
+
getHint,
|
|
169
|
+
getCorrection,
|
|
170
|
+
getAnswer,
|
|
171
|
+
getQuestionFromIdentifiers,
|
|
172
|
+
hasHintAndCorrection: true,
|
|
173
|
+
answerType: "QCU",
|
|
174
|
+
};
|
|
@@ -6,6 +6,7 @@ export * from "./fractionsDivision.js";
|
|
|
6
6
|
export * from "./fractionsProduct.js";
|
|
7
7
|
export * from "./fractionsSum.js";
|
|
8
8
|
export * from "./simplifyFraction.js";
|
|
9
|
+
export * from "./simplifyFractionWithPrimeFactorization.js";
|
|
9
10
|
export * from "./periodicWritingToFraction.js";
|
|
10
11
|
export * from "./fractionsSumsSameDenominators.js";
|
|
11
12
|
export * from "./fractionsSumsMultiplesDenominators.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AACxD,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
|
@@ -6,6 +6,7 @@ export * from "./fractionsDivision.js";
|
|
|
6
6
|
export * from "./fractionsProduct.js";
|
|
7
7
|
export * from "./fractionsSum.js";
|
|
8
8
|
export * from "./simplifyFraction.js";
|
|
9
|
+
export * from "./simplifyFractionWithPrimeFactorization.js";
|
|
9
10
|
export * from "./periodicWritingToFraction.js";
|
|
10
11
|
export * from "./fractionsSumsSameDenominators.js";
|
|
11
12
|
export * from "./fractionsSumsMultiplesDenominators.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
num: number;
|
|
4
|
+
denum: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const simplifyFractionWithPrimeFactorization: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=simplifyFractionWithPrimeFactorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplifyFractionWithPrimeFactorization.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/fractions/simplifyFractionWithPrimeFactorization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAcrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA2GF,eAAO,MAAM,sCAAsC,EAAE,QAAQ,CAAC,WAAW,CAqBxE,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
4
|
+
import { gcd } from "../../../../math/utils/arithmetic/gcd.js";
|
|
5
|
+
import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
|
|
6
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
7
|
+
import { round } from "../../../../math/utils/round.js";
|
|
8
|
+
import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
|
|
9
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
10
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
11
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
12
|
+
const { num, denum } = identifiers;
|
|
13
|
+
const propositions = [];
|
|
14
|
+
addValidProp(propositions, answer);
|
|
15
|
+
while (propositions.length < n) {
|
|
16
|
+
tryToAddWrongProp(propositions, RationalConstructor.randomIrreductible().toTex());
|
|
17
|
+
}
|
|
18
|
+
return shuffleProps(propositions, n);
|
|
19
|
+
};
|
|
20
|
+
const getAnswer = (identifiers) => {
|
|
21
|
+
const { num, denum } = identifiers;
|
|
22
|
+
return frac(num, denum).simplify().toTex();
|
|
23
|
+
};
|
|
24
|
+
const getInstruction = (identifiers) => {
|
|
25
|
+
const { num, denum } = identifiers;
|
|
26
|
+
return `On donne la décomposition en produit de facteurs premiers des nombres suivants:
|
|
27
|
+
|
|
28
|
+
- $${num} = ${new NumberNode(num).toPrimeDecomposition().toTex()}$
|
|
29
|
+
- $${denum} = ${new NumberNode(denum).toPrimeDecomposition().toTex()}$
|
|
30
|
+
|
|
31
|
+
Simplifiez la fraction $${frac(num, denum).toTex()}$.
|
|
32
|
+
`;
|
|
33
|
+
};
|
|
34
|
+
const getHint = (identifiers) => {
|
|
35
|
+
return `Utilise la propriété :
|
|
36
|
+
|
|
37
|
+
$$
|
|
38
|
+
\\frac{k\\times a}{k\\times b} = \\frac{a}{b}
|
|
39
|
+
$$`;
|
|
40
|
+
};
|
|
41
|
+
const getCorrection = (identifiers) => {
|
|
42
|
+
const { num, denum } = identifiers;
|
|
43
|
+
const simpNum = round(num / gcd(num, denum), 3);
|
|
44
|
+
const simpDenum = round(denum / gcd(num, denum), 3);
|
|
45
|
+
return `On a :
|
|
46
|
+
|
|
47
|
+
$$
|
|
48
|
+
${frac(num, denum).toTex()} = ${frac(new NumberNode(num).toPrimeDecomposition(), new NumberNode(denum).toPrimeDecomposition()).toTex()}
|
|
49
|
+
$$
|
|
50
|
+
|
|
51
|
+
On simplifie alors par les facteurs apparaissant à la fois au numérateur et au dénominateur :
|
|
52
|
+
|
|
53
|
+
${alignTex([
|
|
54
|
+
[
|
|
55
|
+
frac(num, denum).toTex(),
|
|
56
|
+
"=",
|
|
57
|
+
frac(new NumberNode(simpNum).toPrimeDecomposition(), new NumberNode(simpDenum).toPrimeDecomposition()).toTex(),
|
|
58
|
+
],
|
|
59
|
+
["", "=", frac(num, denum).simplify().toTex()],
|
|
60
|
+
])}`;
|
|
61
|
+
};
|
|
62
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
63
|
+
return ans === answer;
|
|
64
|
+
};
|
|
65
|
+
const getSimplifyFractionWithPrimeFactorizationQuestion = (ops) => {
|
|
66
|
+
let num = 0;
|
|
67
|
+
let denum = 0;
|
|
68
|
+
do {
|
|
69
|
+
num = randint(2, 100);
|
|
70
|
+
denum = randint(2, 100);
|
|
71
|
+
} while (isPrime(num) ||
|
|
72
|
+
isPrime(denum) ||
|
|
73
|
+
[1, denum].includes(gcd(num, denum)));
|
|
74
|
+
const identifiers = { num, denum };
|
|
75
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
76
|
+
};
|
|
77
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
78
|
+
return {
|
|
79
|
+
answer: getAnswer(identifiers),
|
|
80
|
+
instruction: getInstruction(identifiers),
|
|
81
|
+
keys: [],
|
|
82
|
+
answerFormat: "tex",
|
|
83
|
+
identifiers,
|
|
84
|
+
hint: getHint(identifiers),
|
|
85
|
+
correction: getCorrection(identifiers),
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export const simplifyFractionWithPrimeFactorization = {
|
|
89
|
+
id: "simplifyFractionWithPrimeFactorization",
|
|
90
|
+
label: "Simplifier une fraction en utilisant la décomposition en nombres premiers",
|
|
91
|
+
isSingleStep: true,
|
|
92
|
+
generator: (nb, opts) => getDistinctQuestions(() => getSimplifyFractionWithPrimeFactorizationQuestion(opts), nb),
|
|
93
|
+
qcmTimer: 60,
|
|
94
|
+
freeTimer: 60,
|
|
95
|
+
getPropositions,
|
|
96
|
+
isAnswerValid,
|
|
97
|
+
subject: "Mathématiques",
|
|
98
|
+
getInstruction,
|
|
99
|
+
getHint,
|
|
100
|
+
getCorrection,
|
|
101
|
+
getAnswer,
|
|
102
|
+
getQuestionFromIdentifiers,
|
|
103
|
+
hasHintAndCorrection: true,
|
|
104
|
+
};
|
|
@@ -12,5 +12,6 @@ export * from "./digitRankNumber.js";
|
|
|
12
12
|
export * from "./digitDecimalRankNumber.js";
|
|
13
13
|
export * from "./ordering/index.js";
|
|
14
14
|
export * from "./decimals/index.js";
|
|
15
|
+
export * from "./rationals/index.js";
|
|
15
16
|
export * from "./sign/index.js";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/calcul/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/calcul/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/rationals/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./rationalNumbers.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
choices: {
|
|
5
|
+
node: NodeIdentifiers;
|
|
6
|
+
irrationalUsed: NodeIdentifiers | null;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
export declare const rationalNumbers: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=rationalNumbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rationalNumbers.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/rationals/rationalNumbers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAc7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE;QACP,IAAI,EAAE,eAAe,CAAC;QAEtB,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;KACxC,EAAE,CAAC;CACL,CAAC;AA+LF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAiBjD,CAAC"}
|