math-exercises 3.0.81 → 3.0.82
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isNumberDecimal.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/isNumberDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"isNumberDecimal.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/calcul/arithmetics/isNumberDecimal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAY7C,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE;QACP,CAAC,EAAE,eAAe,CAAC;QACnB,SAAS,EAAE,OAAO,CAAC;KACpB,EAAE,CAAC;CACL,CAAC;AAmIF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAmBjD,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { PiNode } from "../../../../tree/nodes/numbers/piNode.js";
|
|
|
8
8
|
import { isFractionNode, } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
9
9
|
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
10
10
|
import { random } from "../../../../utils/alea/random.js";
|
|
11
|
+
import { doWhile } from "../../../../utils/doWhile.js";
|
|
11
12
|
import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
|
|
12
13
|
const getPropositions = (n, { answer, options }) => {
|
|
13
14
|
const propositions = [];
|
|
@@ -75,15 +76,15 @@ const isAnswerValid = (ans, { answer }) => {
|
|
|
75
76
|
};
|
|
76
77
|
const generateNonDecimalNumber = () => {
|
|
77
78
|
const nonDecimals = [];
|
|
78
|
-
nonDecimals.push(RationalConstructor.randomPureRational().toTree()
|
|
79
|
-
nonDecimals.push(PiNode
|
|
79
|
+
nonDecimals.push(RationalConstructor.randomPureRational().toTree());
|
|
80
|
+
nonDecimals.push(PiNode);
|
|
80
81
|
return random(nonDecimals);
|
|
81
82
|
};
|
|
82
83
|
const generateDecimalNumber = () => {
|
|
83
84
|
const decimals = [];
|
|
84
|
-
decimals.push(randint(0, 100).toTree()
|
|
85
|
-
decimals.push(randfloat(0, 100, 2).toTree()
|
|
86
|
-
decimals.push(RationalConstructor.randomDecimal().toTree()
|
|
85
|
+
decimals.push(randint(0, 100).toTree());
|
|
86
|
+
decimals.push(randfloat(0, 100, 2).toTree());
|
|
87
|
+
decimals.push(RationalConstructor.randomDecimal().toTree());
|
|
87
88
|
return random(decimals);
|
|
88
89
|
};
|
|
89
90
|
const getIsNumberdecimalQuestion = (ops) => {
|
|
@@ -94,12 +95,17 @@ const getIsNumberdecimalQuestion = (ops) => {
|
|
|
94
95
|
choices.push({ a: nonDecimal, isDecimal: false });
|
|
95
96
|
for (let i = 0; i < 2; i++) {
|
|
96
97
|
const isDecimal = coinFlip();
|
|
97
|
-
const randomNumber = isDecimal
|
|
98
|
-
? generateDecimalNumber()
|
|
99
|
-
: generateNonDecimalNumber();
|
|
98
|
+
const randomNumber = doWhile(() => (isDecimal ? generateDecimalNumber() : generateNonDecimalNumber()), (a) => choices.some((c) => c.a.toTex() === a.toTex()));
|
|
100
99
|
choices.push({ a: randomNumber, isDecimal });
|
|
101
100
|
}
|
|
102
|
-
const identifiers = {
|
|
101
|
+
const identifiers = {
|
|
102
|
+
options: choices.map((c) => {
|
|
103
|
+
return {
|
|
104
|
+
a: c.a.toIdentifiers(),
|
|
105
|
+
isDecimal: c.isDecimal,
|
|
106
|
+
};
|
|
107
|
+
}),
|
|
108
|
+
};
|
|
103
109
|
return getQuestionFromIdentifiers(identifiers);
|
|
104
110
|
};
|
|
105
111
|
const getQuestionFromIdentifiers = (identifiers) => {
|