math-exercises 3.0.18 → 3.0.20
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/proportionality/rectangleSideAfterReduction.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/rectangleSideAfterReduction.js +2 -2
- package/lib/exercises/math/geometry/angles/recognizeAngleType.js +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.js +2 -1
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.js +1 -1
- package/lib/exercises/math/geometry/shapes/basicShapesRecognition.js +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts +1 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.js +1 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaNorms.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaNorms.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductViaNorms.js +147 -0
- package/lib/exercises/math/probaStat/basicStats/calculateFrequency.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicStats/calculateFrequency.js +19 -10
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/triangle.d.ts +2 -7
- package/lib/math/geometry/triangle.d.ts.map +1 -1
- package/lib/math/geometry/triangle.js +7 -12
- package/lib/tree/nodes/operators/scalarProductNode.d.ts +11 -0
- package/lib/tree/nodes/operators/scalarProductNode.d.ts.map +1 -0
- package/lib/tree/nodes/operators/scalarProductNode.js +16 -0
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rectangleSideAfterReduction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/rectangleSideAfterReduction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CAGnB,CAAC;AA8OF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"rectangleSideAfterReduction.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/proportionality/rectangleSideAfterReduction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CAGnB,CAAC;AA8OF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAmB7D,CAAC"}
|
|
@@ -68,7 +68,7 @@ const getInstruction = (identifiers) => {
|
|
|
68
68
|
const d3n = new D3Node();
|
|
69
69
|
// Set SVG dimensions
|
|
70
70
|
const width = 300, height = 150;
|
|
71
|
-
const svg = d3n.createSVG(width, height);
|
|
71
|
+
const svg = d3n.createSVG(width, height, { id: "nonLatex" });
|
|
72
72
|
// Function to add rotated rectangles
|
|
73
73
|
function addRectangle(svg, x, y, w, h, angle, color, label1, label2) {
|
|
74
74
|
const group = svg
|
|
@@ -183,7 +183,7 @@ const getRectangleSideAfterReductionQuestion = (ops) => {
|
|
|
183
183
|
export const rectangleSideAfterReduction = {
|
|
184
184
|
id: "rectangleSideAfterReduction",
|
|
185
185
|
// connector: "",
|
|
186
|
-
label: "
|
|
186
|
+
label: "Déterminer les dimensions d'un rectangle après réduction",
|
|
187
187
|
isSingleStep: true,
|
|
188
188
|
generator: (nb, opts) => getDistinctQuestions(() => getRectangleSideAfterReductionQuestion(opts), nb),
|
|
189
189
|
qcmTimer: 60,
|
|
@@ -148,7 +148,7 @@ const getGGBOptions = (identifiers) => {
|
|
|
148
148
|
const ggb = new GeogebraConstructor({
|
|
149
149
|
commands: [
|
|
150
150
|
...points.flatMap((p) => p.toGGBCommand()),
|
|
151
|
-
...lines.flatMap((l) => l.toGGBCommands(false)),
|
|
151
|
+
...lines.flatMap((l) => l.toGGBCommands(false, { color: "black" })),
|
|
152
152
|
...angle.toCommands({ color: "red" }),
|
|
153
153
|
],
|
|
154
154
|
hideAxes: true,
|
package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildPointFromAxialSymetry.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAGL,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAEtC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"buildPointFromAxialSymetry.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAGL,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAEtC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAkGF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAe5D,CAAC"}
|
|
@@ -26,7 +26,7 @@ const getGGBAnswer = (identifiers) => {
|
|
|
26
26
|
const circle = new Circle(center, point, "C");
|
|
27
27
|
return [
|
|
28
28
|
...sol.toGGBCommand(),
|
|
29
|
-
...perp.toGGBCommands(false),
|
|
29
|
+
...perp.toGGBCommands(false, { color: "black" }),
|
|
30
30
|
...circle.toGGBCommands(false),
|
|
31
31
|
];
|
|
32
32
|
};
|
|
@@ -37,6 +37,7 @@ const getStudentGGBOptions = (identifiers) => {
|
|
|
37
37
|
...point.toGGBCommand(),
|
|
38
38
|
...line.toGGBCommands(false, {
|
|
39
39
|
showLabel: true,
|
|
40
|
+
color: "black",
|
|
40
41
|
}),
|
|
41
42
|
];
|
|
42
43
|
const sol = getSolutionPoint(identifiers);
|
|
@@ -29,7 +29,7 @@ const getBasicShapesNamingQuestion = () => {
|
|
|
29
29
|
case 3: //droite
|
|
30
30
|
default:
|
|
31
31
|
const line = LineConstructor.random();
|
|
32
|
-
commands.push(...line.toGGBCommands(true));
|
|
32
|
+
commands.push(...line.toGGBCommands(true, { color: "black" }));
|
|
33
33
|
answer = line.toTexNoLeftRight();
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
@@ -31,7 +31,7 @@ const getBasicShapesRecognitionQuestion = () => {
|
|
|
31
31
|
default:
|
|
32
32
|
answer = "Une droite";
|
|
33
33
|
const line = LineConstructor.random();
|
|
34
|
-
commands.push(...line.toGGBCommands(true));
|
|
34
|
+
commands.push(...line.toGGBCommands(true, { color: "black" }));
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
37
|
const ggb = new GeogebraConstructor({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AAGzC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { TriangleIdentifiers } from "../../../../../math/geometry/triangle.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
triangleIdentifiers: TriangleIdentifiers;
|
|
5
|
+
};
|
|
6
|
+
export declare const scalarProductViaNorms: Exercise<Identifiers>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=scalarProductViaNorms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalarProductViaNorms.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/scalarProductViaNorms.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAEL,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAWzC,KAAK,WAAW,GAAG;IACjB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AA8IF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { TriangleConstructor, } from "../../../../../math/geometry/triangle.js";
|
|
6
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
7
|
+
import { add } from "../../../../../tree/nodes/operators/addNode.js";
|
|
8
|
+
import { frac } from "../../../../../tree/nodes/operators/fractionNode.js";
|
|
9
|
+
import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
|
|
10
|
+
import { cdot } from "../../../../../tree/nodes/operators/scalarProductNode.js";
|
|
11
|
+
import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
12
|
+
import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
|
|
13
|
+
import { alignTex } from "../../../../../utils/latex/alignTex.js";
|
|
14
|
+
const getPropositions = (n, { answer, triangleIdentifiers }) => {
|
|
15
|
+
const propositions = [];
|
|
16
|
+
addValidProp(propositions, answer);
|
|
17
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
18
|
+
const A = triangle.sides[0].getLength();
|
|
19
|
+
const B = triangle.sides[1].getLength();
|
|
20
|
+
const C = triangle.sides[2].getLength();
|
|
21
|
+
// return multiply(frac(1, 2), substract(add(C, B), A));
|
|
22
|
+
tryToAddWrongProp(propositions, substract(add(C ** 2, B ** 2), A ** 2)
|
|
23
|
+
.simplify()
|
|
24
|
+
.toTex());
|
|
25
|
+
tryToAddWrongProp(propositions, multiply(frac(1, 2), substract(add(C, B), A))
|
|
26
|
+
.simplify()
|
|
27
|
+
.toTex());
|
|
28
|
+
tryToAddWrongProp(propositions, multiply(frac(1, 2), substract(add(A ** 2, B ** 2), C ** 2))
|
|
29
|
+
.simplify()
|
|
30
|
+
.toTex());
|
|
31
|
+
while (propositions.length < n) {
|
|
32
|
+
tryToAddWrongProp(propositions, randint(-50, 50).frenchify());
|
|
33
|
+
}
|
|
34
|
+
return shuffleProps(propositions, n);
|
|
35
|
+
};
|
|
36
|
+
const getAnswerNode = (identifiers) => {
|
|
37
|
+
const { triangleIdentifiers } = identifiers;
|
|
38
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
39
|
+
const A = triangle.sides[0].getLength() ** 2;
|
|
40
|
+
const B = triangle.sides[1].getLength() ** 2;
|
|
41
|
+
const C = triangle.sides[2].getLength() ** 2;
|
|
42
|
+
return multiply(frac(1, 2), substract(add(C, B), A));
|
|
43
|
+
};
|
|
44
|
+
const getAnswer = (identifiers) => {
|
|
45
|
+
return getAnswerNode(identifiers).simplify().toTex();
|
|
46
|
+
};
|
|
47
|
+
const getInstruction = (identifiers) => {
|
|
48
|
+
const { triangleIdentifiers } = identifiers;
|
|
49
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
50
|
+
const sides = triangle.sides.map((e) => e.toLengthTex()).reverse();
|
|
51
|
+
const vectors = triangle.sides.map((e) => e.toVector()).reverse();
|
|
52
|
+
return `Le triangle $${triangle.name}$ est tel que $${sides[0]}$, $${sides[1]}$ et $${sides[2]}$.
|
|
53
|
+
|
|
54
|
+
Calculer $${cdot(vectors[0], vectors[1]).toTex()}$.`;
|
|
55
|
+
};
|
|
56
|
+
const getHint = (identifiers) => {
|
|
57
|
+
return `Si $A$, $B$ et $C$ sont trois points du plan, alors :
|
|
58
|
+
|
|
59
|
+
$$
|
|
60
|
+
\\overrightarrow{AB}\\cdot \\overrightarrow{AC} = \\frac{1}{2}\\left(AB^2 + AC^2 - BC^2 \\right)
|
|
61
|
+
$$`;
|
|
62
|
+
};
|
|
63
|
+
const getCorrection = (identifiers) => {
|
|
64
|
+
const { triangleIdentifiers } = identifiers;
|
|
65
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
66
|
+
const sidesInsideNames = triangle.sides
|
|
67
|
+
.map((e) => e.toInsideName())
|
|
68
|
+
.reverse();
|
|
69
|
+
const answerNode = getAnswerNode(identifiers);
|
|
70
|
+
return `D'après le cours, on a :
|
|
71
|
+
|
|
72
|
+
${alignTex([
|
|
73
|
+
[
|
|
74
|
+
"",
|
|
75
|
+
`\\overrightarrow{${sidesInsideNames[0]}}\\cdot \\overrightarrow{${sidesInsideNames[1]}}`,
|
|
76
|
+
],
|
|
77
|
+
[
|
|
78
|
+
"=",
|
|
79
|
+
`\\frac{1}{2}\\left(${sidesInsideNames[0]}^2 + ${sidesInsideNames[1]}^2 - ${sidesInsideNames[2]}^2 \\right)`,
|
|
80
|
+
],
|
|
81
|
+
["=", answerNode.toTex()],
|
|
82
|
+
["=", answerNode.simplify().toTex()],
|
|
83
|
+
])}
|
|
84
|
+
`;
|
|
85
|
+
};
|
|
86
|
+
const getKeys = (identifiers) => {
|
|
87
|
+
return [];
|
|
88
|
+
};
|
|
89
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
90
|
+
try {
|
|
91
|
+
return rationalVEA(ans, answer);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
return handleVEAError(err);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const getGGBOptions = (identifiers) => {
|
|
98
|
+
const { triangleIdentifiers } = identifiers;
|
|
99
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
100
|
+
triangle.showSidesLength();
|
|
101
|
+
const ggb = new GeogebraConstructor({
|
|
102
|
+
commands: triangle.commands,
|
|
103
|
+
hideAxes: true,
|
|
104
|
+
hideGrid: true,
|
|
105
|
+
});
|
|
106
|
+
return ggb.getOptions({
|
|
107
|
+
coords: triangle.generateCoords(),
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const getScalarProductViaNormsQuestion = (ops) => {
|
|
111
|
+
const triangle = TriangleConstructor.randomNiceSides({
|
|
112
|
+
randomName: true,
|
|
113
|
+
intSides: true,
|
|
114
|
+
});
|
|
115
|
+
const identifiers = {
|
|
116
|
+
triangleIdentifiers: triangle.toIdentifiers(),
|
|
117
|
+
};
|
|
118
|
+
const question = {
|
|
119
|
+
answer: getAnswer(identifiers),
|
|
120
|
+
instruction: getInstruction(identifiers),
|
|
121
|
+
keys: getKeys(identifiers),
|
|
122
|
+
answerFormat: "tex",
|
|
123
|
+
identifiers,
|
|
124
|
+
hint: getHint(identifiers),
|
|
125
|
+
correction: getCorrection(identifiers),
|
|
126
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
127
|
+
};
|
|
128
|
+
return question;
|
|
129
|
+
};
|
|
130
|
+
export const scalarProductViaNorms = {
|
|
131
|
+
id: "scalarProductViaNorms",
|
|
132
|
+
connector: "=",
|
|
133
|
+
label: "Calculer un produit scalaire (formule des normes)",
|
|
134
|
+
isSingleStep: true,
|
|
135
|
+
generator: (nb, opts) => getDistinctQuestions(() => getScalarProductViaNormsQuestion(opts), nb),
|
|
136
|
+
qcmTimer: 60,
|
|
137
|
+
freeTimer: 60,
|
|
138
|
+
getPropositions,
|
|
139
|
+
isAnswerValid,
|
|
140
|
+
subject: "Mathématiques",
|
|
141
|
+
getInstruction,
|
|
142
|
+
getHint,
|
|
143
|
+
getCorrection,
|
|
144
|
+
getAnswer,
|
|
145
|
+
hasHintAndCorrection: true,
|
|
146
|
+
hasGeogebra: true,
|
|
147
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicStats/calculateFrequency.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"calculateFrequency.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/basicStats/calculateFrequency.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAyGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAiBpD,CAAC"}
|
|
@@ -3,37 +3,44 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
|
|
|
3
3
|
import { rationalVEA } from "../../../../exercises/vea/rationalVEA.js";
|
|
4
4
|
import { RationalConstructor } from "../../../../math/numbers/rationals/rational.js";
|
|
5
5
|
import { randint } from "../../../../math/utils/random/randint.js";
|
|
6
|
+
import { round } from "../../../../math/utils/round.js";
|
|
6
7
|
import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
7
8
|
import { random } from "../../../../utils/alea/random.js";
|
|
8
9
|
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
10
|
+
import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
|
|
9
11
|
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
10
12
|
const propositions = [];
|
|
11
13
|
const { k, nbEssais } = identifiers;
|
|
12
14
|
addValidProp(propositions, answer);
|
|
13
15
|
tryToAddWrongProp(propositions, k + "");
|
|
14
|
-
tryToAddWrongProp(propositions,
|
|
16
|
+
tryToAddWrongProp(propositions, round(k / 100, 2).frenchify());
|
|
15
17
|
while (propositions.length < n) {
|
|
16
|
-
tryToAddWrongProp(propositions, RationalConstructor.randomIrreductible().toTree().
|
|
18
|
+
tryToAddWrongProp(propositions, round(RationalConstructor.randomIrreductible().toTree().evaluate(), 2).frenchify());
|
|
17
19
|
}
|
|
18
20
|
return shuffleProps(propositions, n);
|
|
19
21
|
};
|
|
20
22
|
const getAnswer = (identifiers) => {
|
|
21
23
|
const { k, nbEssais } = identifiers;
|
|
22
|
-
return
|
|
24
|
+
return round(k / nbEssais, 2).frenchify();
|
|
23
25
|
};
|
|
24
26
|
const getInstruction = (identifiers) => {
|
|
25
27
|
const { type, k, nbEssais, caracType } = identifiers;
|
|
28
|
+
let instruction = ";";
|
|
26
29
|
switch (type) {
|
|
27
30
|
case 0: //pièce
|
|
28
|
-
|
|
31
|
+
instruction = `On lance une pièce de monnaie $${nbEssais}$ fois. On tombe $${k}$ fois sur ${caracType}.`;
|
|
29
32
|
case 1: //dé 6 faces
|
|
30
|
-
|
|
33
|
+
instruction = `On lance un dé à $6$ faces $${nbEssais}$ fois. On tombe $${k}$ fois sur ${caracType}.`;
|
|
31
34
|
case 2: // dé X faces
|
|
32
|
-
|
|
35
|
+
instruction = `On lance un dé à $12$ faces $${nbEssais}$ fois. On tombe $${k}$ fois sur ${caracType}.`;
|
|
33
36
|
case 3:
|
|
34
37
|
default: //deux dés 6 faces
|
|
35
|
-
|
|
38
|
+
instruction = `On lance deux dés à $6$ faces $${nbEssais}$ fois. On note la somme obtenue. On tombe $${k}$ fois sur ${caracType}.`;
|
|
36
39
|
}
|
|
40
|
+
instruction += `
|
|
41
|
+
|
|
42
|
+
Quelle est la fréquence d'apparition de ${caracType} ? Arrondir au centième près.`;
|
|
43
|
+
return instruction;
|
|
37
44
|
};
|
|
38
45
|
const getHint = (identifiers) => {
|
|
39
46
|
const { type, k, nbEssais, caracType } = identifiers;
|
|
@@ -44,15 +51,17 @@ const getCorrection = (identifiers) => {
|
|
|
44
51
|
return `On a obtenu $${k}$ fois ${caracType} sur les $${nbEssais}$ lancers. La fréquence d'apparition de ${caracType} est donc :
|
|
45
52
|
|
|
46
53
|
$$
|
|
47
|
-
${frac(k, nbEssais).
|
|
54
|
+
${frac(k, nbEssais).toTex()} ${approxOrEqual(k / nbEssais, 2).join("")}
|
|
48
55
|
$$`;
|
|
49
56
|
};
|
|
50
57
|
const getKeys = (identifiers) => {
|
|
51
58
|
return [];
|
|
52
59
|
};
|
|
53
|
-
const isAnswerValid = (ans, { answer }) => {
|
|
60
|
+
const isAnswerValid = (ans, { answer, k, nbEssais }) => {
|
|
54
61
|
try {
|
|
55
|
-
return rationalVEA(ans,
|
|
62
|
+
return rationalVEA(ans, frac(k, nbEssais).simplify().toTex(), {
|
|
63
|
+
decimalPrecision: 2,
|
|
64
|
+
});
|
|
56
65
|
}
|
|
57
66
|
catch (err) {
|
|
58
67
|
return handleVEAError(err);
|
package/lib/index.d.ts
CHANGED
|
@@ -1165,6 +1165,8 @@ declare const mathExercises: (Exercise<{
|
|
|
1165
1165
|
AB: number;
|
|
1166
1166
|
AC: number;
|
|
1167
1167
|
trigoPoint: string;
|
|
1168
|
+
}, {}> | Exercise<{
|
|
1169
|
+
triangleIdentifiers: import("./math/geometry/triangle.js").TriangleIdentifiers;
|
|
1168
1170
|
}, {}> | Exercise<{
|
|
1169
1171
|
points: import("./math/geometry/point.js").PointIdentifiers[];
|
|
1170
1172
|
startPointIndex: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/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;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;
|
|
12
|
-
static randomNiceSides({ names, randomName, }: {
|
|
12
|
+
static randomNiceSides({ names, randomName, intSides, }: {
|
|
13
13
|
names?: string[] | undefined;
|
|
14
14
|
randomName?: boolean | undefined;
|
|
15
|
+
intSides?: boolean | undefined;
|
|
15
16
|
}): Triangle;
|
|
16
17
|
static randomName(): string[];
|
|
17
18
|
}
|
|
@@ -35,12 +36,6 @@ export declare class Triangle {
|
|
|
35
36
|
props?: TriangleProps;
|
|
36
37
|
constructor(points: Point[], props?: TriangleProps);
|
|
37
38
|
toIdentifiers(): TriangleIdentifiers;
|
|
38
|
-
/************* ✨ Codeium Command ⭐ *************/
|
|
39
|
-
/**
|
|
40
|
-
* Returns the perimeter of the triangle.
|
|
41
|
-
* @returns {number} the perimeter of the triangle.
|
|
42
|
-
*/
|
|
43
|
-
/****** fbb7c5d7-3919-4ef2-b5ba-db0d6770666d *******/
|
|
44
39
|
getPerimeter(): number;
|
|
45
40
|
getArea(): number;
|
|
46
41
|
isRight(): Boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triangle.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/triangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAKnC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAEL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"triangle.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/triangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MA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I,MAAM;IAItB,OAAO,IAAI,MAAM;IASjB,OAAO,IAAI,OAAO;IAIlB,aAAa,IAAI,OAAO;IAMxB,WAAW,IAAI,OAAO;IAUtB,SAAS,IAAI,OAAO;IASpB,aAAa,CACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE;QACJ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAWH,cAAc,CACZ,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB;IAKH,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE;IAQtC,SAAS,CACP,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IAYH,UAAU,CACR,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,KAAK,CAAC;KACnB;IAoCH,cAAc,IAAI,MAAM,EAAE;CAkB3B"}
|
|
@@ -7,6 +7,7 @@ import { round } from "../utils/round.js";
|
|
|
7
7
|
import { randfloat } from "../utils/random/randfloat.js";
|
|
8
8
|
import { LineConstructor } from "./line.js";
|
|
9
9
|
import { reifyAlgebraic, } from "../../tree/nodes/nodeConstructor.js";
|
|
10
|
+
import { randint } from "../utils/random/randint.js";
|
|
10
11
|
export class TriangleConstructor {
|
|
11
12
|
static fromIdentifiers(identifiers) {
|
|
12
13
|
return new Triangle(identifiers.points.map((p) => PointConstructor.fromIdentifiers(p)), {
|
|
@@ -15,7 +16,7 @@ export class TriangleConstructor {
|
|
|
15
16
|
sidesLengths: identifiers.props?.sidesLengths?.map((n) => n ? reifyAlgebraic(n) : undefined),
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
|
-
static randomNiceSides({ names = ["A", "B", "C"], randomName = false, }) {
|
|
19
|
+
static randomNiceSides({ names = ["A", "B", "C"], randomName = false, intSides = false, }) {
|
|
19
20
|
let vertices = [];
|
|
20
21
|
if (randomName)
|
|
21
22
|
vertices = TriangleConstructor.randomName();
|
|
@@ -25,8 +26,8 @@ export class TriangleConstructor {
|
|
|
25
26
|
const addAngle = randfloat(Math.PI / 4, (3 * Math.PI) / 4);
|
|
26
27
|
//on construit [AC] sur (Ox) de milieu O et de taille 2*xRand
|
|
27
28
|
//puis [AB] sur (Ox) qu'on rotate
|
|
28
|
-
const xRand = randfloat(5, 8, 1);
|
|
29
|
-
const xRand2 = randfloat(-5, 5, 1);
|
|
29
|
+
const xRand = intSides ? randint(5, 9) : randfloat(5, 8, 1);
|
|
30
|
+
const xRand2 = intSides ? randint(-5, 5) : randfloat(-5, 5, 1);
|
|
30
31
|
const origin = new Point("O", (0).toTree(), (0).toTree());
|
|
31
32
|
const startA = new Point(vertices[0], (-xRand).toTree(), (0).toTree());
|
|
32
33
|
const A = startA.rotate(angle, origin);
|
|
@@ -34,9 +35,9 @@ export class TriangleConstructor {
|
|
|
34
35
|
const B = new Point(vertices[1], (-xRand + xRand2).toTree(), (0).toTree()).rotate(angle + addAngle, startA);
|
|
35
36
|
return new Triangle([A, B, C], {
|
|
36
37
|
sidesLengths: [
|
|
37
|
-
round(B.distanceTo(C), 1).toTree(),
|
|
38
|
-
round(A.distanceTo(C), 1).toTree(),
|
|
39
|
-
round(A.distanceTo(B), 1).toTree(),
|
|
38
|
+
round(B.distanceTo(C), intSides ? 0 : 1).toTree(),
|
|
39
|
+
round(A.distanceTo(C), intSides ? 0 : 1).toTree(),
|
|
40
|
+
round(A.distanceTo(B), intSides ? 0 : 1).toTree(),
|
|
40
41
|
],
|
|
41
42
|
});
|
|
42
43
|
}
|
|
@@ -105,12 +106,6 @@ export class Triangle {
|
|
|
105
106
|
},
|
|
106
107
|
};
|
|
107
108
|
}
|
|
108
|
-
/************* ✨ Codeium Command ⭐ *************/
|
|
109
|
-
/**
|
|
110
|
-
* Returns the perimeter of the triangle.
|
|
111
|
-
* @returns {number} the perimeter of the triangle.
|
|
112
|
-
*/
|
|
113
|
-
/****** fbb7c5d7-3919-4ef2-b5ba-db0d6770666d *******/
|
|
114
109
|
getPerimeter() {
|
|
115
110
|
return this.sides.reduce((acc, curr) => acc + curr.getLength(), 0);
|
|
116
111
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NodeOptions, ToTexOptions } from "../node.js";
|
|
2
|
+
import { Vector } from "../../../math/geometry/vector.js";
|
|
3
|
+
export declare const cdot: (a: Vector, b: Vector) => ScalarProductNode;
|
|
4
|
+
export declare class ScalarProductNode {
|
|
5
|
+
leftChild: Vector;
|
|
6
|
+
rightChild: Vector;
|
|
7
|
+
opts?: NodeOptions;
|
|
8
|
+
constructor(leftChild: Vector, rightChild: Vector, opts?: NodeOptions);
|
|
9
|
+
toTex(options?: ToTexOptions): string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=scalarProductNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalarProductNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/scalarProductNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,WAAW,EAAY,YAAY,EAAE,MAAM,YAAY,CAAC;AA2BhF,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD,eAAO,MAAM,IAAI,MAAO,MAAM,KAAK,MAAM,sBAExC,CAAC;AAEF,qBAAa,iBAAiB;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;gBACP,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW;IAMrE,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM;CAGtC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const cdot = (a, b) => {
|
|
2
|
+
return new ScalarProductNode(a, b);
|
|
3
|
+
};
|
|
4
|
+
export class ScalarProductNode {
|
|
5
|
+
leftChild;
|
|
6
|
+
rightChild;
|
|
7
|
+
opts;
|
|
8
|
+
constructor(leftChild, rightChild, opts) {
|
|
9
|
+
this.leftChild = leftChild;
|
|
10
|
+
this.rightChild = rightChild;
|
|
11
|
+
this.opts = opts;
|
|
12
|
+
}
|
|
13
|
+
toTex(options) {
|
|
14
|
+
return `${this.leftChild.toTex()}\\cdot ${this.rightChild.toTex()}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "math-exercises",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.20",
|
|
5
5
|
"description": "Math exercises generator for middle school and high school",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"files": [
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"testpdf": "npm run build && node lib/tests/pdfExo.test.js",
|
|
19
19
|
"testsimplify": "npx jest simplify.test.js",
|
|
20
20
|
"prepublishOnly": "npm run build",
|
|
21
|
-
"build": "tsc && tsc-alias"
|
|
21
|
+
"build": "tsc && tsc-alias",
|
|
22
|
+
"patch": "npm run testml && npm version patch && npm publish"
|
|
22
23
|
},
|
|
23
24
|
"keywords": [],
|
|
24
25
|
"author": "Heureux Hasard",
|