math-exercises 3.0.199 → 3.0.200
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/exercise.d.ts +14 -1
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/math/_debug/debugReorder1.d.ts +8 -0
- package/lib/exercises/math/_debug/debugReorder1.d.ts.map +1 -0
- package/lib/exercises/math/_debug/debugReorder1.js +81 -0
- package/lib/exercises/math/_debug/debugReorder2.d.ts +10 -0
- package/lib/exercises/math/_debug/debugReorder2.d.ts.map +1 -0
- package/lib/exercises/math/_debug/debugReorder2.js +88 -0
- package/lib/exercises/math/_debug/debugReorder3.d.ts +10 -0
- package/lib/exercises/math/_debug/debugReorder3.d.ts.map +1 -0
- package/lib/exercises/math/_debug/debugReorder3.js +81 -0
- package/lib/exercises/math/_debug/index.d.ts +3 -1
- package/lib/exercises/math/_debug/index.d.ts.map +1 -1
- package/lib/exercises/math/_debug/index.js +3 -1
- package/lib/exercises/math/calcul/factorial/index.d.ts +2 -0
- package/lib/exercises/math/calcul/factorial/index.d.ts.map +1 -0
- package/lib/exercises/math/calcul/factorial/index.js +1 -0
- package/lib/exercises/math/calcul/factorial/simplifyQuotientOfFactorialToProduct.d.ts +8 -0
- package/lib/exercises/math/calcul/factorial/simplifyQuotientOfFactorialToProduct.d.ts.map +1 -0
- package/lib/exercises/math/calcul/factorial/simplifyQuotientOfFactorialToProduct.js +199 -0
- package/lib/exercises/math/combinatory/combination/index.d.ts +3 -0
- package/lib/exercises/math/combinatory/combination/index.d.ts.map +1 -0
- package/lib/exercises/math/combinatory/combination/index.js +2 -0
- package/lib/exercises/math/combinatory/combination/mentalCalculateCombination.d.ts +11 -0
- package/lib/exercises/math/combinatory/combination/mentalCalculateCombination.d.ts.map +1 -0
- package/lib/exercises/math/combinatory/combination/mentalCalculateCombination.js +225 -0
- package/lib/exercises/math/combinatory/combination/writeCombinationFormulaUsingFactorial.d.ts +13 -0
- package/lib/exercises/math/combinatory/combination/writeCombinationFormulaUsingFactorial.d.ts.map +1 -0
- package/lib/exercises/math/combinatory/combination/writeCombinationFormulaUsingFactorial.js +285 -0
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotInterpreting.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.d.ts +9 -0
- package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/trigo/productOfSinAXPlusBCosCXPlusDDerivative.js +209 -0
- package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.d.ts +9 -0
- package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/trigo/sinAndCosMixedWithSquareDerivative.js +359 -0
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.d.ts +11 -0
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.d.ts.map +1 -0
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +445 -0
- package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineVarTableOnBoundedInterval.js +2 -3
- package/lib/exercises/math/index.d.ts +1 -0
- package/lib/exercises/math/index.d.ts.map +1 -1
- package/lib/exercises/math/index.js +1 -1
- package/lib/exercises/math/limits/sequenceGeometricLimit.d.ts.map +1 -1
- package/lib/exercises/math/limits/sequenceGeometricLimit.js +9 -0
- package/lib/exercises/math/primitive/constantPrimitive.d.ts +8 -5
- package/lib/exercises/math/primitive/constantPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/constantPrimitive.js +40 -21
- package/lib/exercises/math/probaStat/stats2var/averagePoint.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats2var/averagePoint.js +34 -2
- package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdFromGraph.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdFromGraph.js +255 -0
- package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdUsingCalculator.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdUsingCalculator.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/graph/geometricFindThresholdUsingCalculator.js +242 -0
- package/lib/exercises/math/sequences/geometric/graph/geometricPlaceFirstPoints.js +4 -4
- package/lib/exercises/math/sequences/geometric/graph/geometricSignOfReasonFromGraph.d.ts +12 -0
- package/lib/exercises/math/sequences/geometric/graph/geometricSignOfReasonFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/graph/geometricSignOfReasonFromGraph.js +161 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.d.ts +10 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.d.ts.map +1 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.js +224 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.d.ts +18 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.js +198 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfPowEK.d.ts +10 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfPowEK.d.ts.map +1 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfPowEK.js +231 -0
- package/lib/exercises/math/sets/cartesianProduct/findNumberOfPasswordsWithLettersAndNumbers.d.ts +19 -0
- package/lib/exercises/math/sets/cartesianProduct/findNumberOfPasswordsWithLettersAndNumbers.d.ts.map +1 -0
- package/lib/exercises/math/sets/cartesianProduct/findNumberOfPasswordsWithLettersAndNumbers.js +187 -0
- package/lib/exercises/math/sets/cartesianProduct/index.d.ts +7 -0
- package/lib/exercises/math/sets/cartesianProduct/index.d.ts.map +1 -0
- package/lib/exercises/math/sets/cartesianProduct/index.js +6 -0
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.d.ts +15 -0
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.d.ts.map +1 -0
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.js +291 -0
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInPowEK.d.ts +15 -0
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInPowEK.d.ts.map +1 -0
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInPowEK.js +274 -0
- package/lib/exercises/math/sets/combinations/findNumberOfCombinationsFromSituation.d.ts +17 -0
- package/lib/exercises/math/sets/combinations/findNumberOfCombinationsFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sets/combinations/findNumberOfCombinationsFromSituation.js +228 -0
- package/lib/exercises/math/sets/combinations/findNumberOfProductsOfCombinationsFromSituation.d.ts +17 -0
- package/lib/exercises/math/sets/combinations/findNumberOfProductsOfCombinationsFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sets/combinations/findNumberOfProductsOfCombinationsFromSituation.js +388 -0
- package/lib/exercises/math/sets/combinations/index.d.ts +4 -0
- package/lib/exercises/math/sets/combinations/index.d.ts.map +1 -0
- package/lib/exercises/math/sets/combinations/index.js +3 -0
- package/lib/exercises/math/sets/combinations/proposeCombination.d.ts +15 -0
- package/lib/exercises/math/sets/combinations/proposeCombination.d.ts.map +1 -0
- package/lib/exercises/math/sets/combinations/proposeCombination.js +347 -0
- package/lib/exercises/math/sets/partialPermutations/findNumberOfPartialPermutationsFromSituation.d.ts +16 -0
- package/lib/exercises/math/sets/partialPermutations/findNumberOfPartialPermutationsFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sets/partialPermutations/findNumberOfPartialPermutationsFromSituation.js +186 -0
- package/lib/exercises/math/sets/partialPermutations/findNumberOfPermutationsFromSituation.d.ts +17 -0
- package/lib/exercises/math/sets/partialPermutations/findNumberOfPermutationsFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sets/partialPermutations/findNumberOfPermutationsFromSituation.js +232 -0
- package/lib/exercises/math/sets/partialPermutations/index.d.ts +4 -0
- package/lib/exercises/math/sets/partialPermutations/index.d.ts.map +1 -0
- package/lib/exercises/math/sets/partialPermutations/index.js +3 -0
- package/lib/exercises/math/sets/partialPermutations/proposePartialPermutation.d.ts +15 -0
- package/lib/exercises/math/sets/partialPermutations/proposePartialPermutation.d.ts.map +1 -0
- package/lib/exercises/math/sets/partialPermutations/proposePartialPermutation.js +343 -0
- package/lib/exercises/math/trigonometry/functions/parityOfCosAXTimesSinBX.d.ts +8 -0
- package/lib/exercises/math/trigonometry/functions/parityOfCosAXTimesSinBX.d.ts.map +1 -0
- package/lib/exercises/math/trigonometry/functions/parityOfCosAXTimesSinBX.js +193 -0
- package/lib/index.d.ts +15 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/math/sets/setOperations.d.ts +9 -0
- package/lib/math/sets/setOperations.d.ts.map +1 -0
- package/lib/math/sets/setOperations.js +84 -0
- package/lib/math/sets/tuple.d.ts +12 -0
- package/lib/math/sets/tuple.d.ts.map +1 -0
- package/lib/math/sets/tuple.js +17 -0
- package/lib/server.js +25 -0
- package/lib/tree/utilities/nodePrinter.d.ts +7 -0
- package/lib/tree/utilities/nodePrinter.d.ts.map +1 -0
- package/lib/tree/utilities/nodePrinter.js +36 -0
- package/package.json +1 -1
|
@@ -0,0 +1,193 @@
|
|
|
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 { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
5
|
+
import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
6
|
+
import { alignTex } from "../../../../utils/latex/alignTex.js";
|
|
7
|
+
import { NodeConstructor, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
8
|
+
import { multiply, } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { FunctionsIds, } from "../../../../tree/nodes/functions/functionNode.js";
|
|
10
|
+
import { random } from "../../../../utils/alea/random.js";
|
|
11
|
+
import { sin } from "../../../../tree/nodes/functions/sinNode.js";
|
|
12
|
+
import { cos } from "../../../../tree/nodes/functions/cosNode.js";
|
|
13
|
+
import { VariableNode } from "../../../../tree/nodes/variables/variableNode.js";
|
|
14
|
+
import { nodeBySubstitutingVar } from "../../../../math/utils/functions/functionComposition.js";
|
|
15
|
+
const rewriteFunctionNode = (nodeFunc) => {
|
|
16
|
+
const isChildMinusSigned = nodeFunc.child
|
|
17
|
+
.simplify({ towardsDistribute: true })
|
|
18
|
+
.toTex()
|
|
19
|
+
.startsWith("-");
|
|
20
|
+
if (isChildMinusSigned) {
|
|
21
|
+
switch (nodeFunc.id) {
|
|
22
|
+
case FunctionsIds.cos:
|
|
23
|
+
return cos(opposite(nodeFunc.child).simplify());
|
|
24
|
+
case FunctionsIds.sin:
|
|
25
|
+
return opposite(sin(opposite(nodeFunc.child).simplify()));
|
|
26
|
+
default:
|
|
27
|
+
return nodeFunc;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return nodeFunc;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const rewriteNodeF = (nodeF) => {
|
|
35
|
+
return multiply(rewriteFunctionNode(nodeF.leftChild), rewriteFunctionNode(nodeF.rightChild));
|
|
36
|
+
};
|
|
37
|
+
const getParityType = (nodeF) => {
|
|
38
|
+
const [bit1, bit2] = [
|
|
39
|
+
nodeF.leftChild,
|
|
40
|
+
nodeF.rightChild,
|
|
41
|
+
].map((node) => (node.id === FunctionsIds.sin ? 1 : 0));
|
|
42
|
+
if ((bit1 + bit2) % 2 === 0) {
|
|
43
|
+
return "even";
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return "uneven";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const getInstruction = (identifiers) => {
|
|
50
|
+
const { nodeIdsF } = identifiers;
|
|
51
|
+
const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
|
|
52
|
+
return `Soit $f$ la fonction définie par :
|
|
53
|
+
|
|
54
|
+
$$
|
|
55
|
+
f(x) = ${nodeF.toTex()}
|
|
56
|
+
$$
|
|
57
|
+
|
|
58
|
+
La fonction $f$ est-elle paire, impaire, ou ni paire ni impaire ?`;
|
|
59
|
+
};
|
|
60
|
+
const getAnswer = (identifiers) => {
|
|
61
|
+
const { nodeIdsF } = identifiers;
|
|
62
|
+
const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
|
|
63
|
+
const type = getParityType(nodeF);
|
|
64
|
+
switch (type) {
|
|
65
|
+
case "even":
|
|
66
|
+
return "Paire";
|
|
67
|
+
case "uneven":
|
|
68
|
+
return "Impaire";
|
|
69
|
+
default:
|
|
70
|
+
return "Ni paire, ni impaire";
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const getHint = () => {
|
|
74
|
+
return `Une fonction $f$ est paire si pour tout $x$ de son ensemble de définition, on a : $f(-x) = f(x)$.
|
|
75
|
+
|
|
76
|
+
Une fonction $f$ est impaire si pour tout $x$ de son ensemble de définition, on a : $f(-x) = -f(x)$.`;
|
|
77
|
+
};
|
|
78
|
+
const getCorrection = (identifiers) => {
|
|
79
|
+
const { nodeIdsF } = identifiers;
|
|
80
|
+
const nodeF = NodeConstructor.fromIdentifiers(nodeIdsF);
|
|
81
|
+
const type = getParityType(nodeF);
|
|
82
|
+
const nodeFRewritten = rewriteNodeF(nodeF);
|
|
83
|
+
const isNodeFRewritable = nodeFRewritten.toTex() !== nodeF.toTex();
|
|
84
|
+
const nodeVarX = new VariableNode("x");
|
|
85
|
+
const nodeFOfMinusX = nodeBySubstitutingVar(nodeF, opposite(nodeVarX), nodeVarX);
|
|
86
|
+
const nodeFOfMinusXRewritten1 = multiply(nodeFOfMinusX.leftChild.simplify(), nodeFOfMinusX.rightChild.simplify());
|
|
87
|
+
const nodeFOfMinusXRewritten2 = rewriteNodeF(nodeFOfMinusXRewritten1);
|
|
88
|
+
return `${isNodeFRewritable
|
|
89
|
+
? `On peut réécrire $f(x)$ :
|
|
90
|
+
|
|
91
|
+
${alignTex([
|
|
92
|
+
["f(x)", "=", nodeF.toTex()],
|
|
93
|
+
["", "=", nodeFRewritten.toTex({ forceParenthesis: true })],
|
|
94
|
+
...(() => {
|
|
95
|
+
const texNodeFRewrittenSimplified = nodeFRewritten.simplify().toTex();
|
|
96
|
+
if (texNodeFRewrittenSimplified !==
|
|
97
|
+
nodeFRewritten.toTex({ forceParenthesis: true })) {
|
|
98
|
+
return [["", "=", texNodeFRewrittenSimplified]];
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
})(),
|
|
104
|
+
])}
|
|
105
|
+
|
|
106
|
+
`
|
|
107
|
+
: ``}
|
|
108
|
+
|
|
109
|
+
On exprime $f(-x)$ :
|
|
110
|
+
|
|
111
|
+
${alignTex([
|
|
112
|
+
["f(-x)", "=", nodeFOfMinusX.toTex()],
|
|
113
|
+
["", "=", nodeFOfMinusXRewritten1.toTex()],
|
|
114
|
+
...(() => {
|
|
115
|
+
const texNodeFOfMinusXRewritten2 = nodeFOfMinusXRewritten2.toTex({
|
|
116
|
+
forceParenthesis: true,
|
|
117
|
+
});
|
|
118
|
+
if (texNodeFOfMinusXRewritten2 !== nodeFOfMinusXRewritten1.toTex()) {
|
|
119
|
+
return [["", "=", texNodeFOfMinusXRewritten2]];
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
})(),
|
|
125
|
+
...(() => {
|
|
126
|
+
const texNodeFOfMinusXRewritten2Simplified = nodeFOfMinusXRewritten2
|
|
127
|
+
.simplify()
|
|
128
|
+
.toTex();
|
|
129
|
+
if (texNodeFOfMinusXRewritten2Simplified !==
|
|
130
|
+
nodeFOfMinusXRewritten2.toTex({ forceParenthesis: true })) {
|
|
131
|
+
return [["", "=", texNodeFOfMinusXRewritten2Simplified]];
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
})(),
|
|
137
|
+
])}
|
|
138
|
+
|
|
139
|
+
${type === "even"
|
|
140
|
+
? "Puisque $f(-x) = f(x)$, la fonction $f$ est paire."
|
|
141
|
+
: `Puisque $f(-x) = -f(x)$, la fonction $f$ est impaire.`}
|
|
142
|
+
`;
|
|
143
|
+
};
|
|
144
|
+
const getPropositions = (n, { answer }) => {
|
|
145
|
+
const propositions = [];
|
|
146
|
+
addValidProp(propositions, answer, "raw");
|
|
147
|
+
tryToAddWrongProp(propositions, "Paire", "raw");
|
|
148
|
+
tryToAddWrongProp(propositions, "Impaire", "raw");
|
|
149
|
+
tryToAddWrongProp(propositions, "Ni paire, ni impaire", "raw");
|
|
150
|
+
tryToAddWrongProp(propositions, "On ne peut pas savoir", "raw");
|
|
151
|
+
return shuffleProps(propositions, n);
|
|
152
|
+
};
|
|
153
|
+
const getParityOfCosAXTimesSinBXQuestion = () => {
|
|
154
|
+
const nodeVarX = new VariableNode("x");
|
|
155
|
+
const nodeFactor1 = ((coinFlip() ? +1 : -1) * randint(1, 10)).toTree();
|
|
156
|
+
const node1 = multiply(nodeFactor1, nodeVarX);
|
|
157
|
+
const nodeFactor2 = ((coinFlip() ? +1 : -1) * randint(1, 10)).toTree();
|
|
158
|
+
const node2 = multiply(nodeFactor2, nodeVarX);
|
|
159
|
+
const [func1, func2] = random([
|
|
160
|
+
[sin, sin],
|
|
161
|
+
[sin, cos],
|
|
162
|
+
[cos, sin],
|
|
163
|
+
[cos, cos],
|
|
164
|
+
]);
|
|
165
|
+
const nodeF = multiply(func1(node1), func2(node2));
|
|
166
|
+
const identifiers = { nodeIdsF: nodeF.toIdentifiers() };
|
|
167
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
168
|
+
};
|
|
169
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
170
|
+
const question = {
|
|
171
|
+
answer: getAnswer(identifiers),
|
|
172
|
+
instruction: getInstruction(identifiers),
|
|
173
|
+
keys: [],
|
|
174
|
+
answerFormat: "raw",
|
|
175
|
+
identifiers,
|
|
176
|
+
hint: getHint(identifiers),
|
|
177
|
+
correction: getCorrection(identifiers),
|
|
178
|
+
};
|
|
179
|
+
return question;
|
|
180
|
+
};
|
|
181
|
+
export const parityOfCosAXTimesSinBX = {
|
|
182
|
+
id: "parityOfCosAXTimesSinBX",
|
|
183
|
+
label: "Déterminer si une fonction du type $\\cos(ax) \\sin(bx)$ est paire ou impaire",
|
|
184
|
+
isSingleStep: true,
|
|
185
|
+
generator: (nb) => getDistinctQuestions(getParityOfCosAXTimesSinBXQuestion, nb),
|
|
186
|
+
qcmTimer: 60,
|
|
187
|
+
freeTimer: 60,
|
|
188
|
+
getPropositions,
|
|
189
|
+
answerType: "QCU",
|
|
190
|
+
subject: "Mathématiques",
|
|
191
|
+
getQuestionFromIdentifiers,
|
|
192
|
+
hasHintAndCorrection: true,
|
|
193
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -3122,7 +3122,9 @@ declare const mathExercises: (Exercise<{
|
|
|
3122
3122
|
kIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
3123
3123
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3124
3124
|
c: number;
|
|
3125
|
-
},
|
|
3125
|
+
}, {
|
|
3126
|
+
askParticularPrimitive?: boolean;
|
|
3127
|
+
}> | Exercise<{
|
|
3126
3128
|
coeffs: number[];
|
|
3127
3129
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3128
3130
|
a: number;
|
|
@@ -5034,6 +5036,18 @@ declare const mathExercises: (Exercise<{
|
|
|
5034
5036
|
isGreaterCond: boolean;
|
|
5035
5037
|
k?: number;
|
|
5036
5038
|
randListAdd: number;
|
|
5039
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
5040
|
+
nodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
5041
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
5042
|
+
a: number;
|
|
5043
|
+
b: number;
|
|
5044
|
+
c: number;
|
|
5045
|
+
d: number;
|
|
5046
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
5047
|
+
a: number;
|
|
5048
|
+
b: number;
|
|
5049
|
+
c: number;
|
|
5050
|
+
d: number;
|
|
5037
5051
|
}, Record<string, string | boolean | string[]>>)[];
|
|
5038
5052
|
declare const pcExercises: (Exercise<{
|
|
5039
5053
|
numbers: number[];
|
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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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DiscreteSetNode } from "../../tree/nodes/sets/discreteSetNode.js";
|
|
2
|
+
import { Tuple } from "./tuple.js";
|
|
3
|
+
export declare const discreteSetCartesianProduct: (...arrDiscreteSet: DiscreteSetNode[]) => Tuple[];
|
|
4
|
+
export declare const randomTupleInDiscreteSetPower: (nodeDiscreteSet: DiscreteSetNode, k: number, isWithoutDuplicate: boolean, isForceDuplicate?: boolean) => Tuple;
|
|
5
|
+
export declare const randomManyTuplesInDiscreteSetPower: (nodeDiscreteSet: DiscreteSetNode, k: number, nbTuples: number, isWithoutDuplicate: boolean, isForceDuplicate?: boolean) => Tuple[];
|
|
6
|
+
export declare const discreteSetSubstract: (discreteSetRecipient: DiscreteSetNode, ...arrDiscreteSet: DiscreteSetNode[]) => DiscreteSetNode;
|
|
7
|
+
export declare const randomCombinationFromDiscreteSet: (nodeDiscreteSet: DiscreteSetNode, k: number) => DiscreteSetNode;
|
|
8
|
+
export declare const randomManyCombinationsFromDiscreteSet: (nodeDiscreteSet: DiscreteSetNode, k: number, nbMany: number) => DiscreteSetNode[];
|
|
9
|
+
//# sourceMappingURL=setOperations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setOperations.d.ts","sourceRoot":"","sources":["../../../src/math/sets/setOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAO3E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,eAAO,MAAM,2BAA2B,GACtC,GAAG,gBAAgB,eAAe,EAAE,YAOrC,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,iBAAiB,eAAe,EAChC,GAAG,MAAM,EACT,oBAAoB,OAAO,EAC3B,mBAAkB,OAAe,UA0BlC,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,iBAAiB,eAAe,EAChC,GAAG,MAAM,EACT,UAAU,MAAM,EAChB,oBAAoB,OAAO,EAC3B,mBAAmB,OAAO,YAqB3B,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,sBAAsB,eAAe,EACrC,GAAG,gBAAgB,eAAe,EAAE,oBAWrC,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAC3C,iBAAiB,eAAe,EAChC,GAAG,MAAM,oBAeV,CAAC;AAEF,eAAO,MAAM,qCAAqC,GAChD,iBAAiB,eAAe,EAChC,GAAG,MAAM,EACT,QAAQ,MAAM,sBAuBf,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { DiscreteSetNode } from "../../tree/nodes/sets/discreteSetNode.js";
|
|
2
|
+
import { isVariableNode } from "../../tree/nodes/variables/variableNode.js";
|
|
3
|
+
import { NodeComparator } from "../../tree/utilities/nodeComparator.js";
|
|
4
|
+
import { random } from "../../utils/alea/random.js";
|
|
5
|
+
import { shuffle } from "../../utils/alea/shuffle.js";
|
|
6
|
+
import { zip } from "../../utils/arrays/arrayZip.js";
|
|
7
|
+
import { getFlatCartesianProducts } from "../../utils/arrays/cartesianProducts.js";
|
|
8
|
+
import { Tuple } from "./tuple.js";
|
|
9
|
+
export const discreteSetCartesianProduct = (...arrDiscreteSet) => {
|
|
10
|
+
return getFlatCartesianProducts(arrDiscreteSet.map((discreteSetNode) => discreteSetNode.elements))
|
|
11
|
+
.map((arrNode) => new Tuple(arrNode))
|
|
12
|
+
.toSorted((tuple1, tuple2) => tuple1.toTex().localeCompare(tuple2.toTex()));
|
|
13
|
+
};
|
|
14
|
+
export const randomTupleInDiscreteSetPower = (nodeDiscreteSet, k, isWithoutDuplicate, isForceDuplicate = false) => {
|
|
15
|
+
if (isWithoutDuplicate) {
|
|
16
|
+
if (k > nodeDiscreteSet.elements.length) {
|
|
17
|
+
throw new Error("k > nodeDiscreteSet.elements.length");
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return new Tuple(shuffle(shuffle(nodeDiscreteSet.elements).slice(0, k)));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (isForceDuplicate) {
|
|
25
|
+
const nodeDuplicated = random(nodeDiscreteSet.elements);
|
|
26
|
+
return new Tuple(shuffle([
|
|
27
|
+
nodeDuplicated,
|
|
28
|
+
nodeDuplicated,
|
|
29
|
+
...[...Array(k - 2).keys()].map(() => random(nodeDiscreteSet.elements)),
|
|
30
|
+
]));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return new Tuple([...Array(k).keys()].map(() => random(nodeDiscreteSet.elements)));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const randomManyTuplesInDiscreteSetPower = (nodeDiscreteSet, k, nbTuples, isWithoutDuplicate, isForceDuplicate) => {
|
|
38
|
+
const arrTuple = [];
|
|
39
|
+
let counter = -1;
|
|
40
|
+
while (arrTuple.length < nbTuples && counter < 1000) {
|
|
41
|
+
counter++;
|
|
42
|
+
const tupleCandidate = randomTupleInDiscreteSetPower(nodeDiscreteSet, k, isWithoutDuplicate, isForceDuplicate);
|
|
43
|
+
const isTupleAlreadyAdded = () => NodeComparator.isTupleInArrTuple(tupleCandidate, arrTuple);
|
|
44
|
+
if (!isTupleAlreadyAdded()) {
|
|
45
|
+
const tuple = tupleCandidate;
|
|
46
|
+
arrTuple.push(tuple);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return arrTuple;
|
|
50
|
+
};
|
|
51
|
+
export const discreteSetSubstract = (discreteSetRecipient, ...arrDiscreteSet) => {
|
|
52
|
+
const arrNode = discreteSetRecipient.elements.filter((nodeCandidate) => !arrDiscreteSet.some((discreteSetForbidden) => discreteSetForbidden.elements.some((nodeForbidden) => NodeComparator.isEqualViaSub(nodeCandidate, nodeForbidden))));
|
|
53
|
+
return new DiscreteSetNode(arrNode);
|
|
54
|
+
};
|
|
55
|
+
export const randomCombinationFromDiscreteSet = (nodeDiscreteSet, k) => {
|
|
56
|
+
if (k > nodeDiscreteSet.elements.length) {
|
|
57
|
+
throw new Error("k > nodeDiscreteSet.elements.length");
|
|
58
|
+
}
|
|
59
|
+
const arrElement = shuffle(nodeDiscreteSet.elements)
|
|
60
|
+
.slice(0, k)
|
|
61
|
+
.toSorted((node1, node2) => {
|
|
62
|
+
if (isVariableNode(node1) && isVariableNode(node2)) {
|
|
63
|
+
return node1.toTex().localeCompare(node2.toTex());
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return NodeComparator.compareViaSub(node1, node2);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return new DiscreteSetNode(arrElement);
|
|
70
|
+
};
|
|
71
|
+
export const randomManyCombinationsFromDiscreteSet = (nodeDiscreteSet, k, nbMany) => {
|
|
72
|
+
const arrCombination = [];
|
|
73
|
+
let counter = -1;
|
|
74
|
+
while (arrCombination.length < nbMany && counter < 1000) {
|
|
75
|
+
counter++;
|
|
76
|
+
const combinationCandidate = randomCombinationFromDiscreteSet(nodeDiscreteSet, k);
|
|
77
|
+
const isCombinationAlreadyAdded = () => arrCombination.some((combinationOfArr) => zip(combinationCandidate.elements, combinationOfArr.elements).every(([node1, node2]) => NodeComparator.isEqualViaSub(node1, node2)));
|
|
78
|
+
if (!isCombinationAlreadyAdded()) {
|
|
79
|
+
const combination = combinationCandidate;
|
|
80
|
+
arrCombination.push(combination);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return arrCombination;
|
|
84
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
export type TupleIdentifiers = {
|
|
4
|
+
components: NodeIdentifiers[];
|
|
5
|
+
};
|
|
6
|
+
export declare class Tuple {
|
|
7
|
+
components: AlgebraicNode[];
|
|
8
|
+
constructor(components: AlgebraicNode[]);
|
|
9
|
+
toTex(): string;
|
|
10
|
+
toIdentifiers(): TupleIdentifiers;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=tuple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../../../src/math/sets/tuple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAQtE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAC;AAEF,qBAAa,KAAK;IACG,UAAU,EAAE,aAAa,EAAE;gBAA3B,UAAU,EAAE,aAAa,EAAE;IAE9C,KAAK,IAAI,MAAM;IAOf,aAAa,IAAI,gBAAgB;CAKlC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class Tuple {
|
|
2
|
+
components;
|
|
3
|
+
constructor(components) {
|
|
4
|
+
this.components = components;
|
|
5
|
+
}
|
|
6
|
+
toTex() {
|
|
7
|
+
const strSeparator = ";";
|
|
8
|
+
return `\\left(${this.components
|
|
9
|
+
.map((node) => node.toTex())
|
|
10
|
+
.join(strSeparator)}\\right)`;
|
|
11
|
+
}
|
|
12
|
+
toIdentifiers() {
|
|
13
|
+
return {
|
|
14
|
+
components: this.components.map((node) => node.toIdentifiers()),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
package/lib/server.js
CHANGED
|
@@ -101,6 +101,31 @@ const runServer = () => {
|
|
|
101
101
|
const props = exo.getPropositions(n, { answer, ...identifiers }, options);
|
|
102
102
|
res.json(props);
|
|
103
103
|
});
|
|
104
|
+
app.get("/getOrderedItems", (req, res) => {
|
|
105
|
+
const n = Number(req.query.n) || 4;
|
|
106
|
+
const exoId = req.query.exoId;
|
|
107
|
+
const options = req.query.options
|
|
108
|
+
? JSON.parse(decodeURIComponent(req.query.options))
|
|
109
|
+
: undefined;
|
|
110
|
+
const identifiers = req.query.identifiers
|
|
111
|
+
? JSON.parse(decodeURIComponent(req.query.identifiers))
|
|
112
|
+
: undefined;
|
|
113
|
+
const hasAnswer = !!req.query.answer && req.query.answer !== "undefined";
|
|
114
|
+
const answer = hasAnswer
|
|
115
|
+
? JSON.parse(decodeURIComponent(req.query.answer))
|
|
116
|
+
: "";
|
|
117
|
+
const exo = allExercises.find((exo) => exo.id == exoId);
|
|
118
|
+
if (!exo) {
|
|
119
|
+
res.send("Exo not found");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (!exo?.getOrderedItems) {
|
|
123
|
+
res.send("no getOrderedItems");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const props = exo.getOrderedItems(n, { answer, ...identifiers }, options);
|
|
127
|
+
res.json(props);
|
|
128
|
+
});
|
|
104
129
|
app.get("/isAnswerTableValid", (req, res) => {
|
|
105
130
|
const exoId = req.query.exoId;
|
|
106
131
|
const options = req.query.options
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../nodes/algebraicNode.js";
|
|
2
|
+
import { OperatorNode } from "../nodes/operators/operatorNode.js";
|
|
3
|
+
export declare abstract class NodePrinter {
|
|
4
|
+
static toTexWithMaxWidth(node: AlgebraicNode, maxWidth: number): string;
|
|
5
|
+
static strSymbolForOperatorNode(operatorNode: OperatorNode): string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=nodePrinter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodePrinter.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodePrinter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAGL,YAAY,EACb,MAAM,oCAAoC,CAAC;AAG5C,8BAAsB,WAAW;IAC/B,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAsBvE,MAAM,CAAC,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;CAcpE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isOperatorNode, OperatorIds, } from "../nodes/operators/operatorNode.js";
|
|
2
|
+
import { alignTex } from "../../utils/latex/alignTex.js";
|
|
3
|
+
export class NodePrinter {
|
|
4
|
+
static toTexWithMaxWidth(node, maxWidth) {
|
|
5
|
+
const texRaw = node.toTex();
|
|
6
|
+
if (texRaw.length < maxWidth) {
|
|
7
|
+
return texRaw;
|
|
8
|
+
}
|
|
9
|
+
if (isOperatorNode(node)) {
|
|
10
|
+
return alignTex([
|
|
11
|
+
["", this.toTexWithMaxWidth(node.leftChild, maxWidth)],
|
|
12
|
+
[
|
|
13
|
+
this.strSymbolForOperatorNode(node),
|
|
14
|
+
`( ${this.toTexWithMaxWidth(node.rightChild, maxWidth - 2)} )`,
|
|
15
|
+
],
|
|
16
|
+
], true);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return texRaw;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
static strSymbolForOperatorNode(operatorNode) {
|
|
23
|
+
switch (operatorNode.id) {
|
|
24
|
+
case OperatorIds.add:
|
|
25
|
+
return ` + `;
|
|
26
|
+
case OperatorIds.substract:
|
|
27
|
+
return ` - `;
|
|
28
|
+
case OperatorIds.multiply:
|
|
29
|
+
return ` \\times `;
|
|
30
|
+
case OperatorIds.divide:
|
|
31
|
+
return ` \\div `;
|
|
32
|
+
default:
|
|
33
|
+
throw new Error("Unimplemented operatorNode.id: " + operatorNode.id);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|