math-exercises 1.3.68 → 1.3.70

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.
@@ -58,7 +58,7 @@ function getEuclideanDivisionQuestions() {
58
58
  } while (isDuplicate);
59
59
  res.push(proposition);
60
60
  }
61
- return (0, shuffle_1.shuffle)(res).slice(0, n);
61
+ return (0, shuffle_1.shuffle)([res[0], ...res.slice(1, n - 1)]);
62
62
  };
63
63
  const question = {
64
64
  instruction: `Ecrire la division euclidienne de ${dividend} par ${divisor}`,
@@ -1 +1 @@
1
- {"version":3,"file":"primeNumbers.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/arithmetics/primeNumbers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGjE;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,QAY1B,CAAC;AAQF,wBAAgB,eAAe,IAAI,QAAQ,CA4E1C"}
1
+ {"version":3,"file":"primeNumbers.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calcul/arithmetics/primeNumbers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAe,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGjE;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,QAY1B,CAAC;AAQF,wBAAgB,eAAe,IAAI,QAAQ,CA2E1C"}
@@ -78,7 +78,7 @@ function getPrimeNumbers() {
78
78
  format: 'tex',
79
79
  });
80
80
  }
81
- return (0, shuffle_1.shuffle)(res).slice(0, n);
81
+ return (0, shuffle_1.shuffle)([res[0], ...res.slice(1, n - 1)]);
82
82
  };
83
83
  const question = {
84
84
  startStatement: `${prod}`,
@@ -62,7 +62,7 @@ function getFractionAndIntegerDivision() {
62
62
  } while (isDuplicate);
63
63
  res.push(proposition);
64
64
  }
65
- return (0, shuffle_1.shuffle)(res).slice(0, n);
65
+ return (0, shuffle_1.shuffle)([res[0], ...res.slice(1, n - 1)]);
66
66
  };
67
67
  const question = {
68
68
  instruction: '',
@@ -42,7 +42,7 @@ function getExpDerivativeThree() {
42
42
  (0, exercise_1.tryToAddWrongProp)(propositions, new multiplyNode_1.MultiplyNode(new polynomial_1.Polynomial([b + a, -a]).toTree(), new expNode_1.ExpNode(new variableNode_1.VariableNode('x'))).toTex());
43
43
  (0, exercise_1.tryToAddWrongProp)(propositions, a + '');
44
44
  (0, exercise_1.tryToAddWrongProp)(propositions, (0, simplify_1.simplifyNode)(new multiplyNode_1.MultiplyNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new variableNode_1.VariableNode('x')), new expNode_1.ExpNode(new variableNode_1.VariableNode('x')))).toTex());
45
- return (0, shuffle_1.shuffle)(propositions).slice(0, numOptions);
45
+ return (0, shuffle_1.shuffle)([propositions[0], ...propositions.slice(1, numOptions - 1)]);
46
46
  };
47
47
  const question = {
48
48
  instruction: `Déterminer la dérivée de la fonction $f(x) = ${myfunction.toTex()}$.`,
@@ -56,7 +56,7 @@ function getExpDerivative() {
56
56
  } while (isDuplicate);
57
57
  propositions.push(proposition);
58
58
  }
59
- return (0, shuffle_1.shuffle)(propositions).slice(0, numOptions);
59
+ return (0, shuffle_1.shuffle)([propositions[0], ...propositions.slice(1, numOptions - 1)]);
60
60
  };
61
61
  const question = {
62
62
  instruction: `Déterminer la dérivée de la fonction $f(x) = ${myfunction.toTex()}$.`,
@@ -50,7 +50,7 @@ function getFirstDegreeDerivative() {
50
50
  } while (isDuplicate);
51
51
  propositions.push(proposition);
52
52
  }
53
- return (0, shuffle_1.shuffle)(propositions).slice(0, n);
53
+ return (0, shuffle_1.shuffle)([propositions[0], ...propositions.slice(1, n - 1)]);
54
54
  };
55
55
  const question = {
56
56
  instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) = ${polynomial.toString()}$.`,
@@ -49,7 +49,7 @@ function getInverseFunctionDerivative() {
49
49
  } while (isDuplicate);
50
50
  propositions.push(proposition);
51
51
  }
52
- return (0, shuffle_1.shuffle)(propositions).slice(0, n);
52
+ return (0, shuffle_1.shuffle)([propositions[0], ...propositions.slice(1, n - 1)]);
53
53
  };
54
54
  const question = {
55
55
  instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) =\\frac{${a}}{x}$.`,
