math-exercises 3.0.188 → 3.0.190
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/decimals/decimalFractionToDecimal.d.ts.map +1 -1
- package/lib/exercises/math/calcul/decimals/decimalFractionToDecimal.js +5 -4
- package/lib/exercises/math/calculLitteral/equation/factorizeEquation.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/factorizeEquation.js +9 -8
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.js +7 -6
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/barChartInterpreting.js +5 -4
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving1.js +3 -2
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/derivativeEquationSolving3.js +3 -2
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +45 -37
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +3 -2
- package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/problemMovementOnLineFindSpeedAtPoint.js +3 -2
- package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/tangent/tangentEquationFromFunctionExpression.js +3 -2
- package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/findAbscissaOfExtremaFromFunctionExpression.js +4 -3
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +20 -64
- package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/plausibleDerivativeGraphFromFunctionGraphByManipulatingPolynomial.js +3 -2
- package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/plausibleFunctionGraphFromDerivativeGraphByManipulatingPolynomial.js +3 -2
- package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableFromFunctionExpression.js +4 -3
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +27 -35
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +129 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.js +108 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts +8 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +92 -0
- package/lib/exercises/math/functions/affines/adjustment/index.d.ts +4 -0
- package/lib/exercises/math/functions/affines/adjustment/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/adjustment/index.js +3 -0
- package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/coordsOfPointOnAffineFindX.js +8 -6
- package/lib/exercises/math/functions/affines/index.d.ts +2 -4
- package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/index.js +2 -4
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineFromExercise.js +219 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.js +69 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.js +133 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.js +229 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts +10 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.js +166 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts +9 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/affineSituationVariation.js +78 -0
- package/lib/exercises/math/functions/affines/situations/index.d.ts +6 -0
- package/lib/exercises/math/functions/affines/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/situations/index.js +5 -0
- package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.d.ts +2 -0
- package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponentials/estimateExponentialFunctionImageFromGeometricScatterplot.js +155 -0
- package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.d.ts +8 -0
- package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponentials/exponentialsRawVariations.js +99 -0
- package/lib/exercises/math/functions/exponentials/index.d.ts +3 -0
- package/lib/exercises/math/functions/exponentials/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/exponentials/index.js +4 -0
- package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.d.ts +12 -0
- package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponentials/plausibleExponentialFunctionExpressionFromGraph.js +138 -0
- package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.d.ts +8 -0
- package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.d.ts.map +1 -0
- package/lib/exercises/math/functions/exponentials/readExponentialFunctionParamsOnGraph.js +142 -0
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.d.ts.map +1 -1
- package/lib/exercises/math/geometry/cartesian/placeAbscissOnSemiLineV2.js +7 -6
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.js +3 -2
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.js +7 -6
- package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
- package/lib/exercises/math/percent/percentToDecimal.js +5 -4
- package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicStats/calculateFrequencyInList.js +5 -4
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +7 -8
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -7
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/index.js +1 -7
- package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/index.js +7 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts +11 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.js +112 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.js +176 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.js +94 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.js +166 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.js +133 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.js +211 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.js +113 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts +41 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js +173 -0
- package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianWithList.js +5 -4
- package/lib/exercises/math/python/list/pyListMutationMix.d.ts.map +1 -1
- package/lib/exercises/math/python/list/pyListMutationMix.js +11 -6
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +9 -9
- package/lib/exercises/utils/options/arrayedOptions.d.ts +2 -0
- package/lib/exercises/utils/options/arrayedOptions.d.ts.map +1 -0
- package/lib/exercises/utils/options/arrayedOptions.js +16 -0
- package/lib/index.d.ts +56 -24
- package/lib/index.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -1
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +20 -20
- package/lib/tree/utilities/nodeUtils.d.ts +2 -0
- package/lib/tree/utilities/nodeUtils.d.ts.map +1 -1
- package/lib/tree/utilities/nodeUtils.js +40 -0
- package/package.json +1 -1
package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
|
|
4
|
+
import { RationalConstructor } from "../../../../../math/numbers/rationals/rational.js";
|
|
5
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
6
|
+
import { alignTex } from "../../../../../utils/latex/alignTex.js";
|
|
7
|
+
import { buildRandomVariableSituation, getRandomVariableSituation, } from "./randomVariableSituations.js";
|
|
8
|
+
const getPropositions = (n, { answer }) => {
|
|
9
|
+
const propositions = [];
|
|
10
|
+
addValidProp(propositions, answer);
|
|
11
|
+
propWhile(propositions, n, () => {
|
|
12
|
+
tryToAddWrongProp(propositions, RationalConstructor.randomIrreductibleWithSign().toTree().toTex());
|
|
13
|
+
});
|
|
14
|
+
return shuffleProps(propositions, n);
|
|
15
|
+
};
|
|
16
|
+
const getAnswer = (identifiers) => {
|
|
17
|
+
const { params } = identifiers;
|
|
18
|
+
const va = getRandomVariableSituation(params).getVA();
|
|
19
|
+
return va.getVariance().simplify().toTex();
|
|
20
|
+
};
|
|
21
|
+
const getInstruction = (identifiers) => {
|
|
22
|
+
const { params } = identifiers;
|
|
23
|
+
const context = getRandomVariableSituation(params).getContext();
|
|
24
|
+
return (context +
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
Que vaut la variance $V(X)$ de $X$ ?
|
|
28
|
+
|
|
29
|
+
Donner la valeur exacte ou une valeur arrondie au centième.`);
|
|
30
|
+
};
|
|
31
|
+
const getHint = () => {
|
|
32
|
+
return `Dresse la loi de probabilité de $X$. Pour cela, détermine les valeurs possibles $x_i$ que peut prendre $X$, puis pour chaque valeur, calcule la probabilité $p_i$ associée.
|
|
33
|
+
|
|
34
|
+
Tu peux alors calculer l'espérance de $X$ par la formule :
|
|
35
|
+
|
|
36
|
+
$$
|
|
37
|
+
E(X) = x_1\\times p_1 + \\ldots + x_n\\times p_n
|
|
38
|
+
$$
|
|
39
|
+
|
|
40
|
+
La variance $V(X)$ s'obtient par la formule :
|
|
41
|
+
|
|
42
|
+
$$
|
|
43
|
+
V(X) = p_1(x_1-E(X))^2 + \\ldots + p_n(x_n-E(X))^2
|
|
44
|
+
$$
|
|
45
|
+
`;
|
|
46
|
+
};
|
|
47
|
+
const getCorrection = (identifiers) => {
|
|
48
|
+
const { params } = identifiers;
|
|
49
|
+
const va = getRandomVariableSituation(params).getVA();
|
|
50
|
+
return `On dresse la loi de probabilité de $X$ :
|
|
51
|
+
|
|
52
|
+
${va.getLawMdTable()}
|
|
53
|
+
|
|
54
|
+
Puis on calcule l'espérance :
|
|
55
|
+
|
|
56
|
+
${alignTex([
|
|
57
|
+
["E(X)", "=", va.getAverage().toTex()],
|
|
58
|
+
["", "=", va.getAverage().simplify().toTex()],
|
|
59
|
+
])}
|
|
60
|
+
|
|
61
|
+
Enfin, on calcule la variance :
|
|
62
|
+
|
|
63
|
+
${alignTex([
|
|
64
|
+
["V(X)", "=", va.getVariance().toTex()],
|
|
65
|
+
["", "=", va.getVariance().simplify().toTex()],
|
|
66
|
+
])}`;
|
|
67
|
+
};
|
|
68
|
+
const getKeys = () => {
|
|
69
|
+
return [];
|
|
70
|
+
};
|
|
71
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
72
|
+
try {
|
|
73
|
+
return rationalVEA(ans, answer);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
return handleVEAError(err);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const getRandomVariableSituationAverageQuestion = () => {
|
|
80
|
+
const params = buildRandomVariableSituation();
|
|
81
|
+
const identifiers = {
|
|
82
|
+
params,
|
|
83
|
+
};
|
|
84
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
85
|
+
};
|
|
86
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
87
|
+
return {
|
|
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
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export const randomVariableSituationVariance = {
|
|
98
|
+
id: "randomVariableSituationVariance",
|
|
99
|
+
connector: "=",
|
|
100
|
+
label: "Calculer la variance $V(X)$ d'une variable aléatoire dans un contexte",
|
|
101
|
+
isSingleStep: true,
|
|
102
|
+
generator: (nb, opts) => getDistinctQuestions(() => getRandomVariableSituationAverageQuestion(opts), nb),
|
|
103
|
+
qcmTimer: 60,
|
|
104
|
+
freeTimer: 60,
|
|
105
|
+
getPropositions,
|
|
106
|
+
isAnswerValid,
|
|
107
|
+
subject: "Mathématiques",
|
|
108
|
+
getHint,
|
|
109
|
+
getCorrection,
|
|
110
|
+
getAnswer,
|
|
111
|
+
getQuestionFromIdentifiers,
|
|
112
|
+
hasHintAndCorrection: true,
|
|
113
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RandomVariable } from "../../../../../math/probability/randomVariable.js";
|
|
2
|
+
type UrneParams = {
|
|
3
|
+
b: number;
|
|
4
|
+
r: number;
|
|
5
|
+
n: number;
|
|
6
|
+
gb: number;
|
|
7
|
+
gr: number;
|
|
8
|
+
gn: number;
|
|
9
|
+
};
|
|
10
|
+
type CoinParams = {
|
|
11
|
+
b: number;
|
|
12
|
+
a: number;
|
|
13
|
+
n: number;
|
|
14
|
+
};
|
|
15
|
+
type DiceMultipleParams = {
|
|
16
|
+
n: number;
|
|
17
|
+
winningMultiple: number;
|
|
18
|
+
gain: number;
|
|
19
|
+
loss: number;
|
|
20
|
+
};
|
|
21
|
+
type CardsParams = {
|
|
22
|
+
gAs: number;
|
|
23
|
+
gFigure: number;
|
|
24
|
+
gOther: number;
|
|
25
|
+
};
|
|
26
|
+
export type RandomVariableSituationParams = (UrneParams & {
|
|
27
|
+
id: "urne";
|
|
28
|
+
}) | (CoinParams & {
|
|
29
|
+
id: "coin";
|
|
30
|
+
}) | (DiceMultipleParams & {
|
|
31
|
+
id: "diceMultiple";
|
|
32
|
+
}) | (CardsParams & {
|
|
33
|
+
id: "cards";
|
|
34
|
+
});
|
|
35
|
+
export declare const getRandomVariableSituation: (params: RandomVariableSituationParams) => {
|
|
36
|
+
getContext: () => string;
|
|
37
|
+
getVA: () => RandomVariable;
|
|
38
|
+
};
|
|
39
|
+
export declare const buildRandomVariableSituation: () => RandomVariableSituationParams;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=randomVariableSituations.d.ts.map
|
package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"randomVariableSituations.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAU1E,KAAK,UAAU,GAAG;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAsDF,KAAK,UAAU,GAAG;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmEF,KAAK,kBAAkB,GAAG;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAkCF,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA4BF,MAAM,MAAM,6BAA6B,GACrC,CAAC,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7B,CAAC,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7B,CAAC,kBAAkB,GAAG;IAAE,EAAE,EAAE,cAAc,CAAA;CAAE,CAAC,GAC7C,CAAC,WAAW,GAAG;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAIpC,eAAO,MAAM,0BAA0B,GACrC,QAAQ,6BAA6B;;;CActC,CAAC;AAEF,eAAO,MAAM,4BAA4B,QACnC,6BAkBH,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { RandomVariable } from "../../../../../math/probability/randomVariable.js";
|
|
2
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
3
|
+
import { randTupleInt } from "../../../../../math/utils/random/randTupleInt.js";
|
|
4
|
+
import { binom } from "../../../../../tree/nodes/operators/binomialCoefficientNode.js";
|
|
5
|
+
import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
|
|
6
|
+
import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
7
|
+
import { power } from "../../../../../tree/nodes/operators/powerNode.js";
|
|
8
|
+
import { random } from "../../../../../utils/alea/random.js";
|
|
9
|
+
import { pluralize } from "../../../../../utils/strings/pluralize.js";
|
|
10
|
+
const getUrneRandomParams = () => {
|
|
11
|
+
const [b, r, n] = randTupleInt(3, {
|
|
12
|
+
from: 1,
|
|
13
|
+
to: 5,
|
|
14
|
+
allDifferent: false,
|
|
15
|
+
});
|
|
16
|
+
const [gb, gr] = randTupleInt(2, {
|
|
17
|
+
from: 1,
|
|
18
|
+
to: 10,
|
|
19
|
+
allDifferent: true,
|
|
20
|
+
});
|
|
21
|
+
const gn = randint(-10, 0);
|
|
22
|
+
return { b, r, n, gb, gr, gn };
|
|
23
|
+
};
|
|
24
|
+
const getUrneSituation = (params) => {
|
|
25
|
+
const { b, r, n, gb, gr, gn } = params;
|
|
26
|
+
return {
|
|
27
|
+
getContext: () => {
|
|
28
|
+
const getWord = (g) => g > 0 ? `rapporte $${g}\\ €$` : `fait perdre $${Math.abs(g)}\\ €$`;
|
|
29
|
+
return `Une urne contient $${b}$ ${pluralize("boule", b)} ${pluralize("blanche", b)}, $${r}$ ${pluralize("boule", r)} ${pluralize("rouge", r)} et $${n}$ ${pluralize("boule", r)} ${pluralize("noire", n)}. On tire au hasard une boule de l'urne. Tirer une boule blanche ${getWord(gb)}, une boule rouge ${getWord(gr)} et une boule noire ${getWord(gn)}. La variable aléatoire $X$ associe à chaque tirage le gain algébrique du joueur.`;
|
|
30
|
+
},
|
|
31
|
+
getVA: () => {
|
|
32
|
+
const total = b + r + n;
|
|
33
|
+
const sorted = [
|
|
34
|
+
{ gain: gb, eff: b },
|
|
35
|
+
{ gain: gr, eff: r },
|
|
36
|
+
{ gain: gn, eff: r },
|
|
37
|
+
].sort((a, b) => a.gain - b.gain);
|
|
38
|
+
return new RandomVariable(sorted.map((s) => s.gain), sorted.map((s) => frac(s.eff, total).simplify()));
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const getCoinRandomParams = () => {
|
|
43
|
+
const n = 2;
|
|
44
|
+
let a, b;
|
|
45
|
+
do {
|
|
46
|
+
a = randint(1, 10);
|
|
47
|
+
b = randint(1, 10);
|
|
48
|
+
} while (2 * a === a - b || -2 * b === a - b);
|
|
49
|
+
return { a, b, n };
|
|
50
|
+
};
|
|
51
|
+
const getCoinSituation = (params) => {
|
|
52
|
+
const { a, b, n } = params;
|
|
53
|
+
return {
|
|
54
|
+
getContext: () => {
|
|
55
|
+
return `On lance $${n}$ fois d'affilée une pièce de monnaie bien équilibrée. Chaque pile rapporte $${a}$ ${pluralize("point", a)} et chaque face fait perdre $${b}$ ${pluralize("point", b)}. La variable aléatoire $X$ associe à chaque tirage le gain algébrique du joueur.`;
|
|
56
|
+
},
|
|
57
|
+
// values k(a+b)−nb pourk = 0;...n;
|
|
58
|
+
// P(X = k(a+b)-nb) = (k parmi n) (1/2)^n
|
|
59
|
+
getVA: () => {
|
|
60
|
+
const values = [];
|
|
61
|
+
const probas = [];
|
|
62
|
+
for (let i = 0; i < n + 1; i++) {
|
|
63
|
+
const value = (a + b) * i - n * b;
|
|
64
|
+
values.push(value);
|
|
65
|
+
probas.push(multiply(binom(n, i), power(frac(1, 2), n)).simplify());
|
|
66
|
+
}
|
|
67
|
+
return new RandomVariable(values, probas);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const getDiceMultipleRandomParams = () => {
|
|
72
|
+
const n = 6;
|
|
73
|
+
const winningMultiple = random([2, 3]);
|
|
74
|
+
const gain = randint(1, 10);
|
|
75
|
+
const loss = randint(1, 10);
|
|
76
|
+
return { n, gain, loss, winningMultiple };
|
|
77
|
+
};
|
|
78
|
+
const getDiceMultipleSituation = (params) => {
|
|
79
|
+
const { gain, loss, n, winningMultiple } = params;
|
|
80
|
+
return {
|
|
81
|
+
getContext: () => {
|
|
82
|
+
return `Un jeu consiste à lancer un dé bien équilibré à $${n}$ faces. On gagne $${gain}\\ €$ si on obtient un multiple de $${winningMultiple}$, et on perd $${loss}\\ €$ sinon.`;
|
|
83
|
+
},
|
|
84
|
+
// values k(a+b)−nb pourk = 0;...n;
|
|
85
|
+
// P(X = k(a+b)-nb) = (k parmi n) (1/2)^n
|
|
86
|
+
getVA: () => {
|
|
87
|
+
const values = [-loss, gain];
|
|
88
|
+
let multiples = 0;
|
|
89
|
+
for (let i = 2; i <= n; i++) {
|
|
90
|
+
if (i % winningMultiple === 0) {
|
|
91
|
+
multiples++;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return new RandomVariable(values, [
|
|
95
|
+
frac(n - multiples, n).simplify(),
|
|
96
|
+
frac(multiples, n).simplify(),
|
|
97
|
+
]);
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const getCardsRandomParams = () => {
|
|
102
|
+
const gAs = randint(5, 10);
|
|
103
|
+
const gFigure = randint(1, gAs);
|
|
104
|
+
const gOther = randint(-10, 0);
|
|
105
|
+
return { gAs, gFigure, gOther };
|
|
106
|
+
};
|
|
107
|
+
const getCardsSituation = (params) => {
|
|
108
|
+
const { gAs, gFigure, gOther } = params;
|
|
109
|
+
return {
|
|
110
|
+
getContext: () => {
|
|
111
|
+
return `Un jeu consiste à tirer au hasard une carte dans un jeu de $52$ cartes. Si on tire un as, on gagne $${gAs}\\ €$; si on tire une figure, on gagne $${gFigure}\\ €$; dans les autres cas, on perd $${Math.abs(gOther)}\\ €$.`;
|
|
112
|
+
},
|
|
113
|
+
// values k(a+b)−nb pourk = 0;...n;
|
|
114
|
+
// P(X = k(a+b)-nb) = (k parmi n) (1/2)^n
|
|
115
|
+
getVA: () => {
|
|
116
|
+
return new RandomVariable([gOther, gFigure, gAs], [frac(52 - 16, 52).simplify(), frac(12, 52).simplify(), frac(1, 13)]);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
// | (DiceSumParams & { id: "diceSum" });
|
|
121
|
+
export const getRandomVariableSituation = (params) => {
|
|
122
|
+
switch (params.id) {
|
|
123
|
+
case "coin":
|
|
124
|
+
return getCoinSituation(params);
|
|
125
|
+
case "urne":
|
|
126
|
+
return getUrneSituation(params);
|
|
127
|
+
case "diceMultiple":
|
|
128
|
+
return getDiceMultipleSituation(params);
|
|
129
|
+
case "cards":
|
|
130
|
+
return getCardsSituation(params);
|
|
131
|
+
// case "diceSum":
|
|
132
|
+
// return getDiceSumSituation(params);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
export const buildRandomVariableSituation = () => {
|
|
136
|
+
const id = random(["urne", "coin", "diceMultiple", "cards"]);
|
|
137
|
+
switch (id) {
|
|
138
|
+
case "coin":
|
|
139
|
+
return { ...getCoinRandomParams(), id: "coin" };
|
|
140
|
+
case "urne":
|
|
141
|
+
return { ...getUrneRandomParams(), id: "urne" };
|
|
142
|
+
case "diceMultiple":
|
|
143
|
+
return { ...getDiceMultipleRandomParams(), id: "diceMultiple" };
|
|
144
|
+
case "cards":
|
|
145
|
+
return { ...getCardsRandomParams(), id: "cards" };
|
|
146
|
+
// case "diceSum":
|
|
147
|
+
// return { ...getDiceSumRandomParams(), id: "diceSum" };
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
// {
|
|
151
|
+
// //param nbFaces; g_2, g_3, g_4, g_5, g_6
|
|
152
|
+
// label:
|
|
153
|
+
// "On lance un dé équilibré à 12 faces (ou 4 ou 6 ou 20. Paramétrable ?). On gagne g_2€ pour chaque multiple de 2, g_3€ pour chaque multiples de 3 ... g_6€ pour chaque multiple de 6. Les gains sont cumulables. X donne le gain total du joueur.",
|
|
154
|
+
// },
|
|
155
|
+
// {
|
|
156
|
+
// //param b;r , gb;gr
|
|
157
|
+
// label:
|
|
158
|
+
// "Une urne contient b boules rouges blanches et r boules rouges. On tire deux boules successivement et avec remise (ou sans remise : paramétrable). Une boule rouge rapporte x points, une boule noire en fait perdre y. La varialbe aléatoire X associe à chaque tirage le est le gain algébrique du joueur.",
|
|
159
|
+
// },
|
|
160
|
+
// {
|
|
161
|
+
// },
|
|
162
|
+
// {
|
|
163
|
+
// label:
|
|
164
|
+
// ,
|
|
165
|
+
// },
|
|
166
|
+
// {
|
|
167
|
+
// label:
|
|
168
|
+
// "On lance deux dès équilibrés à 6 faces (ou 4, ou 12, ou 20) et on fait la différence des points. La variable aléatoire X associe à chaque tirage le gain algébrique du joueur.",
|
|
169
|
+
// },
|
|
170
|
+
// {
|
|
171
|
+
// label:
|
|
172
|
+
// "On lance deux dès équilibrés à 6 faces (ou 4, ou 12, ou 20) et on fait la CL... des points. La variable aléatoire X associe à chaque tirage le gain algébrique du joueur.",
|
|
173
|
+
// },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"medianWithList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/medianWithList.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"medianWithList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/medianWithList.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,QAAQ,EAkBT,MAAM,sBAAsB,CAAC;AAE9B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAmJF,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAsBF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBzD,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBzE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defaultArrayedOptsWhereNeeded } from "../../../../exercises/utils/options/arrayedOptions.js";
|
|
1
2
|
import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
|
|
2
3
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
3
4
|
import { median } from "../../../../math/utils/stats/median.js";
|
|
@@ -81,9 +82,9 @@ const isAnswerValid = (ans, { answer, sortedValues }) => {
|
|
|
81
82
|
}
|
|
82
83
|
};
|
|
83
84
|
const getMedianList = (optsIn) => {
|
|
84
|
-
const
|
|
85
|
+
const arrayedOpts = defaultArrayedOptsWhereNeeded(optsIn, arrayedOptsDefault);
|
|
85
86
|
const opts = {
|
|
86
|
-
nbValues: random(
|
|
87
|
+
nbValues: random(arrayedOpts.nbValues),
|
|
87
88
|
isOrdered: optsIn?.isOrdered ?? false,
|
|
88
89
|
};
|
|
89
90
|
const length = Number(opts.nbValues);
|
|
@@ -123,7 +124,7 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
|
123
124
|
};
|
|
124
125
|
return question;
|
|
125
126
|
};
|
|
126
|
-
const
|
|
127
|
+
const arrayedOptsDefault = {
|
|
127
128
|
nbValues: ["7", "8"],
|
|
128
129
|
};
|
|
129
130
|
const options = [
|
|
@@ -133,7 +134,7 @@ const options = [
|
|
|
133
134
|
target: GeneratorOptionTarget.generation,
|
|
134
135
|
type: GeneratorOptionType.multiselect,
|
|
135
136
|
values: ["4", "5", "7", "8", "11", "12", "19", "20"],
|
|
136
|
-
defaultValue:
|
|
137
|
+
defaultValue: arrayedOptsDefault.nbValues,
|
|
137
138
|
},
|
|
138
139
|
];
|
|
139
140
|
export const medianWithList = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pyListMutationMix.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/python/list/pyListMutationMix.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAyIrC,KAAK,MAAM,CAAC,CAAC,IAAI;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,MAAM,CAAC,CAAC,IAAI;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,MAAM,CAAC,CAAC,IAAI;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,IACd,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAChC,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAChC,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAErC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,EAAE,CAAC;IACvB,cAAc,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;CACxC,CAAC;
|
|
1
|
+
{"version":3,"file":"pyListMutationMix.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/python/list/pyListMutationMix.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAyIrC,KAAK,MAAM,CAAC,CAAC,IAAI;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,MAAM,CAAC,CAAC,IAAI;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,MAAM,CAAC,CAAC,IAAI;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,IACd,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAChC,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAChC,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAErC,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,EAAE,CAAC;IACvB,cAAc,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;CACxC,CAAC;AAoaF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAanD,CAAC"}
|
|
@@ -265,21 +265,26 @@ const getPropositions = (n, { answer, ...identifiers }) => {
|
|
|
265
265
|
};
|
|
266
266
|
return getAnswer(identifiersWrong);
|
|
267
267
|
}
|
|
268
|
+
function checkAndTryToAddWrongProp(str) {
|
|
269
|
+
if (!str.includes("undefined")) {
|
|
270
|
+
tryToAddWrongProp(propositions, codifyChunk(str), "raw");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
268
273
|
//indexAsked-1
|
|
269
274
|
{
|
|
270
|
-
|
|
275
|
+
checkAndTryToAddWrongProp(createAnswerWrong((index) => index - 1));
|
|
271
276
|
}
|
|
272
277
|
//indexAsked+1
|
|
273
278
|
{
|
|
274
|
-
|
|
279
|
+
checkAndTryToAddWrongProp(createAnswerWrong((index) => index + 1));
|
|
275
280
|
}
|
|
276
281
|
//student: lst[index]=value -> lst[value]=index
|
|
277
282
|
if (typeof value === "number") {
|
|
278
|
-
|
|
283
|
+
checkAndTryToAddWrongProp(createAnswerWrong(() => value, () => index));
|
|
279
284
|
}
|
|
280
285
|
//-indexAsked
|
|
281
286
|
{
|
|
282
|
-
|
|
287
|
+
checkAndTryToAddWrongProp(createAnswerWrong((index) => -index));
|
|
283
288
|
}
|
|
284
289
|
//append
|
|
285
290
|
{
|
|
@@ -289,13 +294,13 @@ const getPropositions = (n, { answer, ...identifiers }) => {
|
|
|
289
294
|
return { ...instruction, type: "append" };
|
|
290
295
|
}),
|
|
291
296
|
};
|
|
292
|
-
|
|
297
|
+
checkAndTryToAddWrongProp(getAnswer(identifiersWrong));
|
|
293
298
|
}
|
|
294
299
|
//filler
|
|
295
300
|
{
|
|
296
301
|
propWhile(propositions, n, () => {
|
|
297
302
|
const identifiersWrong = createRandomIdentifiers();
|
|
298
|
-
|
|
303
|
+
checkAndTryToAddWrongProp(getAnswer(identifiersWrong));
|
|
299
304
|
});
|
|
300
305
|
}
|
|
301
306
|
return shuffleProps(propositions, n);
|
package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arithmeticFindRankFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAKhE,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAM1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"arithmeticFindRankFromSituation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAgBT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,wDAAwD,CAAC;AAKhE,OAAO,EAEL,kCAAkC,EAEnC,MAAM,kEAAkE,CAAC;AAM1E,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAsPF,KAAK,OAAO,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcpE,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAmB1E,CAAC"}
|
package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js
CHANGED
|
@@ -24,7 +24,7 @@ const getAnswerNode = (identifiers, opts) => {
|
|
|
24
24
|
const { situationIndex, initial, reason, valueAsked } = identifiers;
|
|
25
25
|
const situation = situations[situationIndex];
|
|
26
26
|
const rankDecoder = situation.rankDecoder;
|
|
27
|
-
return situation.variationFindRank.getAnswerStuff(initial, reason, firstRank, valueAsked, rankDecoder).answerNode;
|
|
27
|
+
return situation.variationFindRank.getAnswerStuff(initial, reason, firstRank, valueAsked, rankDecoder, situation.digitsValue, situation.digitsTarget).answerNode;
|
|
28
28
|
};
|
|
29
29
|
const getAnswer = (identifiers, optsIn) => {
|
|
30
30
|
const opts = optsIn ?? optsDefault;
|
|
@@ -54,12 +54,12 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
|
54
54
|
const arrNodeWrong = [];
|
|
55
55
|
//student: uses valueAsked as if it were rankAsked
|
|
56
56
|
{
|
|
57
|
-
const nodeWrong = situation.variationFindRandomTerm.getAnswerNode(initial, reason, firstRank, valueAsked, situation.rankDecoder);
|
|
58
|
-
tryToAddWrongProp(propositions, nodeWrong.simplify().toTex());
|
|
57
|
+
const nodeWrong = situation.variationFindRandomTerm.getAnswerNode(initial, reason, firstRank, valueAsked, situation.rankDecoder, situation.digitsValue, situation.digitsTarget);
|
|
58
|
+
tryToAddWrongProp(propositions, round(nodeWrong.simplify().evaluate(), 0).toTree().toTex());
|
|
59
59
|
arrNodeWrong.push(nodeWrong);
|
|
60
60
|
}
|
|
61
61
|
const rankValid = (() => {
|
|
62
|
-
const { rankNode } = situation.variationFindRank.getAnswerStuff(initial, reason, firstRank, valueAsked, situation.rankDecoder);
|
|
62
|
+
const { rankNode } = situation.variationFindRank.getAnswerStuff(initial, reason, firstRank, valueAsked, situation.rankDecoder, situation.digitsValue, situation.digitsTarget);
|
|
63
63
|
return round(rankNode.evaluate(), 0);
|
|
64
64
|
})();
|
|
65
65
|
//pseudo terror
|
|
@@ -67,7 +67,7 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
|
67
67
|
if (coinFlip()) {
|
|
68
68
|
//student: rankValid - 1
|
|
69
69
|
{
|
|
70
|
-
const nodeWrong = (rankValid - 1).toTree();
|
|
70
|
+
const nodeWrong = round(rankValid - 1, 0).toTree();
|
|
71
71
|
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
72
72
|
arrNodeWrong.push(nodeWrong);
|
|
73
73
|
}
|
|
@@ -75,7 +75,7 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
|
75
75
|
else {
|
|
76
76
|
//student: rankValid + 1
|
|
77
77
|
{
|
|
78
|
-
const nodeWrong = (rankValid + 1).toTree();
|
|
78
|
+
const nodeWrong = round(rankValid + 1, 0).toTree();
|
|
79
79
|
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
80
80
|
arrNodeWrong.push(nodeWrong);
|
|
81
81
|
}
|
|
@@ -83,7 +83,7 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
|
83
83
|
}
|
|
84
84
|
//random around
|
|
85
85
|
{
|
|
86
|
-
const nodeWrong = Math.max(1, rankValid + randint(-5, 6, [0])).toTree();
|
|
86
|
+
const nodeWrong = round(Math.max(1, rankValid + randint(-5, 6, [0])), 0).toTree();
|
|
87
87
|
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
88
88
|
arrNodeWrong.push(nodeWrong);
|
|
89
89
|
}
|
|
@@ -94,7 +94,7 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
|
94
94
|
if (coinFlip()) {
|
|
95
95
|
//student: rankValid - 1
|
|
96
96
|
{
|
|
97
|
-
const nodeWrong = (nodePicked.evaluate() - 1).toTree();
|
|
97
|
+
const nodeWrong = round(nodePicked.evaluate() - 1, 0).toTree();
|
|
98
98
|
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
99
99
|
arrNodeWrong.push(nodeWrong);
|
|
100
100
|
}
|
|
@@ -102,7 +102,7 @@ const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
|
102
102
|
else {
|
|
103
103
|
//student: rankValid + 1
|
|
104
104
|
{
|
|
105
|
-
const nodeWrong = (nodePicked.evaluate() + 1).toTree();
|
|
105
|
+
const nodeWrong = round(nodePicked.evaluate() + 1, 0).toTree();
|
|
106
106
|
tryToAddWrongProp(propositions, nodeWrong.toTex());
|
|
107
107
|
arrNodeWrong.push(nodeWrong);
|
|
108
108
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayedOptions.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/options/arrayedOptions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,GAAI,OAAO,EAAE,cAAc,EACnE,QAAQ,OAAO,GAAG,SAAS,EAC3B,gBAAgB,cAAc,wBAmB/B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const defaultArrayedOptsWhereNeeded = (optsIn, arrayedOptions) => {
|
|
2
|
+
const arrayedOptionsIn = optsIn;
|
|
3
|
+
return {
|
|
4
|
+
...arrayedOptions,
|
|
5
|
+
...(arrayedOptionsIn
|
|
6
|
+
? Object.keys(arrayedOptionsIn).reduce((acc, key) => {
|
|
7
|
+
const dictIn = arrayedOptionsIn;
|
|
8
|
+
acc = {
|
|
9
|
+
...acc,
|
|
10
|
+
...(dictIn[key]?.length > 0 ? { [key]: dictIn[key] } : {}),
|
|
11
|
+
};
|
|
12
|
+
return acc;
|
|
13
|
+
}, {})
|
|
14
|
+
: {}),
|
|
15
|
+
};
|
|
16
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1341,15 +1341,6 @@ declare const mathExercises: (Exercise<{
|
|
|
1341
1341
|
}, {
|
|
1342
1342
|
parameter: string;
|
|
1343
1343
|
}> | Exercise<{
|
|
1344
|
-
xValues: number[];
|
|
1345
|
-
yValues: number[];
|
|
1346
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1347
|
-
xValues: number[];
|
|
1348
|
-
yValues: number[];
|
|
1349
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1350
|
-
xValues: number[];
|
|
1351
|
-
yValues: number[];
|
|
1352
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1353
1344
|
trinomial: number[];
|
|
1354
1345
|
leftbound: number;
|
|
1355
1346
|
rightbound: number;
|
|
@@ -1358,10 +1349,6 @@ declare const mathExercises: (Exercise<{
|
|
|
1358
1349
|
xB: number;
|
|
1359
1350
|
yA: number;
|
|
1360
1351
|
yB: number;
|
|
1361
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1362
|
-
situationIndex: number;
|
|
1363
|
-
initial: number;
|
|
1364
|
-
growth: number;
|
|
1365
1352
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1366
1353
|
correctA: number;
|
|
1367
1354
|
correctB: number;
|
|
@@ -1430,6 +1417,39 @@ declare const mathExercises: (Exercise<{
|
|
|
1430
1417
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1431
1418
|
nodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1432
1419
|
pointIds: import("./math/geometry/point.js").PointIdentifiers[];
|
|
1420
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1421
|
+
xValues: number[];
|
|
1422
|
+
yValues: number[];
|
|
1423
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1424
|
+
xValues: number[];
|
|
1425
|
+
yValues: number[];
|
|
1426
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1427
|
+
xValues: number[];
|
|
1428
|
+
yValues: number[];
|
|
1429
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1430
|
+
id: string;
|
|
1431
|
+
situationIndex: number;
|
|
1432
|
+
initial: number;
|
|
1433
|
+
growth: number;
|
|
1434
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1435
|
+
situationId: string;
|
|
1436
|
+
initial: number;
|
|
1437
|
+
growth: number;
|
|
1438
|
+
x: number;
|
|
1439
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1440
|
+
situationId: string;
|
|
1441
|
+
initial: number;
|
|
1442
|
+
growth: number;
|
|
1443
|
+
y: number;
|
|
1444
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1445
|
+
initial: number;
|
|
1446
|
+
growth: number;
|
|
1447
|
+
situationId: string;
|
|
1448
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1449
|
+
initial: number;
|
|
1450
|
+
growth: number;
|
|
1451
|
+
situationId: string;
|
|
1452
|
+
threshold: number;
|
|
1433
1453
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1434
1454
|
xValue: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1435
1455
|
polynomeCoeffs: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
@@ -1915,6 +1935,18 @@ declare const mathExercises: (Exercise<{
|
|
|
1915
1935
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1916
1936
|
q: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1917
1937
|
a: number;
|
|
1938
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1939
|
+
q: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1940
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1941
|
+
f0: number;
|
|
1942
|
+
f1: number;
|
|
1943
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1944
|
+
k: number;
|
|
1945
|
+
a: number;
|
|
1946
|
+
fakeParams: {
|
|
1947
|
+
a: number;
|
|
1948
|
+
k: number;
|
|
1949
|
+
}[];
|
|
1918
1950
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1919
1951
|
affine1Ids: import("./math/polynomials/generalAffine.js").GeneralAffineIdentifiers;
|
|
1920
1952
|
affine2Ids: import("./math/polynomials/generalAffine.js").GeneralAffineIdentifiers;
|
|
@@ -3287,23 +3319,23 @@ declare const mathExercises: (Exercise<{
|
|
|
3287
3319
|
probasIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
3288
3320
|
intervalIds: import("./tree/nodes/sets/intervalNode.js").IntervalNodeIdentifiers;
|
|
3289
3321
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3290
|
-
params: import("./exercises/math/probaStat/randomVariable/
|
|
3291
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3292
|
-
params: import("./exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3293
|
-
xi: number;
|
|
3294
|
-
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3295
|
-
params: import("./exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3322
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3296
3323
|
}, {
|
|
3297
3324
|
averageFormulation: string;
|
|
3298
3325
|
}> | Exercise<{
|
|
3299
|
-
params: import("./exercises/math/probaStat/randomVariable/
|
|
3300
|
-
|
|
3301
|
-
params: import("./exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3326
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3327
|
+
xi: number;
|
|
3302
3328
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3303
|
-
params: import("./exercises/math/probaStat/randomVariable/
|
|
3329
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3304
3330
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3305
|
-
params: import("./exercises/math/probaStat/randomVariable/
|
|
3331
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3306
3332
|
initTable: string[][];
|
|
3333
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3334
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3335
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3336
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3337
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3338
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3307
3339
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3308
3340
|
xValues: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
3309
3341
|
pValues: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|