math-exercises 3.0.137 → 3.0.139
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/countDivisors.d.ts +7 -0
- package/lib/exercises/math/calcul/arithmetics/countDivisors.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/countDivisors.js +103 -0
- package/lib/exercises/math/calcul/arithmetics/findPrimeInList.d.ts +7 -0
- package/lib/exercises/math/calcul/arithmetics/findPrimeInList.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/findPrimeInList.js +89 -0
- package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.d.ts +12 -0
- package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.js +129 -0
- 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 +3 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.d.ts +14 -0
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.js +314 -0
- package/lib/exercises/math/dataRepresentations/compareBoxPlot.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/compareBoxPlot.js +1 -5
- package/lib/exercises/math/geometry/cartesian/index.d.ts +1 -0
- package/lib/exercises/math/geometry/cartesian/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/index.js +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.js +4 -11
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +2 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/index.js +2 -2
- package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/possibleValuesForProba.js +20 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.d.ts +3 -0
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +12 -0
- package/lib/utils/strings/joinanded.d.ts +1 -1
- package/lib/utils/strings/joinanded.d.ts.map +1 -1
- package/lib/utils/strings/joinanded.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countDivisors.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/countDivisors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAoGF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAkB/C,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
|
|
4
|
+
import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
7
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
8
|
+
import { joinanded } from "../../../../utils/strings/joinanded.js";
|
|
9
|
+
const getPropositions = (n, { answer }) => {
|
|
10
|
+
const propositions = [];
|
|
11
|
+
addValidProp(propositions, answer);
|
|
12
|
+
const answerNb = answer.unfrenchify();
|
|
13
|
+
propWhile(propositions, n, () => {
|
|
14
|
+
tryToAddWrongProp(propositions, Math.max(1, answerNb + randint(-3, 3, [0])).frenchify());
|
|
15
|
+
});
|
|
16
|
+
return shuffleProps(propositions, n);
|
|
17
|
+
};
|
|
18
|
+
const getAnswer = (identifiers) => {
|
|
19
|
+
const dividers = dividersOf(identifiers.nb);
|
|
20
|
+
return dividers.length.frenchify();
|
|
21
|
+
};
|
|
22
|
+
const getInstruction = (identifiers) => {
|
|
23
|
+
return `Combien le nombre $${identifiers.nb}$ a-t-il de diviseurs ?`;
|
|
24
|
+
};
|
|
25
|
+
const getHint = (identifiers) => {
|
|
26
|
+
return `Les diviseurs de $${identifiers.nb}$ sont les nombres $a$ et $b$ tels que
|
|
27
|
+
|
|
28
|
+
$$
|
|
29
|
+
${identifiers.nb} = a \\times b
|
|
30
|
+
$$
|
|
31
|
+
|
|
32
|
+
N'oublie pas que tout nombre naturel $n$ peut s'écrire :
|
|
33
|
+
|
|
34
|
+
$$
|
|
35
|
+
n = 1 \\times n
|
|
36
|
+
$$`;
|
|
37
|
+
};
|
|
38
|
+
const getCorrection = (identifiers) => {
|
|
39
|
+
const divisors = dividersOf(identifiers.nb);
|
|
40
|
+
const pureDivisors = divisors.slice(1, divisors.length % 2 === 0 ? divisors.length / 2 : divisors.length - 1);
|
|
41
|
+
if (divisors.length === 2) {
|
|
42
|
+
return `$${identifiers.nb}$ est un nombre premier, car il n'est divisible que par lui-même et $1$.
|
|
43
|
+
|
|
44
|
+
Il n'a donc que deux diviseurs.`;
|
|
45
|
+
}
|
|
46
|
+
return `Comme tous les nombres naturels, $${identifiers.nb}$ est divisible par $1$ et par lui-même.
|
|
47
|
+
|
|
48
|
+
De plus, il est divisible par ${joinanded(divisors.slice(1, divisors.length - 1).map((e) => `$${e.frenchify()}$`))}, car :
|
|
49
|
+
|
|
50
|
+
${pureDivisors
|
|
51
|
+
.map((d) => `\n$$\n${identifiers.nb} = ${d} \\times ${frac(identifiers.nb, d)
|
|
52
|
+
.simplify()
|
|
53
|
+
.toTex()}\n$$`)
|
|
54
|
+
.join("\n \n")}
|
|
55
|
+
|
|
56
|
+
Le nombre de diviseurs de $${identifiers.nb}$ est donc $${divisors.length}$.
|
|
57
|
+
`;
|
|
58
|
+
};
|
|
59
|
+
const getKeys = () => {
|
|
60
|
+
return [];
|
|
61
|
+
};
|
|
62
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
63
|
+
try {
|
|
64
|
+
return numberVEA(ans, answer);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
return handleVEAError(err);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const getCountDivisorsQuestion = () => {
|
|
71
|
+
const nb = randint(2, 101);
|
|
72
|
+
const identifiers = { nb };
|
|
73
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
74
|
+
};
|
|
75
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
76
|
+
return {
|
|
77
|
+
answer: getAnswer(identifiers),
|
|
78
|
+
instruction: getInstruction(identifiers),
|
|
79
|
+
keys: getKeys(identifiers),
|
|
80
|
+
answerFormat: "tex",
|
|
81
|
+
identifiers,
|
|
82
|
+
hint: getHint(identifiers),
|
|
83
|
+
correction: getCorrection(identifiers),
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export const countDivisors = {
|
|
87
|
+
id: "countDivisors",
|
|
88
|
+
connector: "=",
|
|
89
|
+
label: "Compter les diviseurs d'un nombre",
|
|
90
|
+
isSingleStep: true,
|
|
91
|
+
generator: (nb, opts) => getDistinctQuestions(() => getCountDivisorsQuestion(opts), nb),
|
|
92
|
+
qcmTimer: 60,
|
|
93
|
+
freeTimer: 60,
|
|
94
|
+
getPropositions,
|
|
95
|
+
isAnswerValid,
|
|
96
|
+
subject: "Mathématiques",
|
|
97
|
+
getInstruction,
|
|
98
|
+
getHint,
|
|
99
|
+
getCorrection,
|
|
100
|
+
getAnswer,
|
|
101
|
+
getQuestionFromIdentifiers,
|
|
102
|
+
hasHintAndCorrection: true,
|
|
103
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findPrimeInList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/findPrimeInList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAkFF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAmBjD,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { primes } from "../../../../math/numbers/integer/primes.js";
|
|
4
|
+
import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
|
|
5
|
+
import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
|
|
6
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
7
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
8
|
+
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
9
|
+
import { doWhile } from "../../../../utils/doWhile.js";
|
|
10
|
+
import { joinanded } from "../../../../utils/strings/joinanded.js";
|
|
11
|
+
import { pluralize } from "../../../../utils/strings/pluralize.js";
|
|
12
|
+
const getPropositions = (n, { nbs }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
for (const nb of nbs) {
|
|
15
|
+
if (isPrime(nb))
|
|
16
|
+
addValidProp(propositions, nb.frenchify());
|
|
17
|
+
else
|
|
18
|
+
tryToAddWrongProp(propositions, nb.frenchify());
|
|
19
|
+
}
|
|
20
|
+
return shuffleProps(propositions, n);
|
|
21
|
+
};
|
|
22
|
+
const getAnswer = () => {
|
|
23
|
+
return "";
|
|
24
|
+
};
|
|
25
|
+
const getInstruction = () => {
|
|
26
|
+
return `Parmi les nombres suivants, lequel ou lesquels sont des nombres premiers ?`;
|
|
27
|
+
};
|
|
28
|
+
const getHint = () => {
|
|
29
|
+
return `Un nombre est premier s'il n'a que deux diviseurs : $1$ et lui-même.`;
|
|
30
|
+
};
|
|
31
|
+
const getCorrection = (identifiers) => {
|
|
32
|
+
return `Un nombre est premier s'il n'a que deux diviseurs : $1$ et lui-même.
|
|
33
|
+
|
|
34
|
+
Pour chaque nombre, on compte son nombre de diviseurs :
|
|
35
|
+
|
|
36
|
+
${identifiers.nbs
|
|
37
|
+
.map((nb) => {
|
|
38
|
+
const divisors = dividersOf(nb);
|
|
39
|
+
return `\n
|
|
40
|
+
- $${nb}$ a $${divisors.length}$ ${pluralize("diviseur", divisors.length)} : ${joinanded(divisors.map((e) => `$${e.frenchify()}$`))}. ${divisors.length === 2
|
|
41
|
+
? "Il est donc premier."
|
|
42
|
+
: "Il n'est donc pas premier."}`;
|
|
43
|
+
})
|
|
44
|
+
.join("")}`;
|
|
45
|
+
};
|
|
46
|
+
const getFindPrimeInListQuestion = () => {
|
|
47
|
+
const nbRightAnswer = randint(1, 4);
|
|
48
|
+
const nbs = [];
|
|
49
|
+
for (let i = 0; i < nbRightAnswer; i++) {
|
|
50
|
+
nbs.push(doWhile(() => random(primes), (nb) => nbs.includes(nb)));
|
|
51
|
+
}
|
|
52
|
+
for (let i = 0; i < 4 - nbRightAnswer; i++) {
|
|
53
|
+
nbs.push(doWhile(() => randint(1, 101), (x) => isPrime(x) || nbs.includes(x)));
|
|
54
|
+
}
|
|
55
|
+
const identifiers = {
|
|
56
|
+
nbs: shuffle(nbs),
|
|
57
|
+
};
|
|
58
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
59
|
+
};
|
|
60
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
61
|
+
return {
|
|
62
|
+
answer: getAnswer(identifiers),
|
|
63
|
+
instruction: getInstruction(identifiers),
|
|
64
|
+
keys: [],
|
|
65
|
+
answerFormat: "tex",
|
|
66
|
+
identifiers,
|
|
67
|
+
hint: getHint(identifiers),
|
|
68
|
+
correction: getCorrection(identifiers),
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export const findPrimeInList = {
|
|
72
|
+
id: "findPrimeInList",
|
|
73
|
+
connector: "=",
|
|
74
|
+
label: "Trouver les nombres premiers dans une liste",
|
|
75
|
+
isSingleStep: true,
|
|
76
|
+
generator: (nb, opts) => getDistinctQuestions(() => getFindPrimeInListQuestion(opts), nb),
|
|
77
|
+
qcmTimer: 60,
|
|
78
|
+
freeTimer: 60,
|
|
79
|
+
getPropositions,
|
|
80
|
+
subject: "Mathématiques",
|
|
81
|
+
getInstruction,
|
|
82
|
+
getHint,
|
|
83
|
+
getCorrection,
|
|
84
|
+
getAnswer,
|
|
85
|
+
getQuestionFromIdentifiers,
|
|
86
|
+
hasHintAndCorrection: true,
|
|
87
|
+
answerType: "QCM",
|
|
88
|
+
isQCM: true,
|
|
89
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
nb: number;
|
|
5
|
+
fakeDecomps: NodeIdentifiers[];
|
|
6
|
+
};
|
|
7
|
+
type Options = {
|
|
8
|
+
doNotUsePowers?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const findRightPrimeDecomposition: Exercise<Identifiers, Options>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=findRightPrimeDecomposition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findRightPrimeDecomposition.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAU7C,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAkIF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAsBtE,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, GeneratorOptionTarget, GeneratorOptionType,
|
|
2
|
+
// tryToAddWrongProp,
|
|
3
|
+
addWrongProp, } from "../../../../exercises/exercise.js";
|
|
4
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
5
|
+
import { dividersOf } from "../../../../math/utils/arithmetic/dividersOf.js";
|
|
6
|
+
import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
|
|
7
|
+
// import { isPrime } from "../../../../math/utils/arithmetic/isPrime.js";
|
|
8
|
+
import { primeDecompNode } from "../../../../math/utils/arithmetic/primeDecompNode.js";
|
|
9
|
+
import { primeDecomposition } from "../../../../math/utils/arithmetic/primeDecomposition.js";
|
|
10
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
11
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
12
|
+
import { multiply, MultiplyNode, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
13
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
14
|
+
import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
|
|
15
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
16
|
+
import { doWhile } from "../../../../utils/doWhile.js";
|
|
17
|
+
const options = [
|
|
18
|
+
{
|
|
19
|
+
id: "doNotUsePowers",
|
|
20
|
+
label: "Ne pas utiliser de puissances",
|
|
21
|
+
target: GeneratorOptionTarget.generation,
|
|
22
|
+
type: GeneratorOptionType.checkbox,
|
|
23
|
+
defaultValue: false,
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
const getPropositions = (n, { answer, fakeDecomps }) => {
|
|
27
|
+
const propositions = [];
|
|
28
|
+
addValidProp(propositions, answer);
|
|
29
|
+
for (const decomp of fakeDecomps) {
|
|
30
|
+
addWrongProp(propositions, reifyAlgebraic(decomp).toTex({ forceNoSimplification: true }));
|
|
31
|
+
}
|
|
32
|
+
return shuffleProps(propositions, n);
|
|
33
|
+
};
|
|
34
|
+
const getAnswer = (identifiers, opts) => {
|
|
35
|
+
const decomp = primeDecompNode(identifiers.nb, !opts?.doNotUsePowers);
|
|
36
|
+
return decomp.toTex();
|
|
37
|
+
};
|
|
38
|
+
const getInstruction = (identifiers) => {
|
|
39
|
+
return `Parmi les propositions suivantes, laquelle est la décomposition en produit de facteurs premiers de $${identifiers.nb}$ ?`;
|
|
40
|
+
};
|
|
41
|
+
const getHint = (_identifiers, opts) => {
|
|
42
|
+
return `La décomposition en produit de facteurs premiers d'un nombre $n$ est une écriture de la forme :
|
|
43
|
+
|
|
44
|
+
${opts?.doNotUsePowers
|
|
45
|
+
? `$$
|
|
46
|
+
n = p_1 \\times p_2 \\times ...
|
|
47
|
+
$$`
|
|
48
|
+
: `$$
|
|
49
|
+
n = p_1^{k_1} \\times p_2^{k_2} \\times ...
|
|
50
|
+
$$`}
|
|
51
|
+
|
|
52
|
+
où $p_1$, $p_2$, ... sont des nombres premiers${opts?.doNotUsePowers
|
|
53
|
+
? " ."
|
|
54
|
+
: " et $k_1$, $k_2$, ... sont des entiers naturels."}
|
|
55
|
+
|
|
56
|
+
Parmi les écritures proposées, il faut donc repérer celle dans laquelle chaque facteur est un nombre premier.`;
|
|
57
|
+
};
|
|
58
|
+
const getCorrection = (identifiers, opts) => {
|
|
59
|
+
return `La décomposition en produit de facteurs premiers de $${identifiers.nb}$ est :
|
|
60
|
+
|
|
61
|
+
$$
|
|
62
|
+
${getAnswer(identifiers, opts)}
|
|
63
|
+
$$`;
|
|
64
|
+
};
|
|
65
|
+
const getFindRightPrimeDecompositionQuestion = (opts) => {
|
|
66
|
+
let nb = 0;
|
|
67
|
+
let divisors = [];
|
|
68
|
+
do {
|
|
69
|
+
nb = randint(10, 101);
|
|
70
|
+
divisors = dividersOf(nb);
|
|
71
|
+
} while (divisors.length < 5);
|
|
72
|
+
// const pureDivisors = divisors.slice(
|
|
73
|
+
// 0,
|
|
74
|
+
// divisors.length % 2 === 0 ? divisors.length / 2 : (divisors.length + 1) / 2,
|
|
75
|
+
// );
|
|
76
|
+
const fakeDecomps = [];
|
|
77
|
+
const nonPrimes = [];
|
|
78
|
+
console.log(nb);
|
|
79
|
+
for (let i = 0; i < 3; i++) {
|
|
80
|
+
const nonPrime = doWhile(() => random(divisors.slice(1).filter((n) => !isPrime(n))), (n) => nonPrimes.includes(n));
|
|
81
|
+
nonPrimes.push(nonPrime);
|
|
82
|
+
if (nonPrime === nb) {
|
|
83
|
+
fakeDecomps.push(multiply(1, nb).toIdentifiers());
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const rest = nb / nonPrime;
|
|
87
|
+
const fakeDecomp = primeDecomposition(rest);
|
|
88
|
+
fakeDecomp.push({ value: nonPrime, power: 1 });
|
|
89
|
+
fakeDecomp.sort((a, b) => a.value - b.value);
|
|
90
|
+
fakeDecomps.push(operatorComposition(MultiplyNode, fakeDecomp.map((d) => d.power > 1
|
|
91
|
+
? opts?.doNotUsePowers
|
|
92
|
+
? power(d.value, d.power).toMultiplyNode()
|
|
93
|
+
: power(d.value, d.power)
|
|
94
|
+
: d.value.toTree())).toIdentifiers());
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const identifiers = { nb, fakeDecomps };
|
|
98
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
99
|
+
};
|
|
100
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
101
|
+
return {
|
|
102
|
+
answer: getAnswer(identifiers, opts),
|
|
103
|
+
instruction: getInstruction(identifiers, opts),
|
|
104
|
+
keys: [],
|
|
105
|
+
answerFormat: "tex",
|
|
106
|
+
identifiers,
|
|
107
|
+
hint: getHint(identifiers, opts),
|
|
108
|
+
correction: getCorrection(identifiers, opts),
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export const findRightPrimeDecomposition = {
|
|
112
|
+
id: "findRightPrimeDecomposition",
|
|
113
|
+
connector: "=",
|
|
114
|
+
label: "Trouver la bonne décomposition en produit de facteurs premiers",
|
|
115
|
+
isSingleStep: true,
|
|
116
|
+
generator: (nb, opts) => getDistinctQuestions(() => getFindRightPrimeDecompositionQuestion(opts), nb),
|
|
117
|
+
qcmTimer: 60,
|
|
118
|
+
freeTimer: 60,
|
|
119
|
+
getPropositions,
|
|
120
|
+
subject: "Mathématiques",
|
|
121
|
+
getInstruction,
|
|
122
|
+
getHint,
|
|
123
|
+
getCorrection,
|
|
124
|
+
getAnswer,
|
|
125
|
+
getQuestionFromIdentifiers,
|
|
126
|
+
hasHintAndCorrection: true,
|
|
127
|
+
answerType: "QCU",
|
|
128
|
+
options,
|
|
129
|
+
};
|
|
@@ -11,4 +11,6 @@ export * from "./primeNumberIdentification.js";
|
|
|
11
11
|
export * from "./whichMultipleAmI.js";
|
|
12
12
|
export * from "./isMultipleOrDivisor.js";
|
|
13
13
|
export * from "./coprime.js";
|
|
14
|
+
export * from "./countDivisors.js";
|
|
15
|
+
export * from "./findPrimeInList.js";
|
|
14
16
|
//# 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,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,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,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
|
@@ -11,3 +11,6 @@ export * from "./primeNumberIdentification.js";
|
|
|
11
11
|
export * from "./whichMultipleAmI.js";
|
|
12
12
|
export * from "./isMultipleOrDivisor.js";
|
|
13
13
|
export * from "./coprime.js";
|
|
14
|
+
export * from "./countDivisors.js";
|
|
15
|
+
export * from "./findPrimeInList.js";
|
|
16
|
+
// export * from "./findRightPrimeDecomposition.js";
|
|
@@ -15,4 +15,5 @@ export * from "./equationWithDistributivity.js";
|
|
|
15
15
|
export * from "./choseOperationToSolveEquation.js";
|
|
16
16
|
export * from "./factorizeEquation.js";
|
|
17
17
|
export * from "./equationFromProblem.js";
|
|
18
|
+
export * from "./isEqualityTrue.js";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
evaluationDict: Record<string, NodeIdentifiers>;
|
|
5
|
+
equalNodeIds: NodeIdentifiers;
|
|
6
|
+
isEqual: boolean;
|
|
7
|
+
};
|
|
8
|
+
type Options = {
|
|
9
|
+
typeCoeff: "Entier" | "Fraction" | "Décimal";
|
|
10
|
+
typeTestValue: "Entier" | "Fraction" | "Décimal";
|
|
11
|
+
};
|
|
12
|
+
export declare const isEqualityTrue1: Exercise<Identifiers, Options>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=isEqualityTrue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEqualityTrue.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calculLitteral/equation/isEqualityTrue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAkB7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAChD,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAkUF,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAC7C,aAAa,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;CAClD,CAAC;AA6BF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkB1D,CAAC"}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
|
|
4
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
5
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { EqualNode } from "../../../../tree/nodes/equations/equalNode.js";
|
|
7
|
+
import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
8
|
+
import { isNumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
|
|
9
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
10
|
+
import { frac, isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
11
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
12
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
13
|
+
import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
|
|
14
|
+
import { parseLatex } from "../../../../tree/parsers/latexParser.js";
|
|
15
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
16
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
17
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
18
|
+
import { joinanded } from "../../../../utils/strings/joinanded.js";
|
|
19
|
+
const varNames = ["x", "y", "z", "t", "u", "v"];
|
|
20
|
+
const getPropositions = (_, { answer }) => {
|
|
21
|
+
const propositions = [];
|
|
22
|
+
["Oui", "Non"].forEach((strYN) => {
|
|
23
|
+
if (strYN === answer) {
|
|
24
|
+
addValidProp(propositions, strYN);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
tryToAddWrongProp(propositions, strYN);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return propositions;
|
|
31
|
+
};
|
|
32
|
+
const getAnswer = (identifiers) => {
|
|
33
|
+
const { isEqual } = identifiers;
|
|
34
|
+
return isEqual ? "Oui" : "Non";
|
|
35
|
+
};
|
|
36
|
+
const getInstruction = (identifiers) => {
|
|
37
|
+
const { evaluationDict, equalNodeIds } = identifiers;
|
|
38
|
+
const equalNode = NodeConstructor.fromIdentifiers(equalNodeIds);
|
|
39
|
+
const strEvaluation = `${joinanded(Object.entries(evaluationDict).map(([varName, nodeIds]) => {
|
|
40
|
+
const node = NodeConstructor.fromIdentifiers(nodeIds);
|
|
41
|
+
return `$${varName} = ${node.toTex()}$`;
|
|
42
|
+
}), ", ", " et ")}`;
|
|
43
|
+
return `En considérant l'équation ci-dessous, l'égalité est-elle vérifiée pour ${strEvaluation} ?
|
|
44
|
+
|
|
45
|
+
$$
|
|
46
|
+
${equalNode.toTex()}
|
|
47
|
+
$$
|
|
48
|
+
|
|
49
|
+
`;
|
|
50
|
+
};
|
|
51
|
+
const getHint = () => {
|
|
52
|
+
return `L'expression $3x$ vaut $3,3$ pour $x = 1,1$.`;
|
|
53
|
+
};
|
|
54
|
+
const getCorrection = (identifiers) => {
|
|
55
|
+
const { evaluationDict, equalNodeIds, isEqual } = identifiers;
|
|
56
|
+
const evaluationEntries = Object.entries(evaluationDict).map(([varName, nodeIds]) => [
|
|
57
|
+
varName,
|
|
58
|
+
NodeConstructor.fromIdentifiers(nodeIds),
|
|
59
|
+
]);
|
|
60
|
+
const equalNode = NodeConstructor.fromIdentifiers(equalNodeIds);
|
|
61
|
+
const [lhsNode, rhsNode] = [equalNode.leftChild, equalNode.rightChild];
|
|
62
|
+
const [evaluatedLhsNode, evaluatedRhsNode] = [lhsNode, rhsNode].map((nodeCarrier) => evaluationEntries.reduce((acc, [varName, nodeInjected]) => nodeBySubstitutingVar(acc, nodeInjected, new VariableNode(varName)), nodeCarrier));
|
|
63
|
+
return `Pour tester si l'égalité est vérifiée, on évalue chaque membre de l'équation.
|
|
64
|
+
|
|
65
|
+
On évalue le membre de gauche :
|
|
66
|
+
|
|
67
|
+
${alignTex([
|
|
68
|
+
["", lhsNode.toTex()],
|
|
69
|
+
["=", evaluatedLhsNode.toTex()],
|
|
70
|
+
[
|
|
71
|
+
"=",
|
|
72
|
+
(() => {
|
|
73
|
+
const evLhsAsAddNode = evaluatedLhsNode;
|
|
74
|
+
return add(evLhsAsAddNode.leftChild.simplify(), evLhsAsAddNode.rightChild);
|
|
75
|
+
})().toTex(),
|
|
76
|
+
],
|
|
77
|
+
["=", evaluatedLhsNode.simplify().toTex()],
|
|
78
|
+
])}
|
|
79
|
+
|
|
80
|
+
On évalue le membre de droite :
|
|
81
|
+
|
|
82
|
+
${alignTex([
|
|
83
|
+
["", rhsNode.toTex()],
|
|
84
|
+
["=", evaluatedRhsNode.toTex()],
|
|
85
|
+
[
|
|
86
|
+
"=",
|
|
87
|
+
(() => {
|
|
88
|
+
const evRhsAsAddNode = evaluatedRhsNode;
|
|
89
|
+
return add(evRhsAsAddNode.leftChild.simplify(), evRhsAsAddNode.rightChild);
|
|
90
|
+
})().toTex(),
|
|
91
|
+
],
|
|
92
|
+
["=", evaluatedRhsNode.simplify().toTex()],
|
|
93
|
+
])}
|
|
94
|
+
|
|
95
|
+
${isEqual
|
|
96
|
+
? `Les deux valeurs sont égales donc l'égalité est vérifiée.`
|
|
97
|
+
: `Les deux valeurs sont différentes. L'égalité n'est pas vérifiée.`}
|
|
98
|
+
|
|
99
|
+
`;
|
|
100
|
+
};
|
|
101
|
+
const getKeys = () => {
|
|
102
|
+
return [];
|
|
103
|
+
};
|
|
104
|
+
const getIsEqualityTrue1Question = (optsIn) => {
|
|
105
|
+
const arrayedOptions = optsIn ?? optsDefault;
|
|
106
|
+
const opts = {
|
|
107
|
+
typeCoeff: random(arrayedOptions.typeCoeff),
|
|
108
|
+
typeTestValue: random(arrayedOptions.typeTestValue),
|
|
109
|
+
};
|
|
110
|
+
const roundDecimalTo = 1;
|
|
111
|
+
const varName = random(varNames);
|
|
112
|
+
function getRandomIntNode(excludes = []) {
|
|
113
|
+
let outNode = (1).toTree();
|
|
114
|
+
let counter = -1;
|
|
115
|
+
let isFound = false;
|
|
116
|
+
while (!isFound && counter < 100) {
|
|
117
|
+
counter++;
|
|
118
|
+
const intExcludes = excludes
|
|
119
|
+
.filter((node) => isNumberNode(node))
|
|
120
|
+
.map((node) => node.evaluate())
|
|
121
|
+
.filter((value) => value % 1 === 0);
|
|
122
|
+
let n;
|
|
123
|
+
try {
|
|
124
|
+
n = randint(-9, 10, intExcludes);
|
|
125
|
+
}
|
|
126
|
+
catch (_) {
|
|
127
|
+
(() => { })();
|
|
128
|
+
}
|
|
129
|
+
if (n) {
|
|
130
|
+
outNode = n.toTree();
|
|
131
|
+
isFound = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return outNode;
|
|
135
|
+
}
|
|
136
|
+
function getRandomFractionNode(excludes = []) {
|
|
137
|
+
let outNode = (1).toTree();
|
|
138
|
+
let counter = -1;
|
|
139
|
+
let isFound = false;
|
|
140
|
+
while (!isFound && counter < 100) {
|
|
141
|
+
counter++;
|
|
142
|
+
const num = randint(-9, 10);
|
|
143
|
+
const den = randint(0, 10, [0, num]);
|
|
144
|
+
const fractionNode = frac(num, den);
|
|
145
|
+
const isExcluded = excludes.some((excludedNode) => substract(excludedNode, fractionNode).evaluate() === 0);
|
|
146
|
+
if (!isExcluded) {
|
|
147
|
+
outNode = fractionNode;
|
|
148
|
+
isFound = true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return outNode;
|
|
152
|
+
}
|
|
153
|
+
function getRandomDecimalNode(excludes = [], roundTo) {
|
|
154
|
+
let outNode = (1).toTree();
|
|
155
|
+
let counter = -1;
|
|
156
|
+
let isFound = false;
|
|
157
|
+
while (!isFound && counter < 100) {
|
|
158
|
+
counter++;
|
|
159
|
+
const decimalNode = randfloat(-10, 10, roundTo).toTree();
|
|
160
|
+
const isExcluded = excludes.some((excludedNode) => substract(excludedNode, decimalNode).evaluate() === 0);
|
|
161
|
+
if (!isExcluded) {
|
|
162
|
+
outNode = decimalNode;
|
|
163
|
+
isFound = true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return outNode;
|
|
167
|
+
}
|
|
168
|
+
function getRandomNode(typeCoeff, excludes = []) {
|
|
169
|
+
switch (typeCoeff) {
|
|
170
|
+
case "Fraction":
|
|
171
|
+
return getRandomFractionNode(excludes);
|
|
172
|
+
case "Décimal": {
|
|
173
|
+
return getRandomDecimalNode(excludes, roundDecimalTo);
|
|
174
|
+
}
|
|
175
|
+
case "Entier":
|
|
176
|
+
default:
|
|
177
|
+
return getRandomIntNode(excludes);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function createRandomIdentifiers() {
|
|
181
|
+
const [a, b] = [
|
|
182
|
+
getRandomNode(opts.typeCoeff),
|
|
183
|
+
getRandomNode(opts.typeCoeff),
|
|
184
|
+
];
|
|
185
|
+
const [c, d] = [
|
|
186
|
+
getRandomNode(opts.typeCoeff, [a]),
|
|
187
|
+
getRandomNode(opts.typeCoeff),
|
|
188
|
+
];
|
|
189
|
+
const lhsNode = add(multiply(a, varName.toTree()), b);
|
|
190
|
+
const rhsNode = add(multiply(c, varName.toTree()), d);
|
|
191
|
+
const equalNode = new EqualNode(lhsNode, rhsNode);
|
|
192
|
+
//ax+b=cx+d
|
|
193
|
+
//x=(d-b)/(a-c)
|
|
194
|
+
const solutionNode = frac(substract(d, b), substract(a, c)).simplify();
|
|
195
|
+
const isEqual = coinFlip();
|
|
196
|
+
const evaluationDict = {};
|
|
197
|
+
if (isEqual) {
|
|
198
|
+
let isSalvation = true;
|
|
199
|
+
switch (opts.typeTestValue) {
|
|
200
|
+
case "Entier":
|
|
201
|
+
{
|
|
202
|
+
const value = solutionNode.evaluate();
|
|
203
|
+
const isInteger = value % 1 === 0;
|
|
204
|
+
if (isInteger) {
|
|
205
|
+
evaluationDict[varName] = value.toTree().toIdentifiers();
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
isSalvation = false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
case "Décimal":
|
|
213
|
+
{
|
|
214
|
+
const value = solutionNode.evaluate();
|
|
215
|
+
const strValue = value.toString();
|
|
216
|
+
const isDecimalWithNbDigits = strValue.split(".")?.[1]?.length === roundDecimalTo;
|
|
217
|
+
if (isDecimalWithNbDigits) {
|
|
218
|
+
evaluationDict[varName] = value.toTree().toIdentifiers();
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
isSalvation = false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case "Fraction": {
|
|
226
|
+
if (isFractionNode(solutionNode)) {
|
|
227
|
+
evaluationDict[varName] = solutionNode.toIdentifiers();
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
isSalvation = false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (!isSalvation) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const missNode = getRandomNode(opts.typeTestValue, [solutionNode]);
|
|
240
|
+
evaluationDict[varName] = missNode.toIdentifiers();
|
|
241
|
+
}
|
|
242
|
+
const identifiers = {
|
|
243
|
+
evaluationDict,
|
|
244
|
+
equalNodeIds: equalNode.toIdentifiers(),
|
|
245
|
+
isEqual,
|
|
246
|
+
};
|
|
247
|
+
return identifiers;
|
|
248
|
+
}
|
|
249
|
+
let identifiers;
|
|
250
|
+
let counter = -1;
|
|
251
|
+
while (!identifiers && counter < 100) {
|
|
252
|
+
counter++;
|
|
253
|
+
identifiers = createRandomIdentifiers();
|
|
254
|
+
}
|
|
255
|
+
const defaultIdentifiers = {
|
|
256
|
+
evaluationDict: { x: (0).toTree().toIdentifiers() },
|
|
257
|
+
equalNodeIds: parseLatex("3x+4=-5x+4").toIdentifiers(),
|
|
258
|
+
isEqual: true,
|
|
259
|
+
};
|
|
260
|
+
return getQuestionFromIdentifiers(identifiers ?? defaultIdentifiers, opts);
|
|
261
|
+
};
|
|
262
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
263
|
+
const question = {
|
|
264
|
+
answer: getAnswer(identifiers, opts),
|
|
265
|
+
instruction: getInstruction(identifiers, opts),
|
|
266
|
+
keys: getKeys(identifiers, opts),
|
|
267
|
+
answerFormat: "tex",
|
|
268
|
+
identifiers,
|
|
269
|
+
hint: getHint(identifiers, opts),
|
|
270
|
+
correction: getCorrection(identifiers, opts),
|
|
271
|
+
options: opts,
|
|
272
|
+
};
|
|
273
|
+
return question;
|
|
274
|
+
};
|
|
275
|
+
const optsDefault = {
|
|
276
|
+
typeCoeff: ["Entier"],
|
|
277
|
+
typeTestValue: ["Entier", "Fraction", "Décimal"],
|
|
278
|
+
};
|
|
279
|
+
const options = [
|
|
280
|
+
{
|
|
281
|
+
id: "typeCoeff",
|
|
282
|
+
label: "Type des coefficients",
|
|
283
|
+
target: GeneratorOptionTarget.generation,
|
|
284
|
+
type: GeneratorOptionType.multiselect,
|
|
285
|
+
values: ["Entier", "Fraction", "Décimal"],
|
|
286
|
+
defaultValue: optsDefault.typeCoeff,
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
id: "typeTestValue",
|
|
290
|
+
label: "Type des valeurs de test",
|
|
291
|
+
target: GeneratorOptionTarget.generation,
|
|
292
|
+
type: GeneratorOptionType.multiselect,
|
|
293
|
+
values: ["Entier", "Fraction", "Décimal"],
|
|
294
|
+
defaultValue: optsDefault.typeTestValue,
|
|
295
|
+
},
|
|
296
|
+
];
|
|
297
|
+
export const isEqualityTrue1 = {
|
|
298
|
+
id: "isEqualityTrue1",
|
|
299
|
+
label: "Tester une égalité pour une certaine valeur de la variable",
|
|
300
|
+
isSingleStep: true,
|
|
301
|
+
generator: (nb, opts) => getDistinctQuestions(() => getIsEqualityTrue1Question(opts), nb),
|
|
302
|
+
options,
|
|
303
|
+
qcmTimer: 60,
|
|
304
|
+
freeTimer: 60,
|
|
305
|
+
getPropositions,
|
|
306
|
+
subject: "Mathématiques",
|
|
307
|
+
getInstruction,
|
|
308
|
+
getHint,
|
|
309
|
+
getCorrection,
|
|
310
|
+
getAnswer,
|
|
311
|
+
answerType: "QCU",
|
|
312
|
+
hasHintAndCorrection: true,
|
|
313
|
+
getQuestionFromIdentifiers,
|
|
314
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareBoxPlot.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/compareBoxPlot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"compareBoxPlot.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/dataRepresentations/compareBoxPlot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,EAAE,CAAC;CACvB,CAAC;AAKF,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AA8PF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAmBhD,CAAC"}
|
|
@@ -128,10 +128,6 @@ const getGGBOptions = (identifiers) => {
|
|
|
128
128
|
coords: [xMin - 5, xMax + 5, yMin - 5, yMax + 5],
|
|
129
129
|
});
|
|
130
130
|
};
|
|
131
|
-
const isAnswerValid = (ans, { answer }) => {
|
|
132
|
-
const ansRefined = ans.split(";").toSorted().join(";");
|
|
133
|
-
return ansRefined === answer;
|
|
134
|
-
};
|
|
135
131
|
const getBoxPlotReadingQuestion = () => {
|
|
136
132
|
const nbDistri = 2;
|
|
137
133
|
const nbInAnswer = 1;
|
|
@@ -183,7 +179,6 @@ export const compareBoxPlot = {
|
|
|
183
179
|
qcmTimer: 60,
|
|
184
180
|
freeTimer: 60,
|
|
185
181
|
getPropositions,
|
|
186
|
-
isAnswerValid,
|
|
187
182
|
subject: "Mathématiques",
|
|
188
183
|
getHint,
|
|
189
184
|
getCorrection,
|
|
@@ -193,4 +188,5 @@ export const compareBoxPlot = {
|
|
|
193
188
|
hasGeogebra: true,
|
|
194
189
|
getQuestionFromIdentifiers,
|
|
195
190
|
hasHintAndCorrection: true,
|
|
191
|
+
answerType: "QCU",
|
|
196
192
|
};
|
|
@@ -11,6 +11,7 @@ export * from "./readAbscissOnLine.js";
|
|
|
11
11
|
export * from "./readAbscissOnSemiLine.js";
|
|
12
12
|
export * from "./placeAbscissOnLine.js";
|
|
13
13
|
export * from "./placeAbscissOnSemiLine.js";
|
|
14
|
+
export * from "./placeAbscissOnSemiLineV2.js";
|
|
14
15
|
export * from "./cartesianFromVectorAndPoint.js";
|
|
15
16
|
export * from "./cartesianFromTwoPoints.js";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AAEnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AAEnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC"}
|
|
@@ -12,6 +12,6 @@ export * from "./readAbscissOnLine.js";
|
|
|
12
12
|
export * from "./readAbscissOnSemiLine.js";
|
|
13
13
|
export * from "./placeAbscissOnLine.js";
|
|
14
14
|
export * from "./placeAbscissOnSemiLine.js";
|
|
15
|
-
|
|
15
|
+
export * from "./placeAbscissOnSemiLineV2.js";
|
|
16
16
|
export * from "./cartesianFromVectorAndPoint.js";
|
|
17
17
|
export * from "./cartesianFromTwoPoints.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeAbscissOnSemiLineV2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"placeAbscissOnSemiLineV2.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAK1D,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAK7C,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,UAAU,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAwNF,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,UAAU,GAAG,oBAAoB,CAAC;IAChD,UAAU,EAAE,SAAS,GAAG,YAAY,GAAG,UAAU,CAAC;CACnD,CAAC;AA6BF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAanE,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { GeneratorOptionTarget, GeneratorOptionType, } from "../../../../exercis
|
|
|
2
2
|
import { toolBarConstructor } from "../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
3
3
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
4
4
|
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
5
|
-
import { GeogebraParser } from "../../../../geogebra/parsers/geogebraParser.js";
|
|
6
5
|
import { ggbPointToCoords } from "../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
7
6
|
import { parseGGBPoints } from "../../../../geogebra/parsers/parseGGBPoints.js";
|
|
8
7
|
import { Point } from "../../../../math/geometry/point.js";
|
|
@@ -81,18 +80,12 @@ const getStudentGGBOptions = ({ abscissType, absciss1, axisUnit, absciss2, }) =>
|
|
|
81
80
|
};
|
|
82
81
|
const isGGBAnswerValid = (ans, { absciss2, axisUnit }) => {
|
|
83
82
|
const [absciss2Node, axisUnitNode] = [absciss2, axisUnit].map((nodeIds) => NodeConstructor.fromIdentifiers(nodeIds));
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
if (!strPointA) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
const coordsA = ggbPointToCoords(strPointA);
|
|
91
|
-
const points = parseGGBPoints(ans).map((p) => ggbPointToCoords(p));
|
|
92
|
-
return (points.length === 3 && //O,I,A
|
|
83
|
+
const arrCoords = parseGGBPoints(ans).map((p) => ggbPointToCoords(p));
|
|
84
|
+
const coordsA = arrCoords[0];
|
|
85
|
+
return (arrCoords.length === 1 &&
|
|
93
86
|
Math.abs(coordsA.y) < 0.5 * axisUnitNode.evaluate() &&
|
|
94
87
|
Math.abs(coordsA.x - absciss2Node.evaluate()) <
|
|
95
|
-
0.
|
|
88
|
+
0.2 * axisUnitNode.evaluate());
|
|
96
89
|
};
|
|
97
90
|
const getPlaceAbscissOnSemiLineV2Question = (optsIn) => {
|
|
98
91
|
const arrayedOptions = optsIn ?? optsDefault;
|
|
@@ -2,4 +2,6 @@ export * from "./buildMediatriceWithCompass.js";
|
|
|
2
2
|
export * from "./buildTriangleWithSizes.js";
|
|
3
3
|
export * from "./pointImageFromTranslation.js";
|
|
4
4
|
export * from "./buildPointFromAxialSymetry.js";
|
|
5
|
+
export * from "./pointImageFromHomothety.js";
|
|
6
|
+
export * from "./segmentImageFromHomothety.js";
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidianConstructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidianConstructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC"}
|
|
@@ -2,5 +2,5 @@ export * from "./buildMediatriceWithCompass.js";
|
|
|
2
2
|
export * from "./buildTriangleWithSizes.js";
|
|
3
3
|
export * from "./pointImageFromTranslation.js";
|
|
4
4
|
export * from "./buildPointFromAxialSymetry.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export * from "./pointImageFromHomothety.js";
|
|
6
|
+
export * from "./segmentImageFromHomothety.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"possibleValuesForProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicProbas/possibleValuesForProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAW7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,qBAAqB,EAAE,OAAO,CAAC;CAChC,CAAC;AA2EF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"possibleValuesForProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicProbas/possibleValuesForProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,OAAO,EAEL,eAAe,EAChB,MAAM,qCAAqC,CAAC;AAW7C,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,qBAAqB,EAAE,OAAO,CAAC;CAChC,CAAC;AA2EF,KAAK,OAAO,GAAG;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AA6OF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBjE,CAAC"}
|
|
@@ -235,6 +235,26 @@ const getPossibleValuesForProbaQuestion = (optsIn) => {
|
|
|
235
235
|
.length === 2;
|
|
236
236
|
}
|
|
237
237
|
arrNode = shuffle(arrNode);
|
|
238
|
+
//fix prevent everything to be false
|
|
239
|
+
//{
|
|
240
|
+
function isPossibleProba(node) {
|
|
241
|
+
const value = node.evaluate();
|
|
242
|
+
return 0 <= value && value <= 1;
|
|
243
|
+
}
|
|
244
|
+
function isInvalidNode(node) {
|
|
245
|
+
return (isFilterPossibleProba ? (x) => !x : (x) => x)(isPossibleProba(node));
|
|
246
|
+
}
|
|
247
|
+
const isEverythingFalse = arrNode.every(isInvalidNode);
|
|
248
|
+
if (isEverythingFalse) {
|
|
249
|
+
arrNode.pop();
|
|
250
|
+
if (isFilterPossibleProba) {
|
|
251
|
+
arrNode.push((1).toTree());
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
arrNode.push((-1).toTree());
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//}
|
|
238
258
|
const identifiers = {
|
|
239
259
|
arrayOfNodeIds: arrNode.map((node) => node.toIdentifiers()),
|
|
240
260
|
isFilterPossibleProba,
|
package/lib/index.d.ts
CHANGED
|
@@ -49,6 +49,10 @@ declare const mathExercises: (Exercise<{
|
|
|
49
49
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
50
50
|
a: number;
|
|
51
51
|
b: number;
|
|
52
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
53
|
+
nb: number;
|
|
54
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
55
|
+
nbs: number[];
|
|
52
56
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
53
57
|
integerFirst: boolean;
|
|
54
58
|
integer: number;
|
|
@@ -490,6 +494,13 @@ declare const mathExercises: (Exercise<{
|
|
|
490
494
|
shuffleArrays: number[][];
|
|
491
495
|
equalNodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
492
496
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
497
|
+
evaluationDict: Record<string, import("./tree/nodes/nodeConstructor.js").NodeIdentifiers>;
|
|
498
|
+
equalNodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
499
|
+
isEqual: boolean;
|
|
500
|
+
}, {
|
|
501
|
+
typeCoeff: "Entier" | "Fraction" | "D\u00E9cimal";
|
|
502
|
+
typeTestValue: "Entier" | "Fraction" | "D\u00E9cimal";
|
|
503
|
+
}> | Exercise<{
|
|
493
504
|
a: number;
|
|
494
505
|
b: number;
|
|
495
506
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
@@ -1607,6 +1618,14 @@ declare const mathExercises: (Exercise<{
|
|
|
1607
1618
|
abscissTex: string;
|
|
1608
1619
|
coeff: number;
|
|
1609
1620
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1621
|
+
abscissType: import("./math/numbers/nombre.js").NumberType;
|
|
1622
|
+
axisUnit: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1623
|
+
absciss1: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1624
|
+
absciss2: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1625
|
+
}, {
|
|
1626
|
+
questionType: "standard" | "\u00E9viter le comptage";
|
|
1627
|
+
numberType: "Entiers" | "Rationnels" | "D\u00E9cimaux";
|
|
1628
|
+
}> | Exercise<{
|
|
1610
1629
|
vectorIdentifiers: import("./math/geometry/vector.js").VectorIdentifiers;
|
|
1611
1630
|
pointIdentifiers: import("./math/geometry/point.js").PointIdentifiers;
|
|
1612
1631
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
@@ -1893,6 +1912,22 @@ declare const mathExercises: (Exercise<{
|
|
|
1893
1912
|
point: import("./math/geometry/point.js").PointIdentifiers;
|
|
1894
1913
|
line: import("./math/geometry/line.js").LineIdentifiers;
|
|
1895
1914
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1915
|
+
pointsDict: Record<string, import("./math/geometry/point.js").PointIdentifiers>;
|
|
1916
|
+
nameTargetPoint: string;
|
|
1917
|
+
nameCenterPoint: string;
|
|
1918
|
+
factor: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1919
|
+
}, {
|
|
1920
|
+
isPositiveFactorOnly: boolean;
|
|
1921
|
+
factorTypes: string[];
|
|
1922
|
+
}> | Exercise<{
|
|
1923
|
+
pointsDict: Record<string, import("./math/geometry/point.js").PointIdentifiers>;
|
|
1924
|
+
nameTargetPoints: string[];
|
|
1925
|
+
nameCenterPoint: string;
|
|
1926
|
+
factor: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1927
|
+
}, {
|
|
1928
|
+
isPositiveFactorOnly: boolean;
|
|
1929
|
+
factorTypes: string[];
|
|
1930
|
+
}> | Exercise<{
|
|
1896
1931
|
type: number;
|
|
1897
1932
|
commands: string[];
|
|
1898
1933
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;AAC/D,QAAA,MAAM,aAAa
|
|
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;AAC/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Node, NodeIds, NodeOptions, NodeType, ToTexOptions } from "../node.js";
|
|
2
2
|
import { OperatorIds, OperatorNode } from "./operatorNode.js";
|
|
3
|
+
import { NumberNode } from "../numbers/numberNode.js";
|
|
4
|
+
import { MultiplyNode } from "./multiplyNode.js";
|
|
3
5
|
import { AlgebraicNode, SimplifyOptions } from "../algebraicNode.js";
|
|
4
6
|
export declare function isPowerNode(a: Node): a is PowerNode;
|
|
5
7
|
export declare function isSquareNode(a: Node): a is SquareNode;
|
|
@@ -31,6 +33,7 @@ export declare class PowerNode implements OperatorNode {
|
|
|
31
33
|
simplify(opts?: SimplifyOptions, _log?: boolean): AlgebraicNode;
|
|
32
34
|
equals(node: AlgebraicNode): boolean;
|
|
33
35
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
36
|
+
toMultiplyNode(): AlgebraicNode | import("../numbers/constantNode.js").ConstantNode | NumberNode | MultiplyNode;
|
|
34
37
|
}
|
|
35
38
|
export declare class SquareNode extends PowerNode {
|
|
36
39
|
constructor(child: AlgebraicNode, opts?: NodeOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"powerNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/powerNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAgB,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,YAAY,EAA4B,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAOrE,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,SAAS,CAEnD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,UAAU,CAErD;AACD,eAAO,MAAM,MAAM,GAAI,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,eAKxD,CAAC;AAEF,eAAO,MAAM,KAAK,GAChB,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,EAClC,GAAG,aAAa,GAAG,MAAM,GAAG,MAAM,EAClC,OAAO,WAAW,cAOnB,CAAC;AAEF,qBAAa,SAAU,YAAW,YAAY;IAC5C,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,YAAY,IAAI,MAAM;IAGtB,aAAa;;;;;;;;;IAOb,iBAAiB;IAqBjB,cAAc,IAAI,MAAM,EAAE;IAI1B,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM;IA0BlC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAOxD,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,EAAE,IAAI,UAAQ,GAAG,aAAa;IA6D7D,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO;IAOpC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;IAcvD,cAAc;CASf;AAED,qBAAa,UAAW,SAAQ,SAAS;gBAC3B,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,WAAW;CAIrD"}
|
|
@@ -7,6 +7,7 @@ import { isSqrtNode } from "../functions/sqrtNode.js";
|
|
|
7
7
|
import { round } from "../../../math/utils/round.js";
|
|
8
8
|
import { FractionNode, isFractionNode } from "./fractionNode.js";
|
|
9
9
|
import { FunctionsIds, isFunctionNode } from "../functions/functionNode.js";
|
|
10
|
+
import { operatorComposition } from "../../../tree/utilities/operatorComposition.js";
|
|
10
11
|
export function isPowerNode(a) {
|
|
11
12
|
return isOperatorNode(a) && a.id === OperatorIds.power;
|
|
12
13
|
}
|
|
@@ -156,6 +157,17 @@ export class PowerNode {
|
|
|
156
157
|
throw Error("unimplemented");
|
|
157
158
|
return multiply(multiply(this.rightChild, power(this.leftChild, this.rightChild.value - 1)), this.leftChild.derivative(varName));
|
|
158
159
|
}
|
|
160
|
+
toMultiplyNode() {
|
|
161
|
+
if (this.rightChild.evaluate() === 1)
|
|
162
|
+
return this.leftChild;
|
|
163
|
+
if (this.rightChild.evaluate() === 0)
|
|
164
|
+
return (1).toTree();
|
|
165
|
+
const lefts = [];
|
|
166
|
+
for (let i = 0; i < this.rightChild.evaluate(); i++) {
|
|
167
|
+
lefts.push(this.leftChild);
|
|
168
|
+
}
|
|
169
|
+
return operatorComposition(MultiplyNode, lefts);
|
|
170
|
+
}
|
|
159
171
|
}
|
|
160
172
|
export class SquareNode extends PowerNode {
|
|
161
173
|
constructor(child, opts) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const joinanded: (arrStr: string[], separator
|
|
1
|
+
export declare const joinanded: (arrStr: string[], separator?: string, lastSeparator?: string) => string;
|
|
2
2
|
//# sourceMappingURL=joinanded.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joinanded.d.ts","sourceRoot":"","sources":["../../../src/utils/strings/joinanded.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GACpB,QAAQ,MAAM,EAAE,EAChB,
|
|
1
|
+
{"version":3,"file":"joinanded.d.ts","sourceRoot":"","sources":["../../../src/utils/strings/joinanded.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GACpB,QAAQ,MAAM,EAAE,EAChB,YAAW,MAAa,EACxB,gBAAe,MAAe,WAW/B,CAAC"}
|