math-exercises 3.0.139 → 3.0.141
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/arithmetics/euclideanDivision.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/euclideanDivision.js +65 -8
- package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/findRightPrimeDecomposition.js +3 -6
- package/lib/exercises/math/calcul/arithmetics/index.d.ts +3 -0
- package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/index.js +3 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.d.ts +8 -0
- package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.d.ts.map +1 -0
- package/lib/exercises/math/calcul/arithmetics/primeNumbersAffirmations.js +128 -0
- package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.d.ts +8 -0
- package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.d.ts.map +1 -0
- package/lib/exercises/math/calcul/proportionality/fourthProportionalFromProblem.js +392 -0
- package/lib/exercises/math/calcul/proportionality/index.d.ts +2 -0
- package/lib/exercises/math/calcul/proportionality/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/index.js +2 -0
- package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.d.ts +8 -0
- package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.d.ts.map +1 -0
- package/lib/exercises/math/calcul/proportionality/isProportionalFromProblem.js +349 -0
- package/lib/exercises/math/calculLitteral/equation/isEqualityTrue.js +4 -4
- package/lib/exercises/math/dataRepresentations/index.js +1 -0
- package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.d.ts +12 -0
- package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.d.ts.map +1 -0
- package/lib/exercises/math/dataRepresentations/placePointsFromDataTable.js +175 -0
- package/lib/exercises/math/functions/affines/index.d.ts +2 -0
- package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/index.js +2 -0
- package/lib/exercises/math/functions/affines/placePointsFromAffine.d.ts +8 -0
- package/lib/exercises/math/functions/affines/placePointsFromAffine.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/placePointsFromAffine.js +135 -0
- package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.d.ts +10 -0
- package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.d.ts.map +1 -0
- package/lib/exercises/math/functions/affines/recognizeAffinePointsFromPoints.js +208 -0
- package/lib/exercises/math/functions/basics/index.d.ts +1 -0
- package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/index.js +1 -0
- package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts +8 -0
- package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts.map +1 -0
- package/lib/exercises/math/functions/basics/placePointsFromValueTable.js +128 -0
- package/lib/exercises/math/geometry/pythagore/isTriangleRight.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/isTriangleRight.js +19 -9
- package/lib/exercises/utils/data/boxXY.d.ts +7 -0
- package/lib/exercises/utils/data/boxXY.d.ts.map +1 -0
- package/lib/exercises/utils/data/boxXY.js +16 -0
- package/lib/exercises/utils/data/isBoxable.d.ts +2 -0
- package/lib/exercises/utils/data/isBoxable.d.ts.map +1 -0
- package/lib/exercises/utils/data/isBoxable.js +5 -0
- package/lib/exercises/utils/data/randomDataTable.d.ts +11 -0
- package/lib/exercises/utils/data/randomDataTable.d.ts.map +1 -0
- package/lib/exercises/utils/data/randomDataTable.js +65 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/utils/random/randfloat.d.ts +1 -0
- package/lib/math/utils/random/randfloat.d.ts.map +1 -1
- package/lib/math/utils/random/randfloat.js +35 -0
- package/lib/utils/arrays/transpose.d.ts +2 -0
- package/lib/utils/arrays/transpose.d.ts.map +1 -0
- package/lib/utils/arrays/transpose.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { randfloatFromTruncatedCenteredGaussian } from "../../../math/utils/random/randfloat.js";
|
|
2
|
+
import { randint } from "../../../math/utils/random/randint.js";
|
|
3
|
+
import { randomMany } from "../../../utils/alea/random.js";
|
|
4
|
+
import { transpose } from "../../../utils/arrays/transpose.js";
|
|
5
|
+
const dictCategories = {
|
|
6
|
+
biometric: {
|
|
7
|
+
age: {
|
|
8
|
+
nameTex: "âge",
|
|
9
|
+
gen: (min = 10, max = 20) => Math.max(min, Math.min(max, randint(min, max + 1))),
|
|
10
|
+
},
|
|
11
|
+
poids: {
|
|
12
|
+
nameTex: "poids ($\\textrm{kg}$)",
|
|
13
|
+
gen: (min = 40, max = 80) => Math.max(min, Math.min(max, randint(min, max + 1))),
|
|
14
|
+
},
|
|
15
|
+
taille: {
|
|
16
|
+
nameTex: "taille ($\\textrm{m}$)",
|
|
17
|
+
gen: (min = 1.5, max = 2.1) => Math.max(min, Math.min(max, randfloatFromTruncatedCenteredGaussian(min, max, 2))),
|
|
18
|
+
},
|
|
19
|
+
pointure: {
|
|
20
|
+
nameTex: "pointure",
|
|
21
|
+
gen: (min = 35, max = 48) => Math.max(min, Math.min(max, randfloatFromTruncatedCenteredGaussian(min, max, 0))),
|
|
22
|
+
},
|
|
23
|
+
surfaceMain: {
|
|
24
|
+
nameTex: "surface de main (${\\textrm{cm}^2}$)",
|
|
25
|
+
gen: (min = 90, max = 110) => Math.max(min, Math.min(max, randfloatFromTruncatedCenteredGaussian(min, max, 0))),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
social: {
|
|
29
|
+
revenuFoyer: {
|
|
30
|
+
nameTex: "revenu du foyer ($\\textrm{€}$)",
|
|
31
|
+
gen: (min = 1000, max = 4000) => Math.max(min, Math.min(max, randint(min, max + 1))),
|
|
32
|
+
},
|
|
33
|
+
nombreFreresEtSoeurs: {
|
|
34
|
+
nameTex: "nombre de frères et soeurs",
|
|
35
|
+
gen: (min = 0, max = 4) => Math.max(min, Math.min(max, randint(min, max + 1))),
|
|
36
|
+
},
|
|
37
|
+
dureeReseauxSociaux: {
|
|
38
|
+
nameTex: "durée quotidienne sur les réseaux sociaux ($\\textrm{h}$)",
|
|
39
|
+
gen: (min = 0, max = 8) => Math.max(min, Math.min(max, randfloatFromTruncatedCenteredGaussian(min, max, 1))),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export const randomDataCategAndValues = (nbCateg, nbValues) => {
|
|
44
|
+
const allCateg = Object.values(dictCategories).flatMap((miniDict) => Object.values(miniDict));
|
|
45
|
+
const pickedCategs = randomMany(allCateg, nbCateg);
|
|
46
|
+
const arrCategAndValues = pickedCategs.map((categ) => {
|
|
47
|
+
return {
|
|
48
|
+
categ,
|
|
49
|
+
values: [...Array(nbValues).keys()].map((_) => categ.gen()),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
return arrCategAndValues;
|
|
53
|
+
};
|
|
54
|
+
export const randomDataTable = (nbCateg = 3, nbValues = 3, isRowBased = true) => {
|
|
55
|
+
const arrCategAndValues = randomDataCategAndValues(nbCateg, nbValues);
|
|
56
|
+
const rowBasedDataTable = arrCategAndValues.map(({ categ, values }) => {
|
|
57
|
+
return [categ.nameTex, ...values.map((value) => `$${value.frenchify()}$`)];
|
|
58
|
+
});
|
|
59
|
+
if (isRowBased) {
|
|
60
|
+
return rowBasedDataTable;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return transpose(rowBasedDataTable);
|
|
64
|
+
}
|
|
65
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -53,6 +53,14 @@ declare const mathExercises: (Exercise<{
|
|
|
53
53
|
nb: number;
|
|
54
54
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
55
55
|
nbs: number[];
|
|
56
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
57
|
+
nb: number;
|
|
58
|
+
fakeDecomps: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
59
|
+
}, {
|
|
60
|
+
doNotUsePowers?: boolean;
|
|
61
|
+
}> | Exercise<{
|
|
62
|
+
rightAffirmationsIndexes: number[];
|
|
63
|
+
wrongAffirmationsIndexes: number[];
|
|
56
64
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
57
65
|
integerFirst: boolean;
|
|
58
66
|
integer: number;
|
|
@@ -238,6 +246,12 @@ declare const mathExercises: (Exercise<{
|
|
|
238
246
|
yValues: number[];
|
|
239
247
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
240
248
|
lengths: number[];
|
|
249
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
250
|
+
situationIndex: number;
|
|
251
|
+
values: number[][];
|
|
252
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
253
|
+
situationIndex: number;
|
|
254
|
+
values: number[][];
|
|
241
255
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
242
256
|
precisionAsked: number;
|
|
243
257
|
decimal: number;
|
|
@@ -1081,6 +1095,11 @@ declare const mathExercises: (Exercise<{
|
|
|
1081
1095
|
nbSteps: string;
|
|
1082
1096
|
isSingleUseOperators: boolean;
|
|
1083
1097
|
}> | Exercise<{
|
|
1098
|
+
nodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1099
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1100
|
+
nodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1101
|
+
pointIds: import("./math/geometry/point.js").PointIdentifiers[];
|
|
1102
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1084
1103
|
xValue: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1085
1104
|
polynomeCoeffs: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
1086
1105
|
imageSyntaxText: boolean;
|
|
@@ -1176,6 +1195,8 @@ declare const mathExercises: (Exercise<{
|
|
|
1176
1195
|
nodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
1177
1196
|
};
|
|
1178
1197
|
xValue: number;
|
|
1198
|
+
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1199
|
+
arrCoordsAsNodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[][];
|
|
1179
1200
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
|
1180
1201
|
k: number;
|
|
1181
1202
|
}, Record<string, string | boolean | string[]>> | Exercise<{
|
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,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -8,4 +8,5 @@ export type RandfloatProps = [
|
|
|
8
8
|
excludes?: number[] | ((x: number) => boolean)
|
|
9
9
|
];
|
|
10
10
|
export declare const randfloat: (...args: RandfloatProps) => number;
|
|
11
|
+
export declare const randfloatFromTruncatedCenteredGaussian: (a?: number, b?: number | undefined, roundTo?: number | undefined, excludes?: number[] | ((x: number) => boolean) | undefined) => number;
|
|
11
12
|
//# sourceMappingURL=randfloat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randfloat.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/random/randfloat.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,EAAE,MAAM;IACT,CAAC,CAAC,EAAE,MAAM;IACV,OAAO,CAAC,EAAE,MAAM;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAC/C,CAAC;AACF,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,cAAc,KAAG,MAwBnD,CAAC"}
|
|
1
|
+
{"version":3,"file":"randfloat.d.ts","sourceRoot":"","sources":["../../../../src/math/utils/random/randfloat.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,EAAE,MAAM;IACT,CAAC,CAAC,EAAE,MAAM;IACV,OAAO,CAAC,EAAE,MAAM;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAC/C,CAAC;AACF,eAAO,MAAM,SAAS,GAAI,GAAG,MAAM,cAAc,KAAG,MAwBnD,CAAC;AAEF,eAAO,MAAM,sCAAsC,GACjD,IAAG,MAAU,EACb,IAAG,MAAM,GAAG,SAAa,EACzB,UAAS,MAAM,GAAG,SAAa,EAC/B,WAAU,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAc,KAC7D,MAuBF,CAAC"}
|
|
@@ -32,3 +32,38 @@ export const randfloat = (...args) => {
|
|
|
32
32
|
}
|
|
33
33
|
return round(a + Math.random() * (b - a), roundTo);
|
|
34
34
|
};
|
|
35
|
+
export const randfloatFromTruncatedCenteredGaussian = (a = 0, b = 1, roundTo = 2, excludes = []) => {
|
|
36
|
+
function createRandomValue() {
|
|
37
|
+
const raw = a + (b - a) * randfloatBoxMuller();
|
|
38
|
+
return round(raw, roundTo);
|
|
39
|
+
}
|
|
40
|
+
function isValidValue(value) {
|
|
41
|
+
if (Array.isArray(excludes)) {
|
|
42
|
+
return !excludes.includes(value);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return excludes(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
let counter = -1;
|
|
49
|
+
while (counter < 100) {
|
|
50
|
+
counter++;
|
|
51
|
+
const value = createRandomValue();
|
|
52
|
+
if (isValidValue(value)) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error("randfloat too many iterations");
|
|
57
|
+
};
|
|
58
|
+
function randfloatBoxMuller() {
|
|
59
|
+
let u = 0, v = 0;
|
|
60
|
+
while (u === 0)
|
|
61
|
+
u = Math.random(); //Converting [0,1) to (0,1)
|
|
62
|
+
while (v === 0)
|
|
63
|
+
v = Math.random();
|
|
64
|
+
let num = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
|
|
65
|
+
num = num / 10.0 + 0.5; // Translate to 0 -> 1
|
|
66
|
+
if (num > 1 || num < 0)
|
|
67
|
+
return randfloatBoxMuller(); // resample between 0 and 1
|
|
68
|
+
return num;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpose.d.ts","sourceRoot":"","sources":["../../../src/utils/arrays/transpose.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAS/C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const transpose = (array) => {
|
|
2
|
+
const transposedArray = [];
|
|
3
|
+
for (let i = 0; i < array[0].length; i++) {
|
|
4
|
+
transposedArray.push([]);
|
|
5
|
+
for (let j = 0; j < array.length; j++) {
|
|
6
|
+
transposedArray[i].push(array[j][i]);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return transposedArray;
|
|
10
|
+
};
|