@@ -46,7 +46,7 @@ function getLnDerivative() {
46
46
  (0, exercise_1.tryToAddWrongProp)(propositions, polynom.toTree().toTex());
47
47
  (0, exercise_1.tryToAddWrongProp)(propositions, `\\frac{${a}}{${logTree.toTex()}}`);
48
48
  (0, exercise_1.tryToAddWrongProp)(propositions, `\\frac{1}{${polynom.toTree().toTex()}}`);
49
- return (0, shuffle_1.shuffle)(propositions).slice(0, numOptions);
49
+ return (0, shuffle_1.shuffle)([propositions[0], ...propositions.slice(1, numOptions - 1)]);
50
50
  };
51
51
  const question = {
52
52
  instruction: `Déterminer la dérivée de la fonction $f(x) = ${logTree.toTex()}$.`,
@@ -64,7 +64,7 @@ function getLnDerivative() {
64
64
  } while (isDuplicate);
65
65
  propositions.push(proposition);
66
66
  }
67
- return (0, shuffle_1.shuffle)(propositions).slice(0, numOptions);
67
+ return (0, shuffle_1.shuffle)([propositions[0], ...propositions.slice(1, numOptions - 1)]);
68
68
  };
69
69
  const question = {
70
70
  instruction: `Déterminer la dérivée de la fonction $f(x) = ${myfunction.toTex()} $.`,
@@ -40,7 +40,7 @@ function getPowerFunctionDerivative() {
40
40
  (0, exercise_1.tryToAddWrongProp)(propositions, new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), new powerNode_1.PowerNode(new variableNode_1.VariableNode('x'), new numberNode_1.NumberNode(n - 1))).toTex());
41
41
  (0, exercise_1.tryToAddWrongProp)(propositions, new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a * n), new powerNode_1.PowerNode(new variableNode_1.VariableNode('x'), new numberNode_1.NumberNode(n))).toTex());
42
42
  (0, exercise_1.tryToAddWrongProp)(propositions, new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a - 1), new powerNode_1.PowerNode(new variableNode_1.VariableNode('x'), new numberNode_1.NumberNode(n))).toTex());
43
- const missing = n - propositions.length;
43
+ const missing = numOptions - propositions.length;
44
44
  for (let i = 0; i < missing; i++) {
45
45
  let isDuplicate;
46
46
  let proposition;
@@ -56,7 +56,7 @@ function getPowerFunctionDerivative() {
56
56
  } while (isDuplicate);
57
57
  propositions.push(proposition);
58
58
  }
59
- return (0, shuffle_1.shuffle)(propositions).slice(0, n);
59
+ return (0, shuffle_1.shuffle)([propositions[0], ...propositions.slice(1, numOptions - 1)]);
60
60
  };
61
61
  const question = {
62
62
  instruction: `Déterminer la fonction dérivée $f'$ de la fonction $f$ définie par $f(x) =${statement.toTex()}$.`,
@@ -37,7 +37,7 @@ function getSequenceGeometricLimitQuestion() {
37
37
  (0, exercise_1.tryToAddWrongProp)(res, '0');
38
38
  (0, exercise_1.tryToAddWrongProp)(res, sequence.reason.tex + '');
39
39
  (0, exercise_1.tryToAddWrongProp)(res, sequence.firstTerm.tex + '');
40
- return (0, shuffle_1.shuffle)(res).slice(0, n);
40
+ return (0, shuffle_1.shuffle)([res[0], ...res.slice(1, n - 1)]);
41
41
  };
42
42
  const question = {
43
43
  answer: answer,
@@ -1 +1 @@
1
- {"version":3,"file":"geometricSequence.d.ts","sourceRoot":"","sources":["../../../src/math/sequences/geometricSequence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAOvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIvD,8BAAsB,4BAA4B;IAChD,MAAM,CAAC,MAAM,CAAC,UAAU,GAAE,UAA+B;IAkBzD,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU;CAmB/C;AAED,qBAAa,iBAAiB;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;gBAEH,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK7C,QAAQ;IAMR,MAAM;CAGP"}
1
+ {"version":3,"file":"geometricSequence.d.ts","sourceRoot":"","sources":["../../../src/math/sequences/geometricSequence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAOvE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIvD,8BAAsB,4BAA4B;IAChD,MAAM,CAAC,MAAM,CAAC,UAAU,GAAE,UAA+B;IAkBzD,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,UAAU;CAsB/C;AAED,qBAAa,iBAAiB;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;gBAEH,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK7C,QAAQ;IAMR,MAAM;CAGP"}
@@ -35,7 +35,10 @@ class GeometricSequenceConstructor {
35
35
  const type = reasonType ?? (0, random_1.random)([nombre_1.NumberType.Decimal, nombre_1.NumberType.Integer, nombre_1.NumberType.Rational]);
36
36
  switch (type) {
37
37
  case nombre_1.NumberType.Decimal:
38
- reason = (0, coinFlip_1.coinFlip)() ? decimal_1.DecimalConstructor.random(-1, 1) : decimal_1.DecimalConstructor.random(1, 10);
38
+ const precision = (0, randint_1.randint)(1, 4);
39
+ reason = (0, coinFlip_1.coinFlip)()
40
+ ? decimal_1.DecimalConstructor.fromParts((0, coinFlip_1.coinFlip)() ? '0' : '-0', decimal_1.DecimalConstructor.randomFracPart(precision))
41
+ : decimal_1.DecimalConstructor.random(1, 10);
39
42
  break;
40
43
  case nombre_1.NumberType.Integer:
41
44
  reason = new integer_1.Integer((0, randint_1.randint)(2, 10, [0, 1]));
@@ -56,16 +59,16 @@ class GeometricSequence {
56
59
  this.reason = reason;
57
60
  }
58
61
  getLimit() {
59
- if (this.reason.value < -1)
62
+ if (this.reason.value <= -1)
60
63
  return null;
61
- if (this.reason.value === 1 || this.reason.value === -1)
64
+ if (this.reason.value === 1)
62
65
  return this.firstTerm + '';
63
66
  if (this.reason.value > 1)
64
67
  return this.firstTerm.value > 0 ? '+\\infty' : '-\\infty';
65
68
  return '0';
66
69
  }
67
70
  toTree() {
68
- return new multiplyNode_1.MultiplyNode(this.firstTerm.toTree(), new powerNode_1.PowerNode(this.reason.toTree(), new variableNode_1.VariableNode('n')));
71
+ return new multiplyNode_1.MultiplyNode(this.firstTerm.toTree(), new powerNode_1.PowerNode(this.reason.toTree(), new variableNode_1.VariableNode('n')), true);
69
72
  }
70
73
  }
71
74
  exports.GeometricSequence = GeometricSequence;
@@ -1,7 +1,8 @@
1
1
  import { Node } from '../node';
2
2
  import { OperatorNode } from './operatorNode';
3
3
  export declare class MultiplyNode extends OperatorNode implements Node {
4
- constructor(leftChild: Node, rightChild: Node);
4
+ forceTimesSign?: boolean;
5
+ constructor(leftChild: Node, rightChild: Node, forceTimesSign?: boolean);
5
6
  toMathString(): string;
6
7
  toTex(): string;
7
8
  toMathjs(): any;
@@ -1 +1 @@
1
- {"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AACzC,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;gBAChD,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI;IAY7C,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAoCf,QAAQ;CAGT"}
1
+ {"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAY,MAAM,SAAS,CAAC;AACzC,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,YAAa,SAAQ,YAAa,YAAW,IAAI;IAC5D,cAAc,CAAC,EAAE,OAAO,CAAC;gBACb,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO;IAavE,YAAY,IAAI,MAAM;IAItB,KAAK,IAAI,MAAM;IAoCf,QAAQ;CAGT"}
@@ -6,7 +6,7 @@ const functionNode_1 = require("../functions/functionNode");
6
6
  const node_1 = require("../node");
7
7
  const operatorNode_1 = require("./operatorNode");
8
8
  class MultiplyNode extends operatorNode_1.OperatorNode {
9
- constructor(leftChild, rightChild) {
9
+ constructor(leftChild, rightChild, forceTimesSign) {
10
10
  let [left, right] = [leftChild, rightChild];
11
11
  const shouldSwitch = (rightChild.type === node_1.NodeType.function && rightChild.id === functionNode_1.FunctionsIds.opposite) ||
12
12
  (leftChild.type === node_1.NodeType.constant && rightChild.type === node_1.NodeType.number);
@@ -14,6 +14,7 @@ class MultiplyNode extends operatorNode_1.OperatorNode {
14
14
  [left, right] = [rightChild, leftChild];
15
15
  }
16
16
  super(operatorNode_1.OperatorIds.multiply, left, right, true, '\\times');
17
+ this.forceTimesSign = forceTimesSign;
17
18
  }
18
19
  toMathString() {
19
20
  return `(${this.leftChild.toMathString()})*(${this.rightChild.toMathString()})`;
@@ -38,7 +39,7 @@ class MultiplyNode extends operatorNode_1.OperatorNode {
38
39
  if (needBrackets)
39
40
  rightTex = `(${rightTex})`;
40
41
  // permet de gérer le cas 3*2^x par ex
41
- let showTimesSign = !isNaN(+rightTex[0]) || this.rightChild.type === node_1.NodeType.number;
42
+ let showTimesSign = this.forceTimesSign || !isNaN(+rightTex[0]) || this.rightChild.type === node_1.NodeType.number;
42
43
  if (this.rightChild.type === node_1.NodeType.operator) {
43
44
  const operatorRightChild = this.rightChild;
44
45
  showTimesSign ||= [operatorNode_1.OperatorIds.fraction].includes(operatorRightChild.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "1.3.68",
3
+ "version": "1.3.70",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [