math-exercises 3.0.188 → 3.0.189
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/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +44 -37
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +16 -61
- 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/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/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/python/list/pyListMutationMix.d.ts.map +1 -1
- package/lib/exercises/math/python/list/pyListMutationMix.js +11 -6
- package/lib/index.d.ts +44 -24
- package/lib/index.d.ts.map +1 -1
- 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
|
@@ -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":"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/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[];
|
|
@@ -3287,23 +3307,23 @@ declare const mathExercises: (Exercise<{
|
|
|
3287
3307
|
probasIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
3288
3308
|
intervalIds: import("./tree/nodes/sets/intervalNode.js").IntervalNodeIdentifiers;
|
|
3289
3309
|
}, 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;
|
|
3310
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3296
3311
|
}, {
|
|
3297
3312
|
averageFormulation: string;
|
|
3298
3313
|
}> | Exercise<{
|
|
3299
|
-
params: import("./exercises/math/probaStat/randomVariable/
|
|
3300
|
-
|
|
3301
|
-
params: import("./exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3314
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3315
|
+
xi: number;
|
|
3302
3316
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3303
|
-
params: import("./exercises/math/probaStat/randomVariable/
|
|
3317
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3304
3318
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3305
|
-
params: import("./exercises/math/probaStat/randomVariable/
|
|
3319
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3306
3320
|
initTable: string[][];
|
|
3321
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3322
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3323
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3324
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3325
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3326
|
+
params: import("./exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js").RandomVariableSituationParams;
|
|
3307
3327
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
3308
3328
|
xValues: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
3309
3329
|
pValues: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AlgebraicNode } from "../nodes/algebraicNode.js";
|
|
2
|
+
import { NodeIdentifiers } from "../nodes/nodeConstructor.js";
|
|
2
3
|
export declare abstract class NodeUtils {
|
|
3
4
|
static getDepth: <T extends AlgebraicNode>(algebraicNode: T) => number;
|
|
4
5
|
static getChildren(algebraicNode: AlgebraicNode): AlgebraicNode[];
|
|
6
|
+
static getStrCodeForNodeIdentifiers(nodeIdentifiers: NodeIdentifiers): string;
|
|
5
7
|
}
|
|
6
8
|
//# sourceMappingURL=nodeUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeUtils.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"nodeUtils.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,8BAAsB,SAAS;IAC7B,MAAM,CAAC,QAAQ,GAAI,CAAC,SAAS,aAAa,EAAE,eAAe,CAAC,KAAG,MAAM,CASnE;IAEF,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,aAAa;IAU/C,MAAM,CAAC,4BAA4B,CACjC,eAAe,EAAE,eAAe,GAC/B,MAAM;CA2CV"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isFunctionNode } from "../nodes/functions/functionNode.js";
|
|
2
|
+
import { NodeIds } from "../nodes/node.js";
|
|
2
3
|
import { isOperatorNode } from "../nodes/operators/operatorNode.js";
|
|
3
4
|
export class NodeUtils {
|
|
4
5
|
static getDepth = (algebraicNode) => {
|
|
@@ -21,4 +22,43 @@ export class NodeUtils {
|
|
|
21
22
|
return [];
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
static getStrCodeForNodeIdentifiers(nodeIdentifiers) {
|
|
26
|
+
const nodeId = nodeIdentifiers.id;
|
|
27
|
+
switch (nodeId) {
|
|
28
|
+
case NodeIds.add:
|
|
29
|
+
case NodeIds.substract:
|
|
30
|
+
case NodeIds.multiply:
|
|
31
|
+
case NodeIds.fraction:
|
|
32
|
+
case NodeIds.divide:
|
|
33
|
+
case NodeIds.power: {
|
|
34
|
+
const strCodeOp = (() => {
|
|
35
|
+
switch (nodeId) {
|
|
36
|
+
case NodeIds.add:
|
|
37
|
+
return "add";
|
|
38
|
+
case NodeIds.substract:
|
|
39
|
+
return "substract";
|
|
40
|
+
case NodeIds.multiply:
|
|
41
|
+
return "multiply";
|
|
42
|
+
case NodeIds.fraction:
|
|
43
|
+
return "frac";
|
|
44
|
+
case NodeIds.divide:
|
|
45
|
+
return "divide";
|
|
46
|
+
case NodeIds.power:
|
|
47
|
+
return "power";
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
const [strCodeNodeLeft, strCodeNodeRight] = [
|
|
51
|
+
nodeIdentifiers.leftChild,
|
|
52
|
+
nodeIdentifiers.rightChild,
|
|
53
|
+
].map((nodeIdentifiers) => this.getStrCodeForNodeIdentifiers(nodeIdentifiers));
|
|
54
|
+
return `${strCodeOp}(${strCodeNodeLeft},${strCodeNodeRight})`;
|
|
55
|
+
}
|
|
56
|
+
case NodeIds.number:
|
|
57
|
+
return nodeIdentifiers.value;
|
|
58
|
+
case NodeIds.variable:
|
|
59
|
+
return `new VariableNode("${nodeIdentifiers.name}")`;
|
|
60
|
+
default:
|
|
61
|
+
throw new Error("Unsupported nodeId: " + nodeId);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
24
64
|
}
|