math-exercises 2.2.88 → 2.2.89
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/combinatory/ballsCounting.js +4 -4
- package/lib/exercises/math/combinatory/diceCounting.js +5 -5
- package/lib/exercises/math/probaStat/ballsBasicProbas.js +2 -2
- package/lib/exercises/math/probaStat/cardBasicProbas.js +1 -1
- package/lib/exercises/math/probaStat/diceBasicProbas.js +2 -2
- package/lib/exercises/math/probaStat/issuesCountingForCards.js +1 -1
- package/lib/exercises/math/python/pyForLoop1Exercise.js +1 -1
- package/lib/exercises/math/python/pyWhileLoop1Exercise.js +2 -2
- package/lib/exercises/math/sampling/fluctuationInterval.js +1 -1
- package/lib/latexTester.d.ts.map +1 -1
- package/lib/latexTester.js +58 -5
- package/package.json +1 -1
|
@@ -38,16 +38,16 @@ const getBallsCountingQuestion = () => {
|
|
|
38
38
|
break;
|
|
39
39
|
case 5:
|
|
40
40
|
instruction = `comportant exactement une boule verte et deux boules noires`;
|
|
41
|
-
answer =
|
|
41
|
+
answer = 3 * (greens * blacks * (blacks - 1)) + "";
|
|
42
42
|
break;
|
|
43
43
|
case 6:
|
|
44
44
|
instruction = `comportant exactement une boule verte`;
|
|
45
|
-
answer =
|
|
45
|
+
answer = 3 * greens * (reds + blacks) * (reds + blacks - 1) + "";
|
|
46
46
|
}
|
|
47
47
|
const question = {
|
|
48
48
|
answer: answer,
|
|
49
|
-
instruction: `Une urne contient
|
|
50
|
-
On tire successivement et sans remise 3 boules dans l'urne.
|
|
49
|
+
instruction: `Une urne contient $${blacks}$ boules noires numérotées de $1$ à $${blacks}$, $${reds}$ boules rouges numérotées de $1$ à $${reds}$ et $${greens}$ boules vertes numérotées de $1$ à $${greens}$.
|
|
50
|
+
On tire successivement et sans remise $3$ boules dans l'urne.
|
|
51
51
|
Combien de tirages ${instruction} sont possibles ?`,
|
|
52
52
|
keys: [],
|
|
53
53
|
answerFormat: "tex",
|
|
@@ -22,26 +22,26 @@ const getDiceCountingQuestion = () => {
|
|
|
22
22
|
break;
|
|
23
23
|
case 2:
|
|
24
24
|
face1 = (0, randint_1.randint)(1, 7);
|
|
25
|
-
instruction = `avec exactement une fois la face
|
|
25
|
+
instruction = `avec exactement une fois la face $${face1}$`;
|
|
26
26
|
answer = 3 * 5 * 5 + "";
|
|
27
27
|
break;
|
|
28
28
|
case 3:
|
|
29
29
|
face1 = (0, randint_1.randint)(1, 7);
|
|
30
|
-
instruction = `avec exactement deux fois la face
|
|
30
|
+
instruction = `avec exactement deux fois la face $${face1}$`;
|
|
31
31
|
answer = 3 * 5 + "";
|
|
32
32
|
break;
|
|
33
33
|
case 4:
|
|
34
34
|
face1 = (0, randint_1.randint)(1, 7);
|
|
35
35
|
face2 = (0, randint_1.randint)(1, 7, [face1]);
|
|
36
36
|
face3 = (0, randint_1.randint)(1, 7, [face1, face2]);
|
|
37
|
-
instruction = `avec exactement les faces
|
|
37
|
+
instruction = `avec exactement les faces $${face1}$, $${face2}$ et $${face3}$`;
|
|
38
38
|
answer = 6 + "";
|
|
39
39
|
break;
|
|
40
40
|
case 5:
|
|
41
41
|
face1 = (0, randint_1.randint)(1, 7);
|
|
42
42
|
face2 = (0, randint_1.randint)(1, 7, [face1]);
|
|
43
43
|
face3 = (0, randint_1.randint)(1, 7, [face1, face2]);
|
|
44
|
-
instruction = `avec exactement une fois la face
|
|
44
|
+
instruction = `avec exactement une fois la face $${face1}$ et une fois la face $${face2}$`;
|
|
45
45
|
answer = 3 * 5 + "";
|
|
46
46
|
break;
|
|
47
47
|
case 6:
|
|
@@ -55,7 +55,7 @@ const getDiceCountingQuestion = () => {
|
|
|
55
55
|
}
|
|
56
56
|
const question = {
|
|
57
57
|
answer: answer,
|
|
58
|
-
instruction: `On tire 3 fois consécutivement un dé à six faces numérotées de 1 à 6
|
|
58
|
+
instruction: `On tire $3$ fois consécutivement un dé à six faces numérotées de $1$ à $6$. Combien de tirages ${instruction} sont possibles ?`,
|
|
59
59
|
keys: [],
|
|
60
60
|
answerFormat: "tex",
|
|
61
61
|
identifiers: { type, face1, face2, face3 },
|
|
@@ -15,8 +15,8 @@ const getBallsBasicProbasQuestion = () => {
|
|
|
15
15
|
const answer = new rational_1.Rational(nbColorAsked, total).simplify().tex;
|
|
16
16
|
const question = {
|
|
17
17
|
answer,
|
|
18
|
-
instruction: `Dans un sac, il y a
|
|
19
|
-
|
|
18
|
+
instruction: `Dans un sac, il y a $${repartitions[0]}$ boules ${colors[0]}${repartitions[0] > 1 ? "s" : ""},
|
|
19
|
+
$${repartitions[1]}$ boules ${colors[1]}${repartitions[1] > 1 ? "s" : ""} et $${repartitions[2]}$ boules ${colors[2]}${repartitions[2] > 1 ? "s" : ""}. Quelle est la probabilité de tirer une boule ${colorAsked} ?`,
|
|
20
20
|
keys: [],
|
|
21
21
|
answerFormat: "tex",
|
|
22
22
|
identifiers: { colorAskedIndex, repartitions },
|
|
@@ -41,7 +41,7 @@ const getCardBasicProbasQuestion = () => {
|
|
|
41
41
|
}
|
|
42
42
|
const question = {
|
|
43
43
|
answer,
|
|
44
|
-
instruction: `On tire une carte dans un jeu de 52 cartes. Quelle est la probabilité d'obtenir ${target} ?`,
|
|
44
|
+
instruction: `On tire une carte dans un jeu de $52$ cartes. Quelle est la probabilité d'obtenir ${target} ?`,
|
|
45
45
|
keys: [],
|
|
46
46
|
answerFormat: "tex",
|
|
47
47
|
identifiers: { questionType, value, color: color },
|
|
@@ -16,7 +16,7 @@ const getDiceBasicProbasQuestion = () => {
|
|
|
16
16
|
const faceAsked = (0, randint_1.randint)(1, nbFaces + 1);
|
|
17
17
|
const target = isParityQuestion
|
|
18
18
|
? `un nombre ${isEvenQuestion ? "pair" : "impair"}`
|
|
19
|
-
: `la face
|
|
19
|
+
: `la face $${faceAsked}$`;
|
|
20
20
|
const answer = isParityQuestion
|
|
21
21
|
? isEvenQuestion
|
|
22
22
|
? (0, fractionNode_1.frac)(Math.floor(nbFaces / 2), nbFaces)
|
|
@@ -28,7 +28,7 @@ const getDiceBasicProbasQuestion = () => {
|
|
|
28
28
|
: (0, fractionNode_1.frac)(1, nbFaces).toTex();
|
|
29
29
|
const question = {
|
|
30
30
|
answer,
|
|
31
|
-
instruction: `On lance un dé équilibré à
|
|
31
|
+
instruction: `On lance un dé équilibré à $${nbFaces}$ faces. Quelle est la probabilité d'obtenir ${target} ?`,
|
|
32
32
|
keys: [],
|
|
33
33
|
answerFormat: "tex",
|
|
34
34
|
identifiers: { isParityQuestion, isEvenQuestion, nbFaces, faceAsked },
|
|
@@ -44,7 +44,7 @@ const getIssuesCountingForCardsQuestion = () => {
|
|
|
44
44
|
}
|
|
45
45
|
const question = {
|
|
46
46
|
answer,
|
|
47
|
-
instruction: `On tire une carte dans un jeu de 52 cartes. Combien l'événement $A = $ "obtenir ${target}" compte-t-il d'issues ?`,
|
|
47
|
+
instruction: `On tire une carte dans un jeu de $52$ cartes. Combien l'événement $A = $ "obtenir ${target}" compte-t-il d'issues ?`,
|
|
48
48
|
keys: [],
|
|
49
49
|
answerFormat: "tex",
|
|
50
50
|
identifiers: { questionType, value, color },
|
|
@@ -75,7 +75,7 @@ const generateInstruction = (exoType, a, n, op) => {
|
|
|
75
75
|
return "";
|
|
76
76
|
};
|
|
77
77
|
const generateType16Instruction = (a, b, op) => {
|
|
78
|
-
const instruction = `Qu
|
|
78
|
+
const instruction = `Qu'affichera le programme suivant ?
|
|
79
79
|
\`\`\`
|
|
80
80
|
a=${a}
|
|
81
81
|
n=1
|
|
@@ -87,7 +87,7 @@ const generateType16Instruction = (a, b, op) => {
|
|
|
87
87
|
return instruction;
|
|
88
88
|
};
|
|
89
89
|
const generateType17Instruction = (a, b, op) => {
|
|
90
|
-
const instruction = `Qu
|
|
90
|
+
const instruction = `Qu'affichera le programme suivant, si l'utilisateur entre $${a}$ ?
|
|
91
91
|
\`\`\`
|
|
92
92
|
a=input("Entrez un entier naturel non nul.")
|
|
93
93
|
a=int(a)
|
|
@@ -45,7 +45,7 @@ const getInstruction = (identifiers) => {
|
|
|
45
45
|
return `Une loterie contient $${pPercent}\\%$ de tickets gagnants. Un joueur achète $${n}$ tickets. On note $f$ la fréquence des tickets gagnants achetés par le joueur. Au seuil de $95\\%$, à quel intervalle devrait appartenir $f$ ? Arrondir les données au centième.`;
|
|
46
46
|
case 3:
|
|
47
47
|
default:
|
|
48
|
-
return `Un fabricant prétend que $${pPercent}\\%$ de ses produits sont recyclables. Dans un contrôle qualité sur un échantillon de $${n}$ produits, quel sera l'intervalle probable pour la fréquence observée de produits recyclables, avec un seuil de confiance de 99
|
|
48
|
+
return `Un fabricant prétend que $${pPercent}\\%$ de ses produits sont recyclables. Dans un contrôle qualité sur un échantillon de $${n}$ produits, quel sera l'intervalle probable pour la fréquence observée de produits recyclables, avec un seuil de confiance de $99\\%$ ?`;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
const getHint = (identifiers) => {
|
package/lib/latexTester.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latexTester.d.ts","sourceRoot":"","sources":["../src/latexTester.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"latexTester.d.ts","sourceRoot":"","sources":["../src/latexTester.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAW,MAAM,2CAuIxC,CAAC"}
|
package/lib/latexTester.js
CHANGED
|
@@ -7,6 +7,7 @@ const latexTester = (latex, isDefaultInMathMode = false) => {
|
|
|
7
7
|
let commandModeCount = 0;
|
|
8
8
|
let leftRightCount = 0;
|
|
9
9
|
let inArray = false;
|
|
10
|
+
let inPython = false;
|
|
10
11
|
for (let i = 0; i < latex.length; i++) {
|
|
11
12
|
const prevChar = latex[i - 1];
|
|
12
13
|
const char = latex[i];
|
|
@@ -14,6 +15,8 @@ const latexTester = (latex, isDefaultInMathMode = false) => {
|
|
|
14
15
|
if (char === "$") {
|
|
15
16
|
if (isDefaultInMathMode)
|
|
16
17
|
throw new Error("Dollar in default math mode");
|
|
18
|
+
if (inPython)
|
|
19
|
+
throw new Error("Dollar in python mode");
|
|
17
20
|
if (nextChar === "$") {
|
|
18
21
|
if (inDollarMode)
|
|
19
22
|
throw new Error("Double dollar instead of single");
|
|
@@ -28,7 +31,8 @@ const latexTester = (latex, isDefaultInMathMode = false) => {
|
|
|
28
31
|
}
|
|
29
32
|
else {
|
|
30
33
|
//check si nombre dans latex
|
|
31
|
-
if (!
|
|
34
|
+
if (!inPython &&
|
|
35
|
+
!isNaN(Number(char)) &&
|
|
32
36
|
char !== " " &&
|
|
33
37
|
char !== "\n" &&
|
|
34
38
|
char !== "\t") {
|
|
@@ -37,18 +41,23 @@ const latexTester = (latex, isDefaultInMathMode = false) => {
|
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
//check si charactere spécial
|
|
40
|
-
if (mustEscapeCharacters.includes(char) &&
|
|
44
|
+
if (mustEscapeCharacters.includes(char) &&
|
|
45
|
+
prevChar !== "\\" &&
|
|
46
|
+
!inPython) {
|
|
41
47
|
throw new Error("Must escape character");
|
|
42
48
|
}
|
|
43
49
|
//check si in math
|
|
44
|
-
if (mustBeInMath.includes(char) &&
|
|
50
|
+
if (mustBeInMath.includes(char) &&
|
|
51
|
+
!inDollarMode &&
|
|
52
|
+
!inDoubleDollarMode &&
|
|
53
|
+
!inPython) {
|
|
45
54
|
throw new Error(`Must be in math mode, ${char}, ${latex}`);
|
|
46
55
|
}
|
|
47
56
|
//check si commande bien fermé
|
|
48
|
-
if (char === "{" && prevChar !== "\\") {
|
|
57
|
+
if (char === "{" && prevChar !== "\\" && !inPython) {
|
|
49
58
|
commandModeCount++;
|
|
50
59
|
}
|
|
51
|
-
if (char === "}" && prevChar !== "\\") {
|
|
60
|
+
if (char === "}" && prevChar !== "\\" && !inPython) {
|
|
52
61
|
commandModeCount--;
|
|
53
62
|
}
|
|
54
63
|
const substring = latex.substring(i);
|
|
@@ -77,6 +86,34 @@ const latexTester = (latex, isDefaultInMathMode = false) => {
|
|
|
77
86
|
if (cmd === "\\right") {
|
|
78
87
|
leftRightCount--;
|
|
79
88
|
}
|
|
89
|
+
if (cmd === "\\begin") {
|
|
90
|
+
//lstlisting
|
|
91
|
+
//array / tabular
|
|
92
|
+
if (substring.startsWith("\\begin{lstlisting}")) {
|
|
93
|
+
if (inPython)
|
|
94
|
+
throw new Error("Python not closed");
|
|
95
|
+
inPython = true;
|
|
96
|
+
}
|
|
97
|
+
else if (substring.startsWith("\\begin{array}") ||
|
|
98
|
+
substring.startsWith("\\begin{tabular}")) {
|
|
99
|
+
if (inArray)
|
|
100
|
+
throw new Error("Array not closed");
|
|
101
|
+
inArray = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (cmd === "\\end") {
|
|
105
|
+
if (substring.startsWith("\\end{lstlisting}")) {
|
|
106
|
+
if (!inPython)
|
|
107
|
+
throw new Error("Python not opened");
|
|
108
|
+
inPython = false;
|
|
109
|
+
}
|
|
110
|
+
else if (substring.startsWith("\\end{array}") ||
|
|
111
|
+
substring.startsWith("\\end{tabular}")) {
|
|
112
|
+
if (!inArray)
|
|
113
|
+
throw new Error("Array not opened");
|
|
114
|
+
inArray = false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
80
117
|
}
|
|
81
118
|
//!Todo check si whitespace after double dollar
|
|
82
119
|
//!TODO Check si a^b^c ou a_b_c
|
|
@@ -89,6 +126,10 @@ const latexTester = (latex, isDefaultInMathMode = false) => {
|
|
|
89
126
|
throw new Error("Left right not balanced");
|
|
90
127
|
if (commandModeCount !== 0)
|
|
91
128
|
throw new Error(`Command not closed : ${latex}`);
|
|
129
|
+
if (inArray)
|
|
130
|
+
throw new Error("Array not closed");
|
|
131
|
+
if (inPython)
|
|
132
|
+
throw new Error("Python not closed");
|
|
92
133
|
return true;
|
|
93
134
|
};
|
|
94
135
|
exports.latexTester = latexTester;
|
|
@@ -161,4 +202,16 @@ const validCmds = [
|
|
|
161
202
|
"\\quad",
|
|
162
203
|
"\\qquad",
|
|
163
204
|
"\\rightarrow",
|
|
205
|
+
"\\textrm",
|
|
206
|
+
"\\mathcal",
|
|
207
|
+
"\\det",
|
|
208
|
+
"\\perp",
|
|
209
|
+
"\\dfrac",
|
|
210
|
+
"\\limits",
|
|
211
|
+
"\\displaystyle",
|
|
212
|
+
"\\euro",
|
|
213
|
+
"\\overset",
|
|
214
|
+
"\\Large",
|
|
215
|
+
"\\hspace",
|
|
216
|
+
"\\frown",
|
|
164
217
|
];
|