math-exercises 3.0.172 → 3.0.173
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/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +12 -0
- package/lib/exercises/math/functions/trinoms/parabole/index.d.ts +2 -0
- package/lib/exercises/math/functions/trinoms/parabole/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/parabole/index.js +2 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts +8 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.js +106 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts +14 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.js +186 -0
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts +6 -2
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.js +98 -13
- package/lib/exercises/math/geometry/lines/index.d.ts +1 -0
- package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/lines/index.js +1 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts +13 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts.map +1 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.js +195 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/index.js +1 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.js +119 -0
- package/lib/exercises/math/python/sequences/index.d.ts +8 -0
- package/lib/exercises/math/python/sequences/index.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/index.js +7 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts +11 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.js +274 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts +12 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.js +368 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts +13 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.js +254 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts +14 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.js +365 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts +11 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.js +298 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts +12 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.js +408 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts +17 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.js +498 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts +12 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.js +191 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.js +153 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +184 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.js +210 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.js +161 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts +17 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +188 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +6 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.js +5 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.js +233 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts +13 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.js +111 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts +13 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.js +216 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts +7 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.js +94 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts +5 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.js +4 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +301 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +260 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +186 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.js +142 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.js +205 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.js +208 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts +17 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.js +152 -0
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts +4 -0
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/index.js +5 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.js +248 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.js +126 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts +8 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.js +91 -0
- package/lib/exercises/math/sequences/geometric/sum/index.d.ts +4 -0
- package/lib/exercises/math/sequences/geometric/sum/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/index.js +3 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts +2 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.js +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts +14 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts.map +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.js +202 -0
- package/lib/exercises/options/optionFirstTermRankOne.d.ts +16 -0
- package/lib/exercises/options/optionFirstTermRankOne.d.ts.map +1 -0
- package/lib/exercises/options/optionFirstTermRankOne.js +17 -0
- package/lib/exercises/options/optionIsUsePythonDef.d.ts +16 -0
- package/lib/exercises/options/optionIsUsePythonDef.d.ts.map +1 -0
- package/lib/exercises/options/optionIsUsePythonDef.js +17 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.d.ts +16 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.d.ts.map +1 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.js +17 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
- package/lib/exercises/vea/colinearVectorVEA.d.ts +2 -0
- package/lib/exercises/vea/colinearVectorVEA.d.ts.map +1 -0
- package/lib/exercises/vea/colinearVectorVEA.js +11 -0
- package/lib/exercises/vea/varLineVEA.d.ts.map +1 -1
- package/lib/exercises/vea/varLineVEA.js +5 -2
- package/lib/index.d.ts +25 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/line.d.ts +1 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +3 -3
- package/lib/math/geometry/point.d.ts +1 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +4 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +53 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +1928 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +15 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +136 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts +42 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.js +932 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts +12 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.js +90 -0
- package/lib/tests/exosTest.d.ts.map +1 -1
- package/lib/tests/exosTest.js +0 -2
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts +3 -3
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/binomialCoefficientNode.js +6 -3
- package/lib/tree/parsers/vectorParser.d.ts.map +1 -1
- package/lib/tree/parsers/vectorParser.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, GeneratorOptionType, GeneratorOptionTarget, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { colinearVectorVEA } from "../../../../exercises/vea/colinearVectorVEA.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { Line } from "../../../../math/geometry/line.js";
|
|
6
|
+
import { PointConstructor, } from "../../../../math/geometry/point.js";
|
|
7
|
+
import { Vector, VectorConstructor } from "../../../../math/geometry/vector.js";
|
|
8
|
+
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
9
|
+
import { opposite } from "../../../../tree/nodes/functions/oppositeNode.js";
|
|
10
|
+
import { vectorParser } from "../../../../tree/parsers/vectorParser.js";
|
|
11
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
|
+
const getPropositions = (n, { answer }) => {
|
|
13
|
+
const propositions = [];
|
|
14
|
+
addValidProp(propositions, answer);
|
|
15
|
+
propWhile(propositions, n, () => {
|
|
16
|
+
const vec = VectorConstructor.random("v");
|
|
17
|
+
const sol = vectorParser(answer);
|
|
18
|
+
if (!sol)
|
|
19
|
+
throw new Error("answer malformed in readLineNormalVectorOnGraph");
|
|
20
|
+
if (vec.isColinear(sol))
|
|
21
|
+
return;
|
|
22
|
+
tryToAddWrongProp(propositions, vec.toBinomCoords().toTex());
|
|
23
|
+
});
|
|
24
|
+
return shuffleProps(propositions, n);
|
|
25
|
+
};
|
|
26
|
+
const getAnswer = (identifiers) => {
|
|
27
|
+
const { point1Ids, point2Ids, point3Ids } = identifiers;
|
|
28
|
+
const point1 = PointConstructor.fromIdentifiers(point1Ids);
|
|
29
|
+
const point2 = PointConstructor.fromIdentifiers(point2Ids);
|
|
30
|
+
if (point3Ids) {
|
|
31
|
+
//perp tracée
|
|
32
|
+
const point3 = PointConstructor.fromIdentifiers(point3Ids);
|
|
33
|
+
const vector = VectorConstructor.fromPoints(point2, point3);
|
|
34
|
+
return vector.simplify().toBinomCoords().toTex();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const vector = VectorConstructor.fromPoints(point1, point2);
|
|
38
|
+
const normal = vector.getOrthogonal();
|
|
39
|
+
return normal.toBinomCoords().toTex();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const getInstruction = (_identifiers, opts) => {
|
|
43
|
+
if (opts?.withoutPerp) {
|
|
44
|
+
return `Ci-dessous est tracée une droite $d$.
|
|
45
|
+
|
|
46
|
+
Déterminer graphiquement les coordonnées d'un vecteur normal à $d$.`;
|
|
47
|
+
}
|
|
48
|
+
return `Ci-dessous sont tracées deux droites perpendiculaires $d$ et $d'$.
|
|
49
|
+
|
|
50
|
+
Déterminer graphiquement les coordonnées d'un vecteur normal à $d$.`;
|
|
51
|
+
};
|
|
52
|
+
const getHint = (_identifiers, opts) => {
|
|
53
|
+
if (opts?.withoutPerp) {
|
|
54
|
+
const u = new Vector("u", "a".toTree(), "b".toTree());
|
|
55
|
+
const v = new Vector("v", opposite("b"), "a".toTree());
|
|
56
|
+
return `Détermine un vecteur directeur de $d$. Puis, utilise la propriété suivante : si $${u.toTexWithBinomCoords()}$ est un vecteur directeur de $d$, alors $${v.toTexWithBinomCoords()}$ est un vecteur normal à $d$.`;
|
|
57
|
+
}
|
|
58
|
+
return `Un vecteur normal d'une droite est un vecteur qui est orthogonal à un vecteur directeur de cette droite.
|
|
59
|
+
|
|
60
|
+
Ici, un vecteur normal à $d$ est donc également un vecteur directeur de $d'$.`;
|
|
61
|
+
};
|
|
62
|
+
const getCorrection = (identifiers) => {
|
|
63
|
+
const { point1Ids, point2Ids, point3Ids } = identifiers;
|
|
64
|
+
const point1 = PointConstructor.fromIdentifiers(point1Ids);
|
|
65
|
+
const point2 = PointConstructor.fromIdentifiers(point2Ids);
|
|
66
|
+
if (point3Ids) {
|
|
67
|
+
const point3 = PointConstructor.fromIdentifiers(point3Ids);
|
|
68
|
+
return `Un vecteur normal à la droite $d$ est un vecteur directeur de la droite $d'$.
|
|
69
|
+
|
|
70
|
+
On lit donc graphiquement un vecteur directeur de $d'$.
|
|
71
|
+
|
|
72
|
+
Cette droite passe par les points de coordonnées $${point2.toCoords()}$ et $${point3.toCoords()}$. Un vecteur directeur de $d'$ est donc :
|
|
73
|
+
|
|
74
|
+
$$
|
|
75
|
+
${VectorConstructor.fromPoints(point2, point3).toBinomCoords().toTex()}
|
|
76
|
+
$$
|
|
77
|
+
|
|
78
|
+
C'est un vecteur normal à $d$.`;
|
|
79
|
+
}
|
|
80
|
+
const u = new Vector("u", "a".toTree(), "b".toTree());
|
|
81
|
+
const v = new Vector("v", opposite("b"), "a".toTree());
|
|
82
|
+
return `La droite $d$ passe par les points de coordonnées $${point1.toCoords()}$ et $${point2.toCoords()}$. Un vecteur directeur de $d$ est donc :
|
|
83
|
+
|
|
84
|
+
$$
|
|
85
|
+
${VectorConstructor.fromPoints(point1, point2).toBinomCoords().toTex()}
|
|
86
|
+
$$
|
|
87
|
+
|
|
88
|
+
On sait que si $${u.toTexWithBinomCoords()}$ est un vecteur directeur de $d$, alors $${v.toTexWithBinomCoords()}$ est un vecteur normal à $d$.
|
|
89
|
+
|
|
90
|
+
Ici, les coordonnées d'un vecteur normal à $d$ sont donc :
|
|
91
|
+
|
|
92
|
+
$$
|
|
93
|
+
${getAnswer(identifiers)}
|
|
94
|
+
$$`;
|
|
95
|
+
};
|
|
96
|
+
const getGGBOptions = (identifiers) => {
|
|
97
|
+
const { point1Ids, point2Ids, point3Ids } = identifiers;
|
|
98
|
+
const point1 = PointConstructor.fromIdentifiers(point1Ids);
|
|
99
|
+
const point2 = PointConstructor.fromIdentifiers(point2Ids);
|
|
100
|
+
const line = new Line(point1, point2, "d");
|
|
101
|
+
const ggb = new GeogebraConstructor({
|
|
102
|
+
commands: line.toGGBCommands(true, {
|
|
103
|
+
isFixed: true,
|
|
104
|
+
isSelectionnable: false,
|
|
105
|
+
showLabel: true,
|
|
106
|
+
showUnderlyingPoints: false,
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
if (point3Ids) {
|
|
110
|
+
const point3 = PointConstructor.fromIdentifiers(point3Ids);
|
|
111
|
+
ggb.commands?.push(`d' = PerpendicularLine(${point2.name}, d)`);
|
|
112
|
+
ggb.commands?.push(`alpha = Angle(d,d')`);
|
|
113
|
+
ggb.commands?.push(`ShowLabel(d', true)`);
|
|
114
|
+
ggb.commands?.push(`ShowLabel(alpha, false)`);
|
|
115
|
+
return ggb.getOptions({
|
|
116
|
+
coords: ggb.getCoordsForPoints([point1, point2, point3]),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return ggb.getOptions({
|
|
121
|
+
coords: ggb.getCoordsForPoints([point1, point2]),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const getKeys = () => {
|
|
126
|
+
return ["binom", "semicolon"];
|
|
127
|
+
};
|
|
128
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
129
|
+
try {
|
|
130
|
+
return colinearVectorVEA(ans, answer);
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
return handleVEAError(err);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const getReadLineNormalVectorOnGraphQuestion = (opts) => {
|
|
137
|
+
const point1 = PointConstructor.random("A");
|
|
138
|
+
const ratio = RationalConstructor.randomIrreductibleWithSign(6);
|
|
139
|
+
const translation = new Vector("u", ratio.num.toTree(), ratio.denum.toTree());
|
|
140
|
+
const point2 = translation.getEndPoint(point1);
|
|
141
|
+
let point3;
|
|
142
|
+
if (!opts?.withoutPerp) {
|
|
143
|
+
const vector = VectorConstructor.fromPoints(point1, point2);
|
|
144
|
+
const normal = vector.getOrthogonal();
|
|
145
|
+
point3 = normal.getEndPoint(point2);
|
|
146
|
+
}
|
|
147
|
+
const identifiers = {
|
|
148
|
+
point1Ids: point1.toIdentifiers(),
|
|
149
|
+
point2Ids: point2.toIdentifiers(),
|
|
150
|
+
point3Ids: point3?.toIdentifiers(),
|
|
151
|
+
};
|
|
152
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
153
|
+
};
|
|
154
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
155
|
+
return {
|
|
156
|
+
answer: getAnswer(identifiers, opts),
|
|
157
|
+
instruction: getInstruction(identifiers, opts),
|
|
158
|
+
keys: getKeys(identifiers, opts),
|
|
159
|
+
answerFormat: "tex",
|
|
160
|
+
identifiers,
|
|
161
|
+
hint: getHint(identifiers, opts),
|
|
162
|
+
correction: getCorrection(identifiers, opts),
|
|
163
|
+
ggbOptions: getGGBOptions(identifiers, opts),
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
const options = [
|
|
167
|
+
{
|
|
168
|
+
id: "withoutPerp",
|
|
169
|
+
label: "Ne pas tracer de droite perpendiculaire",
|
|
170
|
+
type: GeneratorOptionType.checkbox,
|
|
171
|
+
target: GeneratorOptionTarget.generation,
|
|
172
|
+
defaultValue: false,
|
|
173
|
+
tooltipText: "S'il n'y a pas de droite perpendiculaire tracée, l'élève devra utiliser le vecteur directeur de la droite puis la propriété qui donne un vecteur normal à partir d'un vecteur directeur.",
|
|
174
|
+
},
|
|
175
|
+
];
|
|
176
|
+
export const readLineNormalVectorOnGraph = {
|
|
177
|
+
id: "readLineNormalVectorOnGraph",
|
|
178
|
+
label: "Déterminer graphiquement les coordonnées d'un vecteur normal à une droite",
|
|
179
|
+
isSingleStep: true,
|
|
180
|
+
generator: (nb, opts) => getDistinctQuestions(() => getReadLineNormalVectorOnGraphQuestion(opts), nb),
|
|
181
|
+
qcmTimer: 60,
|
|
182
|
+
freeTimer: 60,
|
|
183
|
+
getPropositions,
|
|
184
|
+
isAnswerValid,
|
|
185
|
+
subject: "Mathématiques",
|
|
186
|
+
getHint,
|
|
187
|
+
getCorrection,
|
|
188
|
+
getInstruction,
|
|
189
|
+
getAnswer,
|
|
190
|
+
getGGBOptions,
|
|
191
|
+
hasGeogebra: true,
|
|
192
|
+
getQuestionFromIdentifiers,
|
|
193
|
+
options,
|
|
194
|
+
hasHintAndCorrection: true,
|
|
195
|
+
};
|
|
@@ -11,4 +11,5 @@ export * from "./randomVariableSituationVariance.js";
|
|
|
11
11
|
export * from "./randomVariableSituationStandardDeviation.js";
|
|
12
12
|
export * from "./randomVariableSituationIsGameFavorable.js";
|
|
13
13
|
export * from "./randomVariableSituationProbabilityLaw.js";
|
|
14
|
+
export * from "./missingValueInRandomVariableProbabilityLaw.js";
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/randomVariable/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AAErD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,4CAA4C,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/randomVariable/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AAErD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,4CAA4C,CAAC;AAE3D,cAAc,iDAAiD,CAAC"}
|
|
@@ -13,3 +13,4 @@ export * from "./randomVariableSituationStandardDeviation.js";
|
|
|
13
13
|
export * from "./randomVariableSituationIsGameFavorable.js";
|
|
14
14
|
export * from "./randomVariableSituationProbabilityLaw.js";
|
|
15
15
|
// export * from "./decideWhichGameIsLessRisky.js";
|
|
16
|
+
export * from "./missingValueInRandomVariableProbabilityLaw.js";
|
package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
xValues: NodeIdentifiers[];
|
|
5
|
+
pValues: NodeIdentifiers[];
|
|
6
|
+
};
|
|
7
|
+
export declare const missingValueInRandomVariableProbabilityLaw: Exercise<Identifiers>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=missingValueInRandomVariableProbabilityLaw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missingValueInRandomVariableProbabilityLaw.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAe7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC;AAgHF,eAAO,MAAM,0CAA0C,EAAE,QAAQ,CAAC,WAAW,CAsB1E,CAAC"}
|
package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, shuffleProps, propWhile, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
4
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
5
|
+
import { round } from "../../../../math/utils/round.js";
|
|
6
|
+
import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
|
|
7
|
+
import { reifyAlgebraic, } from "../../../../tree/nodes/nodeConstructor.js";
|
|
8
|
+
import { RandomVariable, RandomVariableConstructor, } from "../../../../math/probability/randomVariable.js";
|
|
9
|
+
import { isVariableNode, VariableNode, } from "../../../../tree/nodes/variables/variableNode.js";
|
|
10
|
+
import { operatorComposition } from "../../../../tree/utilities/operatorComposition.js";
|
|
11
|
+
import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
|
|
12
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
13
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
14
|
+
const getPropositions = (n, { answer }) => {
|
|
15
|
+
const props = [];
|
|
16
|
+
addValidProp(props, answer);
|
|
17
|
+
propWhile(props, n, () => {
|
|
18
|
+
const numeric = answer.unfrenchify();
|
|
19
|
+
const offset = randfloat(-0.2, 0.2, 2);
|
|
20
|
+
const candidate = round(numeric + offset, 2).frenchify();
|
|
21
|
+
tryToAddWrongProp(props, candidate);
|
|
22
|
+
});
|
|
23
|
+
return shuffleProps(props, n);
|
|
24
|
+
};
|
|
25
|
+
const getAnswer = ({ pValues }) => {
|
|
26
|
+
const probas = pValues
|
|
27
|
+
.map((e) => reifyAlgebraic(e))
|
|
28
|
+
.filter((p) => !isVariableNode(p));
|
|
29
|
+
const sum = operatorComposition(AddNode, probas).simplify();
|
|
30
|
+
return substract(1, sum).simplify().toTex();
|
|
31
|
+
};
|
|
32
|
+
const getInstruction = ({ pValues, xValues }) => {
|
|
33
|
+
const va = new RandomVariable(xValues.map((e) => reifyAlgebraic(e)), pValues.map((e) => reifyAlgebraic(e)));
|
|
34
|
+
return `On considère une variable aléatoire $X$ dont la loi de probabilité est la suivante :
|
|
35
|
+
|
|
36
|
+
${va.getLawMdTable()}
|
|
37
|
+
|
|
38
|
+
Que vaut $x$ ?`;
|
|
39
|
+
};
|
|
40
|
+
const getHint = () => {
|
|
41
|
+
return `Dans une loi de probabilité, la somme des probabilités est égale à $1$.`;
|
|
42
|
+
};
|
|
43
|
+
const getCorrection = (identifiers) => {
|
|
44
|
+
const { pValues, xValues } = identifiers;
|
|
45
|
+
const probas = pValues.map((e) => reifyAlgebraic(e));
|
|
46
|
+
const index = probas.findIndex((p) => isVariableNode(p));
|
|
47
|
+
const xs = xValues.map((e) => reifyAlgebraic(e));
|
|
48
|
+
const sum = operatorComposition(AddNode, probas.filter((_p, i) => i !== index));
|
|
49
|
+
return `
|
|
50
|
+
On additionne les probabilités connues :
|
|
51
|
+
|
|
52
|
+
$$
|
|
53
|
+
${sum.toTex()} = ${sum.simplify().toTex()}
|
|
54
|
+
$$
|
|
55
|
+
|
|
56
|
+
Puisque la somme des probabilités d'une loi de probabilité vaut $1$, on peut en déduire la probabilité manquante :
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
$$
|
|
60
|
+
P(X = ${xs[index].toTex()}) = 1 - ${sum.simplify().toTex()} = ${getAnswer(identifiers)}.
|
|
61
|
+
$$
|
|
62
|
+
`;
|
|
63
|
+
};
|
|
64
|
+
const getKeys = () => {
|
|
65
|
+
return [];
|
|
66
|
+
};
|
|
67
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
68
|
+
try {
|
|
69
|
+
const a = parseAlgebraic(ans);
|
|
70
|
+
const b = parseAlgebraic(answer);
|
|
71
|
+
return a.simplify().equals(b.simplify());
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
return handleVEAError(err);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const getGetMissingProbabilityValueQuestion = () => {
|
|
78
|
+
const va = RandomVariableConstructor.random();
|
|
79
|
+
const pValues = [...va.yValues];
|
|
80
|
+
pValues[randint(0, pValues.length)] = new VariableNode("x");
|
|
81
|
+
const identifiers = {
|
|
82
|
+
pValues: pValues.map((e) => e.toIdentifiers()),
|
|
83
|
+
xValues: va.xValues.map((e) => e.toIdentifiers()),
|
|
84
|
+
};
|
|
85
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
86
|
+
};
|
|
87
|
+
const getQuestionFromIdentifiers = (identifiers) => ({
|
|
88
|
+
answer: getAnswer(identifiers),
|
|
89
|
+
instruction: getInstruction(identifiers),
|
|
90
|
+
keys: getKeys(identifiers),
|
|
91
|
+
answerFormat: "tex",
|
|
92
|
+
identifiers,
|
|
93
|
+
hint: getHint(identifiers),
|
|
94
|
+
correction: getCorrection(identifiers),
|
|
95
|
+
style: {
|
|
96
|
+
tableOptions: {
|
|
97
|
+
firstColumnIsHeader: true,
|
|
98
|
+
firstCellIsDivided: false,
|
|
99
|
+
firstRowIsHeader: false,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
export const missingValueInRandomVariableProbabilityLaw = {
|
|
104
|
+
id: "missingValueInRandomVariableProbabilityLaw",
|
|
105
|
+
label: "Déterminer une valeur manquante dans la loi de probabilité d'une variable aléatoire",
|
|
106
|
+
isSingleStep: true,
|
|
107
|
+
generator: (nb, opts) => getDistinctQuestions(() => getGetMissingProbabilityValueQuestion(opts), nb),
|
|
108
|
+
qcmTimer: 60,
|
|
109
|
+
freeTimer: 60,
|
|
110
|
+
getPropositions,
|
|
111
|
+
isAnswerValid,
|
|
112
|
+
subject: "Mathématiques",
|
|
113
|
+
getInstruction,
|
|
114
|
+
getHint,
|
|
115
|
+
getCorrection,
|
|
116
|
+
getAnswer,
|
|
117
|
+
getQuestionFromIdentifiers,
|
|
118
|
+
hasHintAndCorrection: true,
|
|
119
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./pySequenceTermForLoopInstructionCompletion.js";
|
|
2
|
+
export * from "./pySequenceTermFromFunctionCallInstructionCompletion.js";
|
|
3
|
+
export * from "./pySequenceFirstTermsListInstructionCompletion.js";
|
|
4
|
+
export * from "./pySequenceFirstTermsSumInstructionCompletion.js";
|
|
5
|
+
export * from "./pySequenceProgramReading.js";
|
|
6
|
+
export * from "./pySequenceFactorialInstructionFalseOneOut.js";
|
|
7
|
+
export * from "./pySequenceThresholdInstructionCompletion.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/python/sequences/index.ts"],"names":[],"mappings":"AAAA,cAAc,iDAAiD,CAAC;AAChE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,mDAAmD,CAAC;AAClE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gDAAgD,CAAC;AAC/D,cAAc,+CAA+C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./pySequenceTermForLoopInstructionCompletion.js";
|
|
2
|
+
export * from "./pySequenceTermFromFunctionCallInstructionCompletion.js";
|
|
3
|
+
export * from "./pySequenceFirstTermsListInstructionCompletion.js";
|
|
4
|
+
export * from "./pySequenceFirstTermsSumInstructionCompletion.js";
|
|
5
|
+
export * from "./pySequenceProgramReading.js";
|
|
6
|
+
export * from "./pySequenceFactorialInstructionFalseOneOut.js";
|
|
7
|
+
export * from "./pySequenceThresholdInstructionCompletion.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { OptionIsUsePythonDef } from "../../../../exercises/options/optionIsUsePythonDef.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
nAsked: number;
|
|
5
|
+
cyRandModFour?: number;
|
|
6
|
+
arrRandForStr: number[];
|
|
7
|
+
};
|
|
8
|
+
type Options = OptionIsUsePythonDef;
|
|
9
|
+
export declare const pySequenceFactorialInstructionFalseOneOut: Exercise<Identifiers, Options>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=pySequenceFactorialInstructionFalseOneOut.d.ts.map
|
package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pySequenceFactorialInstructionFalseOneOut.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,oBAAoB,EACrB,MAAM,iDAAiD,CAAC;AA2BzD,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AA8UF,KAAK,OAAO,GAAG,oBAAoB,CAAC;AAQpC,eAAO,MAAM,yCAAyC,EAAE,QAAQ,CAC9D,WAAW,EACX,OAAO,CAmBR,CAAC"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getOptionIsUsePythonDefStuff, } from "../../../../exercises/options/optionIsUsePythonDef.js";
|
|
3
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
const codify = (strPython) => {
|
|
6
|
+
return `\`\`\`python
|
|
7
|
+
${strPython}
|
|
8
|
+
\`\`\``;
|
|
9
|
+
};
|
|
10
|
+
const codifyChunk = (strPython) => {
|
|
11
|
+
return `\`${strPython}\``;
|
|
12
|
+
};
|
|
13
|
+
const _createStrPythonForNode = (nodeUNext) => {
|
|
14
|
+
return nodeUNext.toMathString().replaceAll("^", "**");
|
|
15
|
+
};
|
|
16
|
+
const uncypherRandModFour = (cyRandModFour) => {
|
|
17
|
+
return (cyRandModFour - 1) % 4;
|
|
18
|
+
};
|
|
19
|
+
const cypherRandModFour = (randModFour) => {
|
|
20
|
+
return randModFour + 1;
|
|
21
|
+
};
|
|
22
|
+
const _getStrPythonProgram = (opts) => {
|
|
23
|
+
const { isUsePythonDef } = opts;
|
|
24
|
+
if (isUsePythonDef) {
|
|
25
|
+
return `def factorielle(n):
|
|
26
|
+
v = 1
|
|
27
|
+
for i in range(1,n):
|
|
28
|
+
v = v * i
|
|
29
|
+
return v
|
|
30
|
+
|
|
31
|
+
print(factorielle(n))
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return `v = 1
|
|
36
|
+
for i in range(1,n):
|
|
37
|
+
v = v * i
|
|
38
|
+
print(v)
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const getStrPythonProgramValid = (identifiers, opts) => {
|
|
43
|
+
const identifiersTweaked = {
|
|
44
|
+
...identifiers,
|
|
45
|
+
cyRandModFour: undefined,
|
|
46
|
+
};
|
|
47
|
+
return getStrPythonProgramInvalid(identifiersTweaked, opts);
|
|
48
|
+
};
|
|
49
|
+
const getStrPythonProgramInvalid = (identifiers, opts) => {
|
|
50
|
+
const { isUsePythonDef } = opts;
|
|
51
|
+
const { cyRandModFour } = identifiers;
|
|
52
|
+
const randModFour = cyRandModFour ? uncypherRandModFour(cyRandModFour) : -1;
|
|
53
|
+
const { strInitialization, strForLoop, strLoopBody, strPrint } = Object.fromEntries(Object.entries(getDictStrCompletion(identifiers, opts)).map(([key, miniDict], i) => i === randModFour ? [key, miniDict.invalid] : [key, miniDict.valid]));
|
|
54
|
+
if (isUsePythonDef) {
|
|
55
|
+
return `def factorielle(n):
|
|
56
|
+
${strInitialization}
|
|
57
|
+
${strForLoop}
|
|
58
|
+
${strLoopBody}
|
|
59
|
+
return v
|
|
60
|
+
|
|
61
|
+
${strPrint}
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return `${strInitialization}
|
|
66
|
+
${strForLoop}
|
|
67
|
+
${strLoopBody}
|
|
68
|
+
${strPrint}
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const getDictStrCompletion = (identifiers, opts) => {
|
|
73
|
+
const { isUsePythonDef } = opts;
|
|
74
|
+
const { nAsked, arrRandForStr } = identifiers;
|
|
75
|
+
const [randStrInitialization, randStrForLoop, randStrLoopBody, randStrPrint] = arrRandForStr;
|
|
76
|
+
function getStrFromArr(arrStr, rand) {
|
|
77
|
+
const i = rand % arrStr.length;
|
|
78
|
+
return arrStr[i];
|
|
79
|
+
}
|
|
80
|
+
if (isUsePythonDef) {
|
|
81
|
+
return {
|
|
82
|
+
strInitialization: {
|
|
83
|
+
valid: getStrFromArr(["v = 1"], randStrInitialization),
|
|
84
|
+
invalid: getStrFromArr([
|
|
85
|
+
//inits with 0
|
|
86
|
+
"v = 0",
|
|
87
|
+
//wrong variable
|
|
88
|
+
"x = 1",
|
|
89
|
+
"n = 1",
|
|
90
|
+
], randStrInitialization),
|
|
91
|
+
},
|
|
92
|
+
strForLoop: {
|
|
93
|
+
valid: getStrFromArr(["for i in range(1,n+1):"], randStrForLoop),
|
|
94
|
+
invalid: getStrFromArr([
|
|
95
|
+
//starts at 0
|
|
96
|
+
"for i in range(n+1):",
|
|
97
|
+
"for i in range(n):",
|
|
98
|
+
"for i in range(n-1):",
|
|
99
|
+
//missing :
|
|
100
|
+
"for i in range(1,n+1)",
|
|
101
|
+
"for i in range(1,n)",
|
|
102
|
+
"for i in range(1,n-1)",
|
|
103
|
+
], randStrForLoop),
|
|
104
|
+
},
|
|
105
|
+
strLoopBody: {
|
|
106
|
+
valid: getStrFromArr(["v = v * i", "v = i * v"], randStrLoopBody),
|
|
107
|
+
invalid: getStrFromArr([
|
|
108
|
+
//uses n
|
|
109
|
+
"n = n * i",
|
|
110
|
+
"n = i * n",
|
|
111
|
+
"v = i * n",
|
|
112
|
+
"v = n * i",
|
|
113
|
+
//i -> (i+1)
|
|
114
|
+
"v = v * (i+1)",
|
|
115
|
+
"v = (i+1) * v",
|
|
116
|
+
], randStrLoopBody),
|
|
117
|
+
},
|
|
118
|
+
strPrint: {
|
|
119
|
+
valid: getStrFromArr([`print(factorielle(${nAsked}))`], randStrPrint),
|
|
120
|
+
invalid: getStrFromArr([
|
|
121
|
+
"print(factorielle(n))",
|
|
122
|
+
"factorielle(n)",
|
|
123
|
+
`print(factorielle(${nAsked - 1}))`,
|
|
124
|
+
`factorielle(${nAsked - 1})`,
|
|
125
|
+
`factorielle(${nAsked})`,
|
|
126
|
+
"print(factorielle)",
|
|
127
|
+
`print(factorielle[${nAsked}])`,
|
|
128
|
+
], randStrPrint),
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return {
|
|
134
|
+
strInitialization: {
|
|
135
|
+
valid: getStrFromArr(["v = 1"], randStrInitialization),
|
|
136
|
+
invalid: getStrFromArr([
|
|
137
|
+
//inits with 0
|
|
138
|
+
"v = 0",
|
|
139
|
+
//wrong variable
|
|
140
|
+
"x = 1",
|
|
141
|
+
"n = 1",
|
|
142
|
+
], randStrInitialization),
|
|
143
|
+
},
|
|
144
|
+
strForLoop: {
|
|
145
|
+
valid: getStrFromArr([`for i in range(1,${nAsked + 1}):`], randStrForLoop),
|
|
146
|
+
invalid: getStrFromArr([
|
|
147
|
+
//starts at 0
|
|
148
|
+
`for i in range(${nAsked + 1}):`,
|
|
149
|
+
`for i in range(${nAsked}):`,
|
|
150
|
+
`for i in range(${nAsked - 1}):`,
|
|
151
|
+
//missing :
|
|
152
|
+
`for i in range(1,${nAsked + 1})`,
|
|
153
|
+
`for i in range(1,${nAsked})`,
|
|
154
|
+
`for i in range(1,${nAsked - 1})`,
|
|
155
|
+
], randStrForLoop),
|
|
156
|
+
},
|
|
157
|
+
strLoopBody: {
|
|
158
|
+
valid: getStrFromArr(["v = v * i", "v = i * v"], randStrLoopBody),
|
|
159
|
+
invalid: getStrFromArr([
|
|
160
|
+
//uses n
|
|
161
|
+
"n = n * i",
|
|
162
|
+
"n = i * n",
|
|
163
|
+
"v = i * n",
|
|
164
|
+
"v = n * i",
|
|
165
|
+
//i -> (i+1)
|
|
166
|
+
"v = v * (i+1)",
|
|
167
|
+
"v = (i+1) * v",
|
|
168
|
+
], randStrLoopBody),
|
|
169
|
+
},
|
|
170
|
+
strPrint: {
|
|
171
|
+
valid: getStrFromArr([`print(v)`], randStrPrint),
|
|
172
|
+
invalid: getStrFromArr([
|
|
173
|
+
"v",
|
|
174
|
+
"print(n)",
|
|
175
|
+
`print(i)`,
|
|
176
|
+
`print(v*${nAsked})`,
|
|
177
|
+
`print(v[${nAsked}])`,
|
|
178
|
+
], randStrPrint),
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const getInstruction = (identifiers, optsIn) => {
|
|
184
|
+
const opts = optsIn ?? optsDefault;
|
|
185
|
+
const { nAsked } = identifiers;
|
|
186
|
+
return `Quelqu'un a codé ce programme Python dans le but d'afficher la valeur de $${nAsked}!$ (pour $n \\geq 1$, $n!$ ("factorielle $n$") est le produit des entiers compris entre $1$ et $n$ inclus).
|
|
187
|
+
|
|
188
|
+
${codify(getStrPythonProgramInvalid(identifiers, opts))}
|
|
189
|
+
|
|
190
|
+
Quelle instruction est erronée dans ce programme ?
|
|
191
|
+
|
|
192
|
+
`;
|
|
193
|
+
};
|
|
194
|
+
const getAnswer = (identifiers, optsIn) => {
|
|
195
|
+
const opts = optsIn ?? optsDefault;
|
|
196
|
+
const { cyRandModFour } = identifiers;
|
|
197
|
+
const randModFour = cyRandModFour ? uncypherRandModFour(cyRandModFour) : -1;
|
|
198
|
+
const arrEntry = Object.entries(getDictStrCompletion(identifiers, opts));
|
|
199
|
+
const [_, miniDict] = arrEntry[randModFour];
|
|
200
|
+
const strInstructionInvalid = miniDict.invalid;
|
|
201
|
+
return codifyChunk(strInstructionInvalid);
|
|
202
|
+
};
|
|
203
|
+
const getHint = () => {
|
|
204
|
+
return `Regarde s'il y a des erreurs de syntaxe et s'il n'y en a pas, essaye d'exécuter le programme pour détecter ce qui ne va pas.`;
|
|
205
|
+
};
|
|
206
|
+
const getCorrection = (identifiers, optsIn) => {
|
|
207
|
+
const opts = optsIn ?? optsDefault;
|
|
208
|
+
return `Voici le programme corrigé :
|
|
209
|
+
|
|
210
|
+
${codify(getStrPythonProgramValid(identifiers, opts))}
|
|
211
|
+
|
|
212
|
+
`;
|
|
213
|
+
};
|
|
214
|
+
const getPropositions = (_n, { answer, ...identifiers }, optsIn) => {
|
|
215
|
+
const opts = optsIn ?? optsDefault;
|
|
216
|
+
const { cyRandModFour } = identifiers;
|
|
217
|
+
const randModFour = cyRandModFour ? uncypherRandModFour(cyRandModFour) : -1;
|
|
218
|
+
const propositions = [];
|
|
219
|
+
Object.entries(getDictStrCompletion(identifiers, opts)).forEach(([_, miniDict], i) => {
|
|
220
|
+
if (i === randModFour) {
|
|
221
|
+
const strInstruction = miniDict.invalid;
|
|
222
|
+
addValidProp(propositions, codifyChunk(strInstruction), "raw");
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const strInstruction = miniDict.valid;
|
|
226
|
+
tryToAddWrongProp(propositions, codifyChunk(strInstruction), "raw");
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return propositions;
|
|
230
|
+
};
|
|
231
|
+
const createRandomIdentifiers = (_opts) => {
|
|
232
|
+
const cyRandModFour = cypherRandModFour(randint(20, 100));
|
|
233
|
+
const nAsked = randint(9, 20);
|
|
234
|
+
const arrRandForStr = [...Array(4).keys()].map(() => randint(10, 50));
|
|
235
|
+
const identifiers = { cyRandModFour, nAsked, arrRandForStr };
|
|
236
|
+
return identifiers;
|
|
237
|
+
};
|
|
238
|
+
const getPySequenceFactorialInstructionFalseOneOutQuestion = (optsIn) => {
|
|
239
|
+
const opts = optsIn ?? optsDefault;
|
|
240
|
+
const identifiers = createRandomIdentifiers(opts);
|
|
241
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
242
|
+
};
|
|
243
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
244
|
+
const question = {
|
|
245
|
+
answer: getAnswer(identifiers, opts),
|
|
246
|
+
instruction: getInstruction(identifiers, opts),
|
|
247
|
+
keys: [],
|
|
248
|
+
answerFormat: "tex",
|
|
249
|
+
identifiers,
|
|
250
|
+
hint: getHint(identifiers, opts),
|
|
251
|
+
correction: getCorrection(identifiers, opts),
|
|
252
|
+
options: opts,
|
|
253
|
+
};
|
|
254
|
+
return question;
|
|
255
|
+
};
|
|
256
|
+
const { optsDefaultIsUsePythonDef, generatorOptionIsUsePythonDef } = getOptionIsUsePythonDefStuff(false);
|
|
257
|
+
const optsDefault = {
|
|
258
|
+
...optsDefaultIsUsePythonDef,
|
|
259
|
+
};
|
|
260
|
+
const options = [generatorOptionIsUsePythonDef];
|
|
261
|
+
export const pySequenceFactorialInstructionFalseOneOut = {
|
|
262
|
+
id: "pySequenceFactorialInstructionFalseOneOut",
|
|
263
|
+
label: "Déterminer l'instruction fausse dans un algorithme de calcul de factorielle",
|
|
264
|
+
isSingleStep: true,
|
|
265
|
+
generator: (nb, opts) => getDistinctQuestions(() => getPySequenceFactorialInstructionFalseOneOutQuestion(opts), nb),
|
|
266
|
+
options,
|
|
267
|
+
qcmTimer: 60,
|
|
268
|
+
freeTimer: 60,
|
|
269
|
+
getPropositions,
|
|
270
|
+
subject: "Mathématiques",
|
|
271
|
+
getQuestionFromIdentifiers,
|
|
272
|
+
hasHintAndCorrection: true,
|
|
273
|
+
answerType: "QCU",
|
|
274
|
+
};
|
package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { OptionFirstTermRankOne } from "../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
firstValue: number;
|
|
5
|
+
lengthAsked: number;
|
|
6
|
+
coeffs: number[];
|
|
7
|
+
isUseFuncRecur: boolean;
|
|
8
|
+
};
|
|
9
|
+
type Options = OptionFirstTermRankOne;
|
|
10
|
+
export declare const pySequenceFirstTermsListInstructionCompletion: Exercise<Identifiers, Options>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=pySequenceFirstTermsListInstructionCompletion.d.ts.map
|