math-exercises 2.2.26 → 2.2.27
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/index.js +1 -0
- package/lib/exercises/math/calcul/rounding/rounding.d.ts.map +1 -1
- package/lib/exercises/math/calcul/rounding/rounding.js +4 -5
- package/lib/exercises/math/calcul/writing/index.d.ts +2 -0
- package/lib/exercises/math/calcul/writing/index.d.ts.map +1 -0
- package/lib/exercises/math/calcul/writing/index.js +17 -0
- package/lib/exercises/math/calcul/writing/numberToFrenchWriting.d.ts +7 -0
- package/lib/exercises/math/calcul/writing/numberToFrenchWriting.d.ts.map +1 -0
- package/lib/exercises/math/calcul/writing/numberToFrenchWriting.js +67 -0
- package/lib/exercises/math/geometry/cartesian/readAbscissOnLine.d.ts +1 -0
- package/lib/exercises/math/geometry/cartesian/readAbscissOnLine.d.ts.map +1 -0
- package/lib/exercises/math/geometry/cartesian/readAbscissOnLine.js +92 -0
- package/lib/exercises/math/percent/percentToDecimal.d.ts.map +1 -1
- package/lib/exercises/math/percent/percentToDecimal.js +69 -26
- package/lib/math/numbers/decimals/decimal.d.ts +1 -0
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +10 -0
- package/lib/math/numbers/integer/integer.d.ts +2 -0
- package/lib/math/numbers/integer/integer.d.ts.map +1 -1
- package/lib/math/numbers/integer/integer.js +9 -0
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +31 -10
- package/lib/utils/strings/frenchNumbers.d.ts +6 -0
- package/lib/utils/strings/frenchNumbers.d.ts.map +1 -0
- package/lib/utils/strings/frenchNumbers.js +50 -0
- package/lib/utils/strings/numberToFrenchWord.d.ts +2 -0
- package/lib/utils/strings/numberToFrenchWord.d.ts.map +1 -0
- package/lib/utils/strings/numberToFrenchWord.js +81 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rounding.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/rounding/rounding.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"rounding.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/rounding/rounding.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AA8ElC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAgDF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,WAAW,CAe7C,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAehD,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAejD,CAAC;AACF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAejD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAkB9C,CAAC"}
|
|
@@ -6,6 +6,7 @@ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQ
|
|
|
6
6
|
const decimal_1 = require("../../../../math/numbers/decimals/decimal");
|
|
7
7
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
8
8
|
const round_1 = require("../../../../math/utils/round");
|
|
9
|
+
const numberParser_1 = require("../../../../tree/parsers/numberParser");
|
|
9
10
|
const shuffle_1 = require("../../../../utils/shuffle");
|
|
10
11
|
/**
|
|
11
12
|
* arrondi à l'unité
|
|
@@ -19,6 +20,7 @@ const instructions = [
|
|
|
19
20
|
"Arrondir au millième :",
|
|
20
21
|
];
|
|
21
22
|
const getRoundQuestions = (opts) => {
|
|
23
|
+
244.8895;
|
|
22
24
|
const precisionAsked = opts?.precisionAsked || 0;
|
|
23
25
|
const precision = (0, randint_1.randint)(precisionAsked + 1, precisionAsked + 5);
|
|
24
26
|
const dec = decimal_1.DecimalConstructor.random(0, 1000, precision);
|
|
@@ -76,11 +78,8 @@ const getPropositions = (n, { answer, precisionAsked, decimal, precision }) => {
|
|
|
76
78
|
}
|
|
77
79
|
return (0, shuffle_1.shuffle)(propositions);
|
|
78
80
|
};
|
|
79
|
-
const isAnswerValid = (ans, { decimal, precisionAsked }) => {
|
|
80
|
-
|
|
81
|
-
const answer = dec.round(precisionAsked).toTree();
|
|
82
|
-
const texs = answer.toAllValidTexs();
|
|
83
|
-
return texs.includes(ans);
|
|
81
|
+
const isAnswerValid = (ans, { answer, decimal, precisionAsked }) => {
|
|
82
|
+
return (0, numberParser_1.numberParser)(ans) === answer;
|
|
84
83
|
};
|
|
85
84
|
exports.roundToUnit = {
|
|
86
85
|
id: "roundToUnit",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/writing/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./numberToFrenchWriting"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberToFrenchWriting.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/writing/numberToFrenchWriting.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,0BAA0B,CAAC;AAOlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAqDF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAgBvD,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.numberToFrenchWriting = void 0;
|
|
4
|
+
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const integer_1 = require("../../../../math/numbers/integer/integer");
|
|
7
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
8
|
+
const toSeparatedThousands_1 = require("../../../../utils/numberPrototype/toSeparatedThousands");
|
|
9
|
+
const numberToFrenchWord_1 = require("../../../../utils/strings/numberToFrenchWord");
|
|
10
|
+
const getPropositions = (n, { answer }) => {
|
|
11
|
+
const propositions = [];
|
|
12
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
13
|
+
while (propositions.length < n) {
|
|
14
|
+
throw Error("QCM not implemented");
|
|
15
|
+
}
|
|
16
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
17
|
+
};
|
|
18
|
+
const getAnswer = (identifiers) => {
|
|
19
|
+
return (0, numberToFrenchWord_1.numberToFrenchWord)(identifiers.nb);
|
|
20
|
+
};
|
|
21
|
+
const getInstruction = (identifiers) => {
|
|
22
|
+
return `Écrire le nombre $${(0, toSeparatedThousands_1.toSeperatedThousands)(identifiers.nb + "")}$ en lettres.`;
|
|
23
|
+
};
|
|
24
|
+
const getHint = (identifiers) => {
|
|
25
|
+
return ``;
|
|
26
|
+
};
|
|
27
|
+
const getCorrection = (identifiers) => {
|
|
28
|
+
return ``;
|
|
29
|
+
};
|
|
30
|
+
const getKeys = (identifiers) => {
|
|
31
|
+
return [];
|
|
32
|
+
};
|
|
33
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
34
|
+
return ans === answer;
|
|
35
|
+
};
|
|
36
|
+
const getNumberToFrenchWritingQuestion = () => {
|
|
37
|
+
const nb = integer_1.IntegerConstructor.random((0, randint_1.randint)(2, 8));
|
|
38
|
+
const identifiers = {
|
|
39
|
+
nb,
|
|
40
|
+
};
|
|
41
|
+
const question = {
|
|
42
|
+
answer: getAnswer(identifiers),
|
|
43
|
+
instruction: getInstruction(identifiers),
|
|
44
|
+
keys: getKeys(identifiers),
|
|
45
|
+
answerFormat: "raw",
|
|
46
|
+
identifiers,
|
|
47
|
+
hint: getHint(identifiers),
|
|
48
|
+
correction: getCorrection(identifiers),
|
|
49
|
+
};
|
|
50
|
+
return question;
|
|
51
|
+
};
|
|
52
|
+
exports.numberToFrenchWriting = {
|
|
53
|
+
id: "numberToFrenchWriting",
|
|
54
|
+
connector: "=",
|
|
55
|
+
label: "Écrire un nombre entier en lettres",
|
|
56
|
+
isSingleStep: true,
|
|
57
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getNumberToFrenchWritingQuestion, nb),
|
|
58
|
+
qcmTimer: 60,
|
|
59
|
+
freeTimer: 60,
|
|
60
|
+
ggbTimer: 60,
|
|
61
|
+
getPropositions,
|
|
62
|
+
isAnswerValid,
|
|
63
|
+
subject: "Mathématiques",
|
|
64
|
+
getHint,
|
|
65
|
+
getCorrection,
|
|
66
|
+
getAnswer,
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=readAbscissOnLine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readAbscissOnLine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/readAbscissOnLine.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import {
|
|
3
|
+
// Exercise,
|
|
4
|
+
// Proposition,
|
|
5
|
+
// QCMGenerator,
|
|
6
|
+
// Question,
|
|
7
|
+
// QuestionGenerator,
|
|
8
|
+
// VEA,
|
|
9
|
+
// GGBVEA,
|
|
10
|
+
// addValidProp,
|
|
11
|
+
// shuffleProps,
|
|
12
|
+
// tryToAddWrongProp,
|
|
13
|
+
// GetAnswer,
|
|
14
|
+
// GetHint,
|
|
15
|
+
// GetCorrection,
|
|
16
|
+
// GetInstruction,
|
|
17
|
+
// GetKeys,
|
|
18
|
+
// GetGGBOptions,
|
|
19
|
+
// GetStudentGGBOptions,
|
|
20
|
+
// GetGGBAnswer,
|
|
21
|
+
// } from "../../../../exercises/exercise";
|
|
22
|
+
// import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions";
|
|
23
|
+
// type Identifiers = {
|
|
24
|
+
// axisUnit: number; //for ggb
|
|
25
|
+
// oneUnitTex: string;
|
|
26
|
+
// absciss: number | [number, number];
|
|
27
|
+
// };
|
|
28
|
+
// const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
|
|
29
|
+
// const propositions: Proposition[] = [];
|
|
30
|
+
// addValidProp(propositions, answer);
|
|
31
|
+
// while (propositions.length < n) {
|
|
32
|
+
// throw Error("QCM not implemented");
|
|
33
|
+
// }
|
|
34
|
+
// return shuffleProps(propositions, n);
|
|
35
|
+
// };
|
|
36
|
+
// const getAnswer: GetAnswer<Identifiers> = (identifiers) => {};
|
|
37
|
+
// const getInstruction: GetInstruction<Identifiers> = (identifiers) => {};
|
|
38
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
39
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
40
|
+
// const getGGBAnswer: GetGGBAnswer<Identifiers> = (identifiers) => {};
|
|
41
|
+
// const getGGBOptions: GetGGBOptions<Identifiers> = (identifiers) => {};
|
|
42
|
+
// const getStudentGGBOptions: GetStudentGGBOptions<Identifiers> = (
|
|
43
|
+
// identifiers,
|
|
44
|
+
// ) => {};
|
|
45
|
+
// const getKeys: GetKeys<Identifiers> = (identifiers) => {
|
|
46
|
+
// return [];
|
|
47
|
+
// };
|
|
48
|
+
// const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {
|
|
49
|
+
// throw Error("VEA not implemented");
|
|
50
|
+
// };
|
|
51
|
+
// const isGGBAnswerValid: GGBVEA<Identifiers> = (ans, { ggbAnswer }) => {
|
|
52
|
+
// throw Error("GGBVea not implemented");
|
|
53
|
+
// };
|
|
54
|
+
// const getReadAbscissOnLineQuestion: QuestionGenerator<Identifiers> = () => {
|
|
55
|
+
// const identifiers: Identifiers = {
|
|
56
|
+
// absciss,
|
|
57
|
+
// axisUnit,
|
|
58
|
+
// oneUnitTex,
|
|
59
|
+
// };
|
|
60
|
+
// const question: Question<Identifiers> = {
|
|
61
|
+
// answer: getAnswer(identifiers),
|
|
62
|
+
// instruction: getInstruction(identifiers),
|
|
63
|
+
// keys: getKeys(identifiers),
|
|
64
|
+
// answerFormat: "tex",
|
|
65
|
+
// identifiers,
|
|
66
|
+
// hint: getHint(identifiers),
|
|
67
|
+
// correction: getCorrection(identifiers),
|
|
68
|
+
// };
|
|
69
|
+
// return question;
|
|
70
|
+
// };
|
|
71
|
+
// export const readAbscissOnLine: Exercise<Identifiers> = {
|
|
72
|
+
// id: "readAbscissOnLine",
|
|
73
|
+
// connector: "=",
|
|
74
|
+
// label: "",
|
|
75
|
+
// isSingleStep: true,
|
|
76
|
+
// generator: (nb: number) =>
|
|
77
|
+
// getDistinctQuestions(getReadAbscissOnLineQuestion, nb),
|
|
78
|
+
// qcmTimer: 60,
|
|
79
|
+
// freeTimer: 60,
|
|
80
|
+
// ggbTimer: 60,
|
|
81
|
+
// getPropositions,
|
|
82
|
+
// isAnswerValid,
|
|
83
|
+
// isGGBAnswerValid,
|
|
84
|
+
// subject: "Mathématiques",
|
|
85
|
+
// getHint,
|
|
86
|
+
// getCorrection,
|
|
87
|
+
// getAnswer,
|
|
88
|
+
// getGGBAnswer,
|
|
89
|
+
// getGGBOptions,
|
|
90
|
+
// getStudentGGBOptions,
|
|
91
|
+
// rebuildIdentifiers,
|
|
92
|
+
// };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"percentToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/percentToDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"percentToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/percent/percentToDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAgBlC,KAAK,WAAW,GAAG;IACjB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAuIF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAelD,CAAC"}
|
|
@@ -4,36 +4,76 @@ exports.percentToDecimal = void 0;
|
|
|
4
4
|
const exercise_1 = require("../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
6
|
const decimal_1 = require("../../../math/numbers/decimals/decimal");
|
|
7
|
+
const integer_1 = require("../../../math/numbers/integer/integer");
|
|
7
8
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
9
|
+
const round_1 = require("../../../math/utils/round");
|
|
10
|
+
const numberParser_1 = require("../../../tree/parsers/numberParser");
|
|
8
11
|
const coinFlip_1 = require("../../../utils/coinFlip");
|
|
12
|
+
const probaFlip_1 = require("../../../utils/probaFlip");
|
|
13
|
+
const getAnswer = ({ nb, isPercentToDecimal }) => {
|
|
14
|
+
const dec = new decimal_1.Decimal(nb);
|
|
15
|
+
const tex = dec.toTree().toTex();
|
|
16
|
+
const percentTex = dec.toPercentNode().toTex();
|
|
17
|
+
return isPercentToDecimal ? tex : percentTex;
|
|
18
|
+
};
|
|
19
|
+
const getInstruction = ({ isPercentToDecimal, nb, }) => {
|
|
20
|
+
const dec = new decimal_1.Decimal(nb);
|
|
21
|
+
const tex = dec.toTree().toTex();
|
|
22
|
+
const percentTex = dec.toPercentNode().toTex();
|
|
23
|
+
const instru = isPercentToDecimal ? percentTex : tex;
|
|
24
|
+
return `Ecrire le nombre suivant ${isPercentToDecimal
|
|
25
|
+
? "sous forme de nombre décimal"
|
|
26
|
+
: "sous forme de pourcentage"} : $${instru}$`;
|
|
27
|
+
};
|
|
28
|
+
const getHint = ({ isPercentToDecimal }) => {
|
|
29
|
+
return `${isPercentToDecimal
|
|
30
|
+
? `Pour écrire $x\\%$ en décimal, rappelle toi que $x\\% = \\frac{x}{100}$.`
|
|
31
|
+
: `Pour écrire un nombre $x$ en pourcentage, on multiplie $x$ par $100$.`}`;
|
|
32
|
+
};
|
|
33
|
+
const getCorrection = ({ isPercentToDecimal, nb, }) => {
|
|
34
|
+
const answer = getAnswer({ isPercentToDecimal, nb });
|
|
35
|
+
const nbPercent = (0, round_1.round)(nb * 100, 10).frenchify();
|
|
36
|
+
return `${isPercentToDecimal
|
|
37
|
+
? `Le symbole $\\%$ signifie simplement "divisé par $100$".
|
|
38
|
+
|
|
39
|
+
On a donc $${nbPercent}\\% = \\frac{${nbPercent}}{100} = ${answer}$
|
|
40
|
+
`
|
|
41
|
+
: `Pour écrire un nombre sous la forme d'un pourcentage, il suffit de le multiplier par $100$.
|
|
42
|
+
|
|
43
|
+
On a donc $${nb.frenchify()} = ${answer}$.
|
|
44
|
+
|
|
45
|
+
En effet, on a bien $${answer} = \\frac{${answer.replace("\\%", "")}}{100} = ${nb.frenchify()}$.`}`;
|
|
46
|
+
};
|
|
47
|
+
const getKeys = (identifiers) => {
|
|
48
|
+
return ["percent"];
|
|
49
|
+
};
|
|
9
50
|
const getPercentToDecimalQuestion = () => {
|
|
10
51
|
const isPercentToDecimal = (0, coinFlip_1.coinFlip)();
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
52
|
+
const isNatural = (0, coinFlip_1.coinFlip)();
|
|
53
|
+
const percentNb = (0, probaFlip_1.probaFlip)(0.3)
|
|
54
|
+
? isNatural
|
|
55
|
+
? new integer_1.Integer(integer_1.IntegerConstructor.random(1, [0]))
|
|
56
|
+
: decimal_1.DecimalConstructor.random(0, 10)
|
|
57
|
+
: (0, coinFlip_1.coinFlip)()
|
|
58
|
+
? isNatural
|
|
59
|
+
? new integer_1.Integer(integer_1.IntegerConstructor.random(2))
|
|
60
|
+
: decimal_1.DecimalConstructor.random(10, 100)
|
|
61
|
+
: isNatural
|
|
62
|
+
? new integer_1.Integer(integer_1.IntegerConstructor.random(3))
|
|
63
|
+
: decimal_1.DecimalConstructor.random(100, 200);
|
|
64
|
+
const nb = percentNb.times(0.01);
|
|
65
|
+
const identifiers = {
|
|
66
|
+
isPercentToDecimal,
|
|
67
|
+
nb: nb.value,
|
|
68
|
+
};
|
|
16
69
|
const question = {
|
|
17
|
-
answer,
|
|
18
|
-
instruction:
|
|
19
|
-
|
|
20
|
-
: "sous forme de pourcentage"} : $${instru}$`,
|
|
21
|
-
keys: ["percent"],
|
|
70
|
+
answer: getAnswer(identifiers),
|
|
71
|
+
instruction: getInstruction(identifiers),
|
|
72
|
+
keys: getKeys(identifiers),
|
|
22
73
|
answerFormat: "tex",
|
|
23
|
-
identifiers
|
|
24
|
-
hint:
|
|
25
|
-
|
|
26
|
-
: `Pour écrire un nombre $x$ en pourcentage, on multiplie $x$ par $100$.`}`,
|
|
27
|
-
correction: `${isPercentToDecimal
|
|
28
|
-
? `Le symbole $\\%$ signifie simplement "divisé par $100$".
|
|
29
|
-
|
|
30
|
-
On a donc $${(nb.value * 100).frenchify()}\\% = \\frac{${(nb.value * 100).frenchify()}}{100} = ${answer}$
|
|
31
|
-
`
|
|
32
|
-
: `Pour écrire un nombre sous la forme d'un pourcentage, il suffit de le multiplier par $100$.
|
|
33
|
-
|
|
34
|
-
On a donc $${nb.value.frenchify()} = ${answer}$.
|
|
35
|
-
|
|
36
|
-
En effet, on a bien $${answer} = \\frac{${answer.replace("\\%", "")}}{100} = ${nb.value.frenchify()}$.`}`,
|
|
74
|
+
identifiers,
|
|
75
|
+
hint: getHint(identifiers),
|
|
76
|
+
correction: getCorrection(identifiers),
|
|
37
77
|
};
|
|
38
78
|
return question;
|
|
39
79
|
};
|
|
@@ -63,8 +103,11 @@ const isAnswerValid = (ans, { answer, isPercentToDecimal, nb }) => {
|
|
|
63
103
|
return ans === answer;
|
|
64
104
|
}
|
|
65
105
|
else {
|
|
66
|
-
const
|
|
67
|
-
|
|
106
|
+
const rawAns = ans.replace("\\%", "");
|
|
107
|
+
const parsed = (0, numberParser_1.numberParser)(rawAns);
|
|
108
|
+
if (!parsed)
|
|
109
|
+
return false;
|
|
110
|
+
return parsed + "\\%" === answer;
|
|
68
111
|
}
|
|
69
112
|
};
|
|
70
113
|
exports.percentToDecimal = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAAyC,CAAC;AACxE,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAY1E,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAK/D,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;CAMrD;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,aAAsB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;gBACR,KAAK,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"decimal.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/decimals/decimal.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,UAAyC,CAAC;AACxE,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;IAY1E,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;IAMpE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAK/D,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;CAMrD;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,aAAsB;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;gBACR,KAAK,EAAE,MAAM,GAAG,MAAM;IAQlC,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IASxB,MAAM,CAAC,CAAC,EAAE,MAAM;IAIhB;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIhC,oBAAoB,CAAC,KAAK,EAAE,MAAM;IAkClC,gBAAgB;IA6BhB,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM;IAwCtC,cAAc,CAAC,IAAI,EAAE,MAAM;IAS3B,UAAU;IAMV,MAAM;IAIN,aAAa;IAIb,YAAY,CAAC,UAAU,EAAE,MAAM;IAS/B,YAAY,CAAC,UAAU,EAAE,MAAM;CAShC"}
|
|
@@ -54,6 +54,16 @@ class Decimal {
|
|
|
54
54
|
this.decimalPart = decimalPartString || "";
|
|
55
55
|
this.precision = this.decimalPart.length;
|
|
56
56
|
}
|
|
57
|
+
times(n) {
|
|
58
|
+
if (typeof n === "number")
|
|
59
|
+
return new Decimal((0, round_1.round)(this.value * n, 10));
|
|
60
|
+
throw Error("unimplemnented");
|
|
61
|
+
// if (n.type === NumberType.Real) {
|
|
62
|
+
// throw Error("decimal times real not implemented");
|
|
63
|
+
// }
|
|
64
|
+
// if (n.type === NumberType.Rational)
|
|
65
|
+
// throw Error("decimal times real not implemented");
|
|
66
|
+
}
|
|
57
67
|
equals(n) {
|
|
58
68
|
return this.value === n.value;
|
|
59
69
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NumberNode } from "../../../tree/nodes/numbers/numberNode";
|
|
2
|
+
import { Decimal } from "../decimals/decimal";
|
|
2
3
|
import { Nombre, NumberType } from "../nombre";
|
|
3
4
|
import { Rational } from "../rationals/rational";
|
|
4
5
|
export declare const integerDigitRanks: string[];
|
|
@@ -14,6 +15,7 @@ export declare class Integer implements Nombre {
|
|
|
14
15
|
constructor(value: number, tex?: string);
|
|
15
16
|
equals(n: Nombre): boolean;
|
|
16
17
|
toTree(): NumberNode;
|
|
18
|
+
times(n: number | Nombre): Integer | Decimal;
|
|
17
19
|
round(precision: number): Integer;
|
|
18
20
|
divide(nb: Nombre): Nombre;
|
|
19
21
|
multiply(nb: Nombre): Rational | Integer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/integer/integer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,eAAO,MAAM,iBAAiB,UAK7B,CAAC;AACF,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE;IAGrD,MAAM,CAAC,WAAW,CAAC,GAAG,GAAE,MAAW;IAGnC,MAAM,CAAC,gBAAgB,CACrB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,MAAM,EACV,QAAQ,CAAC,EAAE,MAAM,EAAE;CAYtB;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;gBAEL,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAMvC,MAAM,CAAC,CAAC,EAAE,MAAM;IAGhB,MAAM;IAIN,KAAK,CAAC,SAAS,EAAE,MAAM;IAkCvB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAc1B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO;IAYxC,QAAQ;IAGR,GAAG,CAAC,EAAE,EAAE,MAAM;CAYf"}
|
|
1
|
+
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../../../src/math/numbers/integer/integer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,eAAO,MAAM,iBAAiB,UAK7B,CAAC;AACF,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE;IAGrD,MAAM,CAAC,WAAW,CAAC,GAAG,GAAE,MAAW;IAGnC,MAAM,CAAC,gBAAgB,CACrB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,MAAM,EACV,QAAQ,CAAC,EAAE,MAAM,EAAE;CAYtB;AAED,qBAAa,OAAQ,YAAW,MAAM;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;gBAEL,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAMvC,MAAM,CAAC,CAAC,EAAE,MAAM;IAGhB,MAAM;IAIN,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAMxB,KAAK,CAAC,SAAS,EAAE,MAAM;IAkCvB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAc1B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO;IAYxC,QAAQ;IAGR,GAAG,CAAC,EAAE,EAAE,MAAM;CAYf"}
|
|
@@ -45,6 +45,15 @@ class Integer {
|
|
|
45
45
|
toTree() {
|
|
46
46
|
return new numberNode_1.NumberNode(this.value, this.tex);
|
|
47
47
|
}
|
|
48
|
+
times(n) {
|
|
49
|
+
if (typeof n === "number")
|
|
50
|
+
return new Integer(this.value * n);
|
|
51
|
+
if (n.type === nombre_1.NumberType.Integer)
|
|
52
|
+
return new Integer(this.value * n.value);
|
|
53
|
+
if (n.type === nombre_1.NumberType.Decimal)
|
|
54
|
+
return n.times(n);
|
|
55
|
+
throw Error("unimplemented");
|
|
56
|
+
}
|
|
48
57
|
round(precision) {
|
|
49
58
|
const intString = this.value + "";
|
|
50
59
|
if (precision >= intString.length || precision < 1)
|
package/lib/playground.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,UAAU,YAmCtB,CAAC"}
|
package/lib/playground.js
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.playground = void 0;
|
|
4
|
+
const numberToFrenchWord_1 = require("./utils/strings/numberToFrenchWord");
|
|
4
5
|
const playground = () => {
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
// for (let i = 0; i < 10000; i++) {
|
|
7
|
+
// console.log(numberToFrenchWord(i));
|
|
8
|
+
// }
|
|
9
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(2));
|
|
10
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(21));
|
|
11
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(71));
|
|
12
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(100));
|
|
13
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(120));
|
|
14
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(281));
|
|
15
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(323));
|
|
16
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(900));
|
|
17
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(999));
|
|
18
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(1000));
|
|
19
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(1100));
|
|
20
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(1323));
|
|
21
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(3000));
|
|
22
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(3242));
|
|
23
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(9999));
|
|
24
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(10000));
|
|
25
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(11000));
|
|
26
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(10001));
|
|
27
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(10100));
|
|
28
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(10010));
|
|
29
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(12345));
|
|
30
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(12234));
|
|
31
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(100000));
|
|
32
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(1001000));
|
|
33
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(1000100));
|
|
34
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(1000000));
|
|
35
|
+
console.log((0, numberToFrenchWord_1.numberToFrenchWord)(9999999));
|
|
15
36
|
};
|
|
16
37
|
exports.playground = playground;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const frenchUnits: string[];
|
|
2
|
+
export declare const frenchTeens: string[];
|
|
3
|
+
export declare const frenchTens: string[];
|
|
4
|
+
export declare const frenchTenPowers: string[];
|
|
5
|
+
export declare const tenthThreePowers: string[];
|
|
6
|
+
//# sourceMappingURL=frenchNumbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frenchNumbers.d.ts","sourceRoot":"","sources":["../../../src/utils/strings/frenchNumbers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAWvB,CAAC;AAEF,eAAO,MAAM,WAAW,UAWvB,CAAC;AAEF,eAAO,MAAM,UAAU,UAUtB,CAAC;AAEF,eAAO,MAAM,eAAe,UAU3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAmC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tenthThreePowers = exports.frenchTenPowers = exports.frenchTens = exports.frenchTeens = exports.frenchUnits = void 0;
|
|
4
|
+
exports.frenchUnits = [
|
|
5
|
+
"zéro",
|
|
6
|
+
"un",
|
|
7
|
+
"deux",
|
|
8
|
+
"trois",
|
|
9
|
+
"quatre",
|
|
10
|
+
"cinq",
|
|
11
|
+
"six",
|
|
12
|
+
"sept",
|
|
13
|
+
"huit",
|
|
14
|
+
"neuf",
|
|
15
|
+
];
|
|
16
|
+
exports.frenchTeens = [
|
|
17
|
+
"dix",
|
|
18
|
+
"onze",
|
|
19
|
+
"douze",
|
|
20
|
+
"treize",
|
|
21
|
+
"quatorze",
|
|
22
|
+
"quinze",
|
|
23
|
+
"seize",
|
|
24
|
+
"dix-sept",
|
|
25
|
+
"dix-huit",
|
|
26
|
+
"dix-neuf",
|
|
27
|
+
];
|
|
28
|
+
exports.frenchTens = [
|
|
29
|
+
"dix",
|
|
30
|
+
"vingt",
|
|
31
|
+
"trente",
|
|
32
|
+
"quarante",
|
|
33
|
+
"cinquante",
|
|
34
|
+
"soixante",
|
|
35
|
+
"soixante-dix",
|
|
36
|
+
"quatre-vingts",
|
|
37
|
+
"quatre-vingt-dix",
|
|
38
|
+
];
|
|
39
|
+
exports.frenchTenPowers = [
|
|
40
|
+
"dix",
|
|
41
|
+
"cent",
|
|
42
|
+
"mille",
|
|
43
|
+
"dix-mille",
|
|
44
|
+
"cent-mille",
|
|
45
|
+
"million",
|
|
46
|
+
"dix-millions",
|
|
47
|
+
"cent-millions",
|
|
48
|
+
"milliard",
|
|
49
|
+
];
|
|
50
|
+
exports.tenthThreePowers = ["mille", "million", "milliard"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberToFrenchWord.d.ts","sourceRoot":"","sources":["../../../src/utils/strings/numberToFrenchWord.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,kBAAkB,WAAY,MAAM,WA0ChD,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.numberToFrenchWord = void 0;
|
|
4
|
+
const frenchNumbers_1 = require("./frenchNumbers");
|
|
5
|
+
const tensToFrench = (number) => {
|
|
6
|
+
if (number < 10)
|
|
7
|
+
return frenchNumbers_1.frenchUnits[number];
|
|
8
|
+
if (number < 20)
|
|
9
|
+
return frenchNumbers_1.frenchTeens[number - 10];
|
|
10
|
+
const tens = Math.floor(number / 10);
|
|
11
|
+
const ones = number % 10;
|
|
12
|
+
const units = tens === 7 || tens === 9 ? frenchNumbers_1.frenchTeens : frenchNumbers_1.frenchUnits;
|
|
13
|
+
let tenString = frenchNumbers_1.frenchTens[tens - 1];
|
|
14
|
+
if (!ones)
|
|
15
|
+
return tenString;
|
|
16
|
+
if (tens === 7 || tens === 9)
|
|
17
|
+
tenString = frenchNumbers_1.frenchTens[tens - 2];
|
|
18
|
+
if (tens === 8 || tens === 9)
|
|
19
|
+
tenString = tenString.replace("s", "");
|
|
20
|
+
if (ones === 1 && tens !== 8 && tens !== 9)
|
|
21
|
+
return tenString + "-et-" + units[ones];
|
|
22
|
+
return tenString + "-" + units[ones];
|
|
23
|
+
};
|
|
24
|
+
const hundredsToFrench = (number) => {
|
|
25
|
+
if (number === 100)
|
|
26
|
+
return "cent";
|
|
27
|
+
const hundreds = Math.floor(number / 100);
|
|
28
|
+
const tens = number % 100;
|
|
29
|
+
if (hundreds === 0)
|
|
30
|
+
return tensToFrench(number);
|
|
31
|
+
if (tens === 0)
|
|
32
|
+
return frenchNumbers_1.frenchUnits[hundreds] + "-cent";
|
|
33
|
+
if (hundreds === 1)
|
|
34
|
+
return "cent-" + tensToFrench(tens);
|
|
35
|
+
return frenchNumbers_1.frenchUnits[hundreds] + "-cent-" + tensToFrench(tens);
|
|
36
|
+
};
|
|
37
|
+
const numberToFrenchWord = (number) => {
|
|
38
|
+
// return hundredsToFrench(number);
|
|
39
|
+
if (Math.floor(number) !== number)
|
|
40
|
+
throw Error("decimal writing to french not implemented");
|
|
41
|
+
const nbStr = number.toString();
|
|
42
|
+
let toHundreds = [];
|
|
43
|
+
let j = 0;
|
|
44
|
+
let currentHundreds = [];
|
|
45
|
+
const length = nbStr.length;
|
|
46
|
+
const partsNumber = Math.floor((length - 1) / 3) + 1;
|
|
47
|
+
for (let i = nbStr.length - 1; i >= 0; i--) {
|
|
48
|
+
if (j === 3) {
|
|
49
|
+
toHundreds.push(Number(currentHundreds.reverse().reduce((a, b) => a + b)));
|
|
50
|
+
currentHundreds = [];
|
|
51
|
+
j = 0;
|
|
52
|
+
}
|
|
53
|
+
j++;
|
|
54
|
+
currentHundreds.push(nbStr[i]);
|
|
55
|
+
}
|
|
56
|
+
toHundreds.push(Number(currentHundreds.reverse().reduce((a, b) => a + b)));
|
|
57
|
+
// toHundreds.reverse();
|
|
58
|
+
let res = "";
|
|
59
|
+
for (let i = toHundreds.length - 1; i > -1; i--) {
|
|
60
|
+
const tenthPower = i * 3;
|
|
61
|
+
const hundreds = hundredsToFrench(toHundreds[i]);
|
|
62
|
+
if (i === 0) {
|
|
63
|
+
if (res?.length && hundreds !== "zéro")
|
|
64
|
+
res += "-" + hundreds;
|
|
65
|
+
if (!res?.length)
|
|
66
|
+
res += hundreds;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (hundreds === "zéro")
|
|
70
|
+
continue;
|
|
71
|
+
const thousandWord = frenchNumbers_1.tenthThreePowers[i - 1];
|
|
72
|
+
if (hundreds === "un" && tenthPower === 3) {
|
|
73
|
+
res += (res ? "-" : "") + "mille";
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
res += (res ? "-" : "") + hundreds + "-" + thousandWord;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return res;
|
|
80
|
+
};
|
|
81
|
+
exports.numberToFrenchWord = numberToFrenchWord;
|