math-exercises 3.0.56 → 3.0.57

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.
Files changed (97) hide show
  1. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -1
  2. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +65 -13
  3. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  4. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +43 -0
  5. package/lib/exercises/math/calculLitteral/systems/basicNiceValuesSystemResolution.d.ts.map +1 -1
  6. package/lib/exercises/math/calculLitteral/systems/basicNiceValuesSystemResolution.js +23 -0
  7. package/lib/exercises/math/calculLitteral/systems/basicSystemResolution.d.ts.map +1 -1
  8. package/lib/exercises/math/calculLitteral/systems/basicSystemResolution.js +23 -0
  9. package/lib/exercises/math/calculLitteral/systems/verifySystemSolution.d.ts.map +1 -1
  10. package/lib/exercises/math/calculLitteral/systems/verifySystemSolution.js +49 -0
  11. package/lib/exercises/math/conversion/capacityConversion.d.ts.map +1 -1
  12. package/lib/exercises/math/conversion/capacityConversion.js +68 -12
  13. package/lib/exercises/math/conversion/hoursToDecimal.d.ts.map +1 -1
  14. package/lib/exercises/math/conversion/hoursToDecimal.js +73 -15
  15. package/lib/exercises/math/conversion/lengthConversion.d.ts.map +1 -1
  16. package/lib/exercises/math/conversion/lengthConversion.js +55 -6
  17. package/lib/exercises/math/conversion/massConversion.d.ts.map +1 -1
  18. package/lib/exercises/math/conversion/massConversion.js +72 -16
  19. package/lib/exercises/math/conversion/volumeConversion.d.ts.map +1 -1
  20. package/lib/exercises/math/conversion/volumeConversion.js +72 -12
  21. package/lib/exercises/math/functions/affines/signFunction.d.ts.map +1 -1
  22. package/lib/exercises/math/functions/affines/signFunction.js +23 -11
  23. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.d.ts.map +1 -1
  24. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.js +12 -5
  25. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.d.ts.map +1 -1
  26. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.js +68 -29
  27. package/lib/exercises/math/geometry/lines/cartesianEquationsIntersection.d.ts.map +1 -1
  28. package/lib/exercises/math/geometry/lines/cartesianEquationsIntersection.js +56 -4
  29. package/lib/exercises/math/geometry/lines/drawLineFromCartesianEquation.d.ts.map +1 -1
  30. package/lib/exercises/math/geometry/lines/drawLineFromCartesianEquation.js +71 -25
  31. package/lib/exercises/math/limits/polynomLimit.d.ts +1 -1
  32. package/lib/exercises/math/limits/polynomLimit.d.ts.map +1 -1
  33. package/lib/exercises/math/limits/polynomLimit.js +28 -9
  34. package/lib/exercises/math/limits/polynomLimitNoFI.d.ts +1 -1
  35. package/lib/exercises/math/limits/polynomLimitNoFI.d.ts.map +1 -1
  36. package/lib/exercises/math/limits/polynomLimitNoFI.js +29 -10
  37. package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
  38. package/lib/exercises/math/powers/calculateNegativePower.js +59 -16
  39. package/lib/exercises/math/powers/decimalToScientific.d.ts.map +1 -1
  40. package/lib/exercises/math/powers/decimalToScientific.js +55 -11
  41. package/lib/exercises/math/powers/index.d.ts +1 -0
  42. package/lib/exercises/math/powers/index.d.ts.map +1 -1
  43. package/lib/exercises/math/powers/index.js +1 -0
  44. package/lib/exercises/math/powers/powersDivision.d.ts +5 -2
  45. package/lib/exercises/math/powers/powersDivision.d.ts.map +1 -1
  46. package/lib/exercises/math/powers/powersDivision.js +68 -53
  47. package/lib/exercises/math/powers/powersMixOperations.d.ts +1 -0
  48. package/lib/exercises/math/powers/powersMixOperations.d.ts.map +1 -1
  49. package/lib/exercises/math/powers/powersMixOperations.js +88 -17
  50. package/lib/exercises/math/powers/powersOfTenMixOperations.d.ts +10 -0
  51. package/lib/exercises/math/powers/powersOfTenMixOperations.d.ts.map +1 -0
  52. package/lib/exercises/math/powers/powersOfTenMixOperations.js +129 -0
  53. package/lib/exercises/math/powers/powersOfTenToDecimal.d.ts.map +1 -1
  54. package/lib/exercises/math/powers/powersOfTenToDecimal.js +32 -3
  55. package/lib/exercises/math/powers/powersProduct.d.ts.map +1 -1
  56. package/lib/exercises/math/powers/powersProduct.js +1 -0
  57. package/lib/exercises/math/powers/scientificToDecimal.d.ts.map +1 -1
  58. package/lib/exercises/math/powers/scientificToDecimal.js +50 -10
  59. package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
  60. package/lib/exercises/math/primitive/polynomialPrimitive.js +1 -0
  61. package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.d.ts.map +1 -1
  62. package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.js +40 -2
  63. package/lib/exercises/math/sequences/geometric/geometricFirstTermsSum.d.ts.map +1 -1
  64. package/lib/exercises/math/sequences/geometric/geometricFirstTermsSum.js +32 -0
  65. package/lib/exercises/math/trigonometry/trigonometry.d.ts.map +1 -1
  66. package/lib/exercises/math/trigonometry/trigonometry.js +67 -1
  67. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts.map +1 -1
  68. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.js +89 -0
  69. package/lib/index.d.ts +14 -4
  70. package/lib/index.d.ts.map +1 -1
  71. package/lib/math/geometry/angle.d.ts.map +1 -1
  72. package/lib/math/geometry/angle.js +0 -5
  73. package/lib/math/geometry/vector.d.ts +1 -0
  74. package/lib/math/geometry/vector.d.ts.map +1 -1
  75. package/lib/math/geometry/vector.js +19 -0
  76. package/lib/math/numbers/decimals/decimal.d.ts +1 -0
  77. package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
  78. package/lib/math/numbers/decimals/decimal.js +2 -0
  79. package/lib/math/systems/generalSystem.d.ts +6 -1
  80. package/lib/math/systems/generalSystem.d.ts.map +1 -1
  81. package/lib/math/systems/generalSystem.js +137 -0
  82. package/lib/math/utils/arithmetic/lcm.js +1 -1
  83. package/lib/playground.d.ts.map +1 -1
  84. package/lib/playground.js +1 -36
  85. package/lib/tree/nodes/algebraicNode.d.ts +1 -0
  86. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  87. package/lib/tree/nodes/equations/equalNode.d.ts +7 -1
  88. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  89. package/lib/tree/nodes/equations/equalNode.js +17 -9
  90. package/lib/tree/nodes/operators/addNode.js +1 -1
  91. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  92. package/lib/tree/nodes/operators/fractionNode.js +31 -11
  93. package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
  94. package/lib/tree/nodes/operators/powerNode.js +5 -0
  95. package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
  96. package/lib/tree/nodes/sets/intervalNode.js +3 -1
  97. package/package.json +1 -1
@@ -5,62 +5,90 @@ import { Power } from "../../../math/numbers/integer/power.js";
5
5
  import { randint } from "../../../math/utils/random/randint.js";
6
6
  import { frac } from "../../../tree/nodes/operators/fractionNode.js";
7
7
  import { power } from "../../../tree/nodes/operators/powerNode.js";
8
- import { SubstractNode } from "../../../tree/nodes/operators/substractNode.js";
8
+ import { substract, } from "../../../tree/nodes/operators/substractNode.js";
9
9
  import { alignTex } from "../../../utils/latex/alignTex.js";
10
10
  import { shuffle } from "../../../utils/alea/shuffle.js";
11
11
  import { addValidProp, tryToAddWrongProp, } from "../../exercise.js";
12
12
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions.js";
13
13
  import { rationalParser } from "../../../tree/parsers/rationalParser.js";
14
14
  import { powerParser } from "../../../tree/parsers/powerParser.js";
15
- const getPowersDivisionQuestion = (opts) => {
16
- let a = opts.useOnlyPowersOfTen ? 10 : randint(-11, 11, [0]);
17
- const [b, c] = [1, 2].map((el) => randint(-11, 11));
18
- const statement = frac(power(a, b), power(a, c));
19
- const answerTree = power(a, b - c).simplify();
20
- const answer = answerTree.toTex();
21
- const statementTex = statement.toTex();
22
- const question = {
23
- instruction: `Simplifier :
15
+ const getInstruction = (identifiers) => {
16
+ return `Simplifier :
24
17
 
25
18
  $$
26
- ${statementTex}
27
- $$`,
28
- startStatement: statementTex,
29
- answer,
30
- keys: [],
31
- hint: `${opts?.useOnlyPowersOfTen
32
- ? `Pour diviser deux puissances de $10$, on utilise la propriété :
19
+ ${getStartStatement(identifiers)}
20
+ $$`;
21
+ };
22
+ const getAnswer = (identifiers) => {
23
+ const { a, b, c } = identifiers;
24
+ const answerTree = power(a, b - c).simplify();
25
+ const answer = answerTree.toTex();
26
+ return answer;
27
+ };
28
+ const getHint = (identifiers, opts) => {
29
+ return `${opts?.useOnlyPowersOfTen
30
+ ? `Pour diviser deux puissances de $10$, on utilise la propriété :
33
31
 
34
32
  $\\frac{10^a}{10^b} = 10^{a-b}$`
35
- : `Pour diviser deux puissances d'un même nombre $x$, on utilise la propriété :
33
+ : `Pour diviser deux puissances d'un même nombre $x$, on utilise la propriété :
34
+
35
+ $\\frac{x^a}{x^b} = x^{a-b}$`}`;
36
+ };
37
+ const getCorrection = (identifiers, opts) => {
38
+ const statementTex = getStartStatement(identifiers);
39
+ const answer = getAnswer(identifiers);
40
+ const { a, b, c } = identifiers;
41
+ if (opts?.useOnlyPowersOfTen) {
42
+ return `On utilise la propriété :
43
+
44
+ $$
45
+ \\frac{10^a}{10^b} = 10^{a-b}
46
+ $$
36
47
 
37
- $\\frac{x^a}{x^b} = x^{a-b}$`}`,
38
- correction: `${opts?.useOnlyPowersOfTen
39
- ? `On utilise la propriété : $\\frac{10^a}{10^b} = 10^{a-b}$. On a alors :
48
+ On a alors :
40
49
 
41
50
  ${alignTex([
42
- [
43
- statementTex,
44
- "=",
45
- `10^{${new SubstractNode(b.toTree(), c.toTree()).toTex()}}`,
46
- ],
47
- ["", "=", answer],
48
- ])}`
49
- : `On utilise la propriété : $\\frac{x^a}{x^b} = x^{a-b}$. On a alors :
51
+ [statementTex, "=", power(10, substract(b, c)).toTex()],
52
+ ["", "=", answer],
53
+ ])}`;
54
+ }
55
+ return `On utilise la propriété :
56
+
57
+ $$
58
+ \\frac{x^a}{x^b} = x^{a-b}
59
+ $$
60
+
61
+ On a alors :
50
62
 
51
63
  ${alignTex([
52
- [
53
- statementTex,
54
- "=",
55
- `${a.toTree().toTex()}^{${new SubstractNode(b.toTree(), c.toTree()).toTex()}}`,
56
- ],
57
- ["", "=", answer],
58
- ])}`} `,
64
+ [statementTex, "=", power(a, substract(b, c)).toTex()],
65
+ ["", "=", answer],
66
+ ])}`;
67
+ };
68
+ const getStartStatement = (identifiers) => {
69
+ const { a, b, c } = identifiers;
70
+ const statement = frac(power(a, b), power(a, c));
71
+ return statement.toTex();
72
+ };
73
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
74
+ const question = {
75
+ instruction: getInstruction(identifiers, opts),
76
+ startStatement: getStartStatement(identifiers, opts),
77
+ answer: getAnswer(identifiers, opts),
78
+ keys: [],
79
+ hint: getHint(identifiers, opts),
80
+ correction: getCorrection(identifiers, opts),
59
81
  answerFormat: "tex",
60
- identifiers: { a, b, c },
82
+ identifiers,
61
83
  };
62
84
  return question;
63
85
  };
86
+ const getPowersDivisionQuestion = (opts) => {
87
+ let a = opts.useOnlyPowersOfTen ? 10 : randint(-11, 11, [0]);
88
+ const [b, c] = [1, 2].map((el) => randint(-11, 11));
89
+ const identifiers = { a, b, c };
90
+ return getQuestionFromIdentifiers(identifiers, opts);
91
+ };
64
92
  const getPropositions = (n, { answer, a, b, c }) => {
65
93
  const propositions = [];
66
94
  addValidProp(propositions, answer);
@@ -88,34 +116,20 @@ export const powersDivision = {
88
116
  id: "powersDivision",
89
117
  connector: "=",
90
118
  label: "Division de puissances",
91
- levels: [
92
- "4ème",
93
- "3ème",
94
- "2nde",
95
- "2ndPro",
96
- "1reESM",
97
- "1rePro",
98
- "1reSpé",
99
- "1reTech",
100
- "TermPro",
101
- "TermTech",
102
- ],
103
- sections: ["Puissances"],
104
119
  isSingleStep: true,
105
- generator: (nb) => getDistinctQuestions(() => getPowersDivisionQuestion({ useOnlyPowersOfTen: false }), nb),
120
+ generator: (nb, opts) => getDistinctQuestions(() => getPowersDivisionQuestion({ useOnlyPowersOfTen: false }), nb),
106
121
  qcmTimer: 60,
107
122
  freeTimer: 60,
108
123
  getPropositions,
109
124
  isAnswerValid,
110
125
  subject: "Mathématiques",
111
126
  hasHintAndCorrection: true,
127
+ getQuestionFromIdentifiers,
112
128
  };
113
129
  export const powersOfTenDivision = {
114
130
  id: "powersOfTenDivision",
115
131
  connector: "=",
116
132
  label: "Division de puissances de $10$",
117
- levels: ["4ème", "3ème", "2nde"],
118
- sections: ["Puissances"],
119
133
  isSingleStep: true,
120
134
  generator: (nb) => getDistinctQuestions(() => getPowersDivisionQuestion({ useOnlyPowersOfTen: true }), nb),
121
135
  qcmTimer: 60,
@@ -124,4 +138,5 @@ export const powersOfTenDivision = {
124
138
  isAnswerValid,
125
139
  subject: "Mathématiques",
126
140
  hasHintAndCorrection: true,
141
+ getQuestionFromIdentifiers,
127
142
  };
@@ -5,6 +5,7 @@ type Identifiers = {
5
5
  k: number;
6
6
  l: number;
7
7
  m: number;
8
+ n: number | undefined;
8
9
  };
9
10
  export declare const powersMixOperations: Exercise<Identifiers>;
10
11
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"powersMixOperations.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersMixOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAerC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwFF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAgBrD,CAAC"}
1
+ {"version":3,"file":"powersMixOperations.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersMixOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAwBrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvB,CAAC;AA2KF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}
@@ -1,16 +1,19 @@
1
1
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { randint } from "../../../math/utils/random/randint.js";
4
- import { frac } from "../../../tree/nodes/operators/fractionNode.js";
4
+ import { frac, isFractionNode, } from "../../../tree/nodes/operators/fractionNode.js";
5
5
  import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
6
  import { power } from "../../../tree/nodes/operators/powerNode.js";
7
7
  import { powerParser } from "../../../tree/parsers/powerParser.js";
8
+ import { valueParser } from "../../../tree/parsers/valueParser.js";
9
+ import { coinFlip } from "../../../utils/alea/coinFlip.js";
8
10
  import { doWhile } from "../../../utils/doWhile.js";
9
11
  import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
12
+ import { isInt } from "../../../utils/isInt.js";
10
13
  const getStatementNode = (identifiers) => {
11
- const { a, b, k, l, m } = identifiers;
12
- const n = k + l * m;
13
- return frac(multiply(power(a, k), power(power(a, l), m)), power(b, n));
14
+ const { a, b, k, l, m, n } = identifiers;
15
+ const nPower = n ?? k + l * m;
16
+ return frac(multiply(power(a, k), power(power(a, l), m)), power(b, nPower));
14
17
  };
15
18
  const getPropositions = (n, { answer, ...identifiers }) => {
16
19
  const propositions = [];
@@ -25,7 +28,18 @@ const getPropositions = (n, { answer, ...identifiers }) => {
25
28
  };
26
29
  const getAnswer = (identifiers) => {
27
30
  const statement = getStatementNode(identifiers);
28
- return statement.simplify({ keepPowers: true }).toTex();
31
+ const { a, b, k, l, m, n } = identifiers;
32
+ if (a !== b) {
33
+ const pow = k + l * m;
34
+ const fraction = frac(a, b).simplify();
35
+ if (isFractionNode(fraction) && fraction.leftChild.evaluate() === 1) {
36
+ return power(fraction.rightChild, -pow).toTex();
37
+ }
38
+ return power(fraction, pow).toTex();
39
+ }
40
+ return power(a, k + l * m - n)
41
+ .simplify({ keepPowers: true })
42
+ .toTex();
29
43
  };
30
44
  const getInstruction = (identifiers) => {
31
45
  return `Écrire sous la forme d'une seule puissance :
@@ -34,17 +48,58 @@ $$
34
48
  ${getStatementNode(identifiers).toTex()}
35
49
  $$`;
36
50
  };
37
- // const getHint: GetHint<Identifiers> = (identifiers) => {
38
- // return ``;
39
- // };
40
- // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
41
- // return ``;
42
- // };
51
+ const getHint = (identifiers) => {
52
+ return `On utilise les propriétés suivantes :
53
+
54
+ - $a^x \\times a^y = a^{x+y}$
55
+
56
+ - $(a^x)^y = a^{xy}$
57
+
58
+ - $\\frac{a^x}{a^y} = a^{x-y}$
59
+ `;
60
+ };
61
+ const getCorrection = (identifiers) => {
62
+ const { a, b, k, l, m, n } = identifiers;
63
+ const statement = getStatementNode(identifiers);
64
+ const num = multiply(power(a, k), power(power(a, l), m));
65
+ const firstStep = multiply(power(a, k), power(power(a, l), m).simplify({ keepPowers: true }));
66
+ const numSimp = num.simplify({ keepPowers: true });
67
+ let corr = `On simplifie le numérateur :
68
+
69
+ $$
70
+ ${multiply(power(a, k), power(power(a, l), m)).toTex()} = ${firstStep.toTex()} = ${numSimp.toTex()}
71
+ $$
72
+
73
+ `;
74
+ if (a === b) {
75
+ corr += `On a donc :
76
+
77
+ $$
78
+ ${statement.toTex()} = ${frac(numSimp, power(a, n)).toTex()} = ${getAnswer(identifiers)}
79
+ $$`;
80
+ return corr;
81
+ }
82
+ const pow = k + l * m;
83
+ const denum = power(b, pow);
84
+ return (corr +
85
+ `On a donc :
86
+
87
+ $$
88
+ ${statement.toTex()} = ${frac(numSimp, denum).toTex()} = ${getAnswer(identifiers)}
89
+ $$
90
+ `);
91
+ };
43
92
  const getKeys = (identifiers) => {
44
93
  return [];
45
94
  };
46
95
  const isAnswerValid = (ans, { answer }) => {
47
96
  try {
97
+ if (isInt(Number(answer))) {
98
+ const parsed = valueParser(ans);
99
+ if (parsed !== false) {
100
+ return parsed === Number(answer);
101
+ }
102
+ }
48
103
  const parsed = powerParser(ans);
49
104
  if (!parsed)
50
105
  return false;
@@ -57,25 +112,39 @@ const isAnswerValid = (ans, { answer }) => {
57
112
  const getPowersMixOperationsQuestion = (ops) => {
58
113
  const finalPower = randint(2, 10);
59
114
  const a = randint(2, 10);
60
- const b = randint(2, 10, [a]);
61
- const l = randint(-5, 6, [0, 1]);
62
- const m = doWhile(() => randint(2, 6), (x) => x * l === finalPower);
63
- const k = finalPower - l * m;
115
+ const bEqualsA = coinFlip();
116
+ const b = bEqualsA ? a : randint(2, 10, [a]);
117
+ let l, m, k, n;
118
+ if (!bEqualsA) {
119
+ l = randint(-5, 6, [0, 1]);
120
+ m = doWhile(() => randint(2, 6), (x) => x * l === finalPower);
121
+ k = finalPower - l * m;
122
+ }
123
+ else {
124
+ l = randint(-5, 6);
125
+ m = randint(-5, 6);
126
+ k = randint(-5, 6);
127
+ n = randint(-5, 6);
128
+ }
64
129
  const identifiers = {
65
130
  a,
66
131
  b,
67
132
  k,
68
133
  l,
69
134
  m,
135
+ n,
70
136
  };
137
+ return getQuestionFromIdentifiers(identifiers);
138
+ };
139
+ const getQuestionFromIdentifiers = (identifiers) => {
71
140
  const question = {
72
141
  answer: getAnswer(identifiers),
73
142
  instruction: getInstruction(identifiers),
74
143
  keys: getKeys(identifiers),
75
144
  answerFormat: "tex",
76
145
  identifiers,
77
- // hint: getHint(identifiers),
78
- // correction: getCorrection(identifiers),
146
+ hint: getHint(identifiers),
147
+ correction: getCorrection(identifiers),
79
148
  };
80
149
  return question;
81
150
  };
@@ -94,4 +163,6 @@ export const powersMixOperations = {
94
163
  // getHint,
95
164
  // getCorrection,
96
165
  getAnswer,
166
+ hasHintAndCorrection: true,
167
+ getQuestionFromIdentifiers,
97
168
  };
@@ -0,0 +1,10 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ c: number;
6
+ d: number;
7
+ };
8
+ export declare const powersOfTenMixOperations: Exercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=powersOfTenMixOperations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"powersOfTenMixOperations.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersOfTenMixOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAuHF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAkB1D,CAAC"}
@@ -0,0 +1,129 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../math/utils/random/randint.js";
4
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
5
+ import { multiply } from "../../../tree/nodes/operators/multiplyNode.js";
6
+ import { power } from "../../../tree/nodes/operators/powerNode.js";
7
+ import { powerParser } from "../../../tree/parsers/powerParser.js";
8
+ import { valueParser } from "../../../tree/parsers/valueParser.js";
9
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
10
+ import { isInt } from "../../../utils/isInt.js";
11
+ const getPropositions = (n, { answer }) => {
12
+ const propositions = [];
13
+ addValidProp(propositions, answer);
14
+ while (propositions.length < n) {
15
+ tryToAddWrongProp(propositions, power(10, randint(-9, 10)).simplify({ keepPowers: true }).toTex());
16
+ }
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { a, b, c, d } = identifiers;
21
+ return power(10, a + b - c * d)
22
+ .simplify({ keepPowers: true })
23
+ .toTex();
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const { a, b, c, d } = identifiers;
27
+ return `Écrire sous la forme d'une seule puissance de $10$ :
28
+
29
+ $$
30
+ ${frac(multiply(power(10, a), power(10, b)), power(power(10, c), d)).toTex()}
31
+ $$`;
32
+ };
33
+ const getHint = (identifiers) => {
34
+ const { a, b, c, d } = identifiers;
35
+ return `On utilise les propriétés suivantes :
36
+
37
+ - $10^a \\times 10^b = 10^{a+b}$
38
+
39
+ - $(10^a)^b = 10^{ab}$
40
+
41
+ - $\\frac{10^a}{10^b} = 10^{a-b}$
42
+ `;
43
+ };
44
+ const getCorrection = (identifiers) => {
45
+ const { a, b, c, d } = identifiers;
46
+ const statement = frac(multiply(power(10, a), power(10, b)), power(power(10, c), d));
47
+ const num = power(10, a + b).simplify({ keepPowers: true });
48
+ const denum = power(10, c * d).simplify({ keepPowers: true });
49
+ return `On simplifie le numérateur :
50
+
51
+ $$
52
+ ${multiply(power(10, a), power(10, b)).toTex()} = ${num.toTex()}
53
+ $$
54
+
55
+ Puis le dénumérateur :
56
+
57
+ $$
58
+ ${power(power(10, c), d).toTex()} = ${denum.toTex()}
59
+ $$
60
+
61
+ On a donc :
62
+
63
+ $$
64
+ ${statement.toTex()} = ${frac(num, denum).toTex()} = ${getAnswer(identifiers)}
65
+ $$
66
+ `;
67
+ };
68
+ const getKeys = (identifiers) => {
69
+ return [];
70
+ };
71
+ const isAnswerValid = (ans, { answer }) => {
72
+ try {
73
+ if (isInt(Number(answer))) {
74
+ const parsed = valueParser(ans);
75
+ if (parsed !== false) {
76
+ return parsed === Number(answer);
77
+ }
78
+ }
79
+ const parsed = powerParser(ans);
80
+ if (!parsed)
81
+ return false;
82
+ return parsed.simplify({ keepPowers: true }).toTex() === answer;
83
+ }
84
+ catch (err) {
85
+ return handleVEAError(err);
86
+ }
87
+ };
88
+ const getPowersOfTenMixOperationsQuestion = (ops) => {
89
+ const a = randint(-9, 10);
90
+ const b = randint(-9, 10);
91
+ const c = randint(-9, 10);
92
+ const d = randint(-9, 10);
93
+ const identifiers = {
94
+ a,
95
+ b,
96
+ c,
97
+ d,
98
+ };
99
+ return getQuestionFromIdentifiers(identifiers);
100
+ };
101
+ const getQuestionFromIdentifiers = (identifiers) => {
102
+ return {
103
+ answer: getAnswer(identifiers),
104
+ instruction: getInstruction(identifiers),
105
+ keys: getKeys(identifiers),
106
+ answerFormat: "tex",
107
+ identifiers,
108
+ hint: getHint(identifiers),
109
+ correction: getCorrection(identifiers),
110
+ };
111
+ };
112
+ export const powersOfTenMixOperations = {
113
+ id: "powersOfTenMixOperations",
114
+ connector: "=",
115
+ label: "Calcul avec des puissances de $10$ : mélange d'opérations",
116
+ isSingleStep: true,
117
+ generator: (nb, opts) => getDistinctQuestions(() => getPowersOfTenMixOperationsQuestion(opts), nb),
118
+ qcmTimer: 60,
119
+ freeTimer: 60,
120
+ getPropositions,
121
+ isAnswerValid,
122
+ subject: "Mathématiques",
123
+ getInstruction,
124
+ // getHint,
125
+ // getCorrection,
126
+ getAnswer,
127
+ getQuestionFromIdentifiers,
128
+ hasHintAndCorrection: true,
129
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"powersOfTenToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersOfTenToDecimal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EACL,QAAQ,EAYT,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAyEF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAiBtD,CAAC"}
1
+ {"version":3,"file":"powersOfTenToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersOfTenToDecimal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EACL,QAAQ,EAcT,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAoGF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAkBtD,CAAC"}
@@ -32,10 +32,36 @@ const getAnswer = (identifiers) => {
32
32
  return answer;
33
33
  };
34
34
  const getPowersOfTenToDecimalQuestion = () => {
35
- const randPower = randint(-9, 10);
35
+ const randPower = randint(-6, 7);
36
36
  const identifiers = { randPower };
37
37
  return getQuestionFromIdentifiers(identifiers);
38
38
  };
39
+ const getHint = (identifiers) => {
40
+ return `Si $x$ est un entier positif, alors $10^x$ est le nombre composé d'un $1$ suivi de $x$ zéros.
41
+
42
+ Si $x$ est un entier négatif, alors $10^x$ est le nombre composé d'un $1$ précédé de $x$ zéros.
43
+
44
+ Enfin, tout nombre élevé à la puissance $0$ est égal à $1$.`;
45
+ };
46
+ const getCorrection = (identifiers) => {
47
+ const { randPower } = identifiers;
48
+ const order = randPower < 0 ? "précédé" : "suivi";
49
+ let corr = "";
50
+ if (randPower === 0) {
51
+ corr = `Tout nombre élevé à la puissance $0$ est égal à $1$ : `;
52
+ }
53
+ else if (randPower === 1) {
54
+ corr = `Un nombre élevé à la puissance $1$ est égal à lui-même :`;
55
+ }
56
+ else {
57
+ corr = `$10^{${randPower}}$ est le nombre composé d'un $1$ ${order} de $${Math.abs(randPower)}$ zéros :`;
58
+ }
59
+ const final = `
60
+ $$
61
+ ${getStartStatement(identifiers)}=${getAnswer(identifiers)}
62
+ $$`;
63
+ return corr + final;
64
+ };
39
65
  const getQuestionFromIdentifiers = (identifiers) => {
40
66
  const question = {
41
67
  instruction: getInstruction(identifiers),
@@ -44,6 +70,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
44
70
  keys: [],
45
71
  answerFormat: "tex",
46
72
  identifiers,
73
+ hint: getHint(identifiers),
74
+ correction: getCorrection(identifiers),
47
75
  };
48
76
  return question;
49
77
  };
@@ -68,10 +96,10 @@ export const powersOfTenToDecimal = {
68
96
  connector: "=",
69
97
  label: "Écriture décimale d'une puissance de $10$",
70
98
  isSingleStep: true,
71
- generator: (nb) => getDistinctQuestions(getPowersOfTenToDecimalQuestion, nb, 19),
99
+ generator: (nb) => getDistinctQuestions(getPowersOfTenToDecimalQuestion, nb, 12),
72
100
  qcmTimer: 60,
73
101
  freeTimer: 60,
74
- maxAllowedQuestions: 19,
102
+ maxAllowedQuestions: 12,
75
103
  getPropositions,
76
104
  isAnswerValid,
77
105
  subject: "Mathématiques",
@@ -79,4 +107,5 @@ export const powersOfTenToDecimal = {
79
107
  getAnswer,
80
108
  getStartStatement,
81
109
  getQuestionFromIdentifiers,
110
+ hasHintAndCorrection: true,
82
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"powersProduct.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersProduct.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,EACL,QAAQ,EAiBT,MAAM,mBAAmB,CAAC;AAM3B,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AA4IF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAuB7D,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAyBxD,CAAC"}
1
+ {"version":3,"file":"powersProduct.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersProduct.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,EACL,QAAQ,EAiBT,MAAM,mBAAmB,CAAC;AAM3B,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AA6IF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAuB7D,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAyBxD,CAAC"}
@@ -85,6 +85,7 @@ const getQuestionFromIdentifiers = (identifiers, opts) => {
85
85
  const getPropositions = (n, { answer, a, b, c }) => {
86
86
  const propositions = [];
87
87
  addValidProp(propositions, answer);
88
+ tryToAddWrongProp(propositions, power(a, add(b, c)).simplify().toTex());
88
89
  while (propositions.length < n) {
89
90
  const wrongExponent = b + c + randint(-11, 11, [0, -b - c]);
90
91
  const wrongAnswerTree = new Power(a === 1 || a === -1 ? randint(-3, 4, [-1, 1]) : a, wrongExponent).simplify();
@@ -1 +1 @@
1
- {"version":3,"file":"scientificToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/scientificToDecimal.ts"],"names":[],"mappings":"AAAA;;MAEM;AAYN,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAE3B,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAiDF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAYrD,CAAC"}
1
+ {"version":3,"file":"scientificToDecimal.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/scientificToDecimal.ts"],"names":[],"mappings":"AAAA;;MAEM;AAaN,OAAO,EACL,QAAQ,EAeT,MAAM,mBAAmB,CAAC;AAE3B,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AA8FF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * a*10^x vers décimal
3
3
  * */
4
+ import { numberVEA } from "../../../exercises/vea/numberVEA.js";
4
5
  import { Decimal, DecimalConstructor, } from "../../../math/numbers/decimals/decimal.js";
5
6
  import { randint } from "../../../math/utils/random/randint.js";
6
7
  import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
@@ -8,22 +9,59 @@ import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode.js";
8
9
  import { PowerNode } from "../../../tree/nodes/operators/powerNode.js";
9
10
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../exercise.js";
10
11
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions.js";
11
- const getScientificToDecimalQuestion = () => {
12
- const decScientific = DecimalConstructor.randomScientific(randint(1, 4));
13
- const tenPower = randint(-5, 6, [0, 1]);
12
+ const getInstruction = (identifiers) => {
13
+ return `Donner l'écriture décimale du nombre suivant :
14
+
15
+ $$
16
+ ${getStartStatement(identifiers)}
17
+ $$`;
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { decimal, tenPower } = identifiers;
21
+ const decScientific = new Decimal(decimal);
14
22
  const answer = decScientific.multiplyByPowerOfTen(tenPower).toTree().toTex();
15
- const statement = new MultiplyNode(new NumberNode(decScientific.value), new PowerNode(new NumberNode(10), new NumberNode(tenPower)));
16
- const statementTex = statement.toTex();
23
+ return answer;
24
+ };
25
+ const getHint = (identifiers) => {
26
+ const { decimal, tenPower } = identifiers;
27
+ return `Si $x$ est un entier négatif, alors multiplier par $10^x$ revient à déplacer la virgule de $x$ rangs vers la gauche.
28
+
29
+ Si $x$ est un entier positif, alors multiplier par $10^x$ revient à déplacer la virgule de $x$ rangs vers la droite.`;
30
+ };
31
+ const getCorrection = (identifiers) => {
32
+ const { decimal, tenPower } = identifiers;
33
+ return `On déplace la virgule de $${Math.abs(tenPower)}$ rangs vers la ${tenPower < 0 ? "gauche" : "droite"} :
34
+
35
+ $$
36
+ ${getStartStatement(identifiers)} = ${getAnswer(identifiers)}
37
+ $$`;
38
+ };
39
+ const getQuestionFromIdentifiers = (identifiers) => {
40
+ const { decimal, tenPower } = identifiers;
17
41
  const question = {
18
- instruction: `Donner l'écriture décimale de : $${statementTex}$`,
19
- startStatement: statementTex,
20
- answer: answer,
42
+ instruction: getInstruction(identifiers),
43
+ startStatement: getStartStatement(identifiers),
44
+ answer: getAnswer(identifiers),
21
45
  keys: [],
22
46
  answerFormat: "tex",
23
- identifiers: { decimal: decScientific.value, tenPower },
47
+ identifiers,
48
+ hint: getHint(identifiers),
49
+ correction: getCorrection(identifiers),
24
50
  };
25
51
  return question;
26
52
  };
53
+ const getStartStatement = (identifiers) => {
54
+ const { decimal, tenPower } = identifiers;
55
+ const statement = new MultiplyNode(new NumberNode(decimal), new PowerNode(new NumberNode(10), new NumberNode(tenPower)));
56
+ const statementTex = statement.toTex();
57
+ return statementTex;
58
+ };
59
+ const getScientificToDecimalQuestion = () => {
60
+ const decScientific = DecimalConstructor.randomScientific(randint(1, 4));
61
+ const tenPower = randint(-5, 6, [0, 1]);
62
+ const identifiers = { decimal: decScientific.value, tenPower };
63
+ return getQuestionFromIdentifiers(identifiers);
64
+ };
27
65
  const getPropositions = (n, { answer, tenPower, decimal }) => {
28
66
  const propositions = [];
29
67
  const decScientific = new Decimal(decimal);
@@ -39,7 +77,7 @@ const getPropositions = (n, { answer, tenPower, decimal }) => {
39
77
  return shuffleProps(propositions, n);
40
78
  };
41
79
  const isAnswerValid = (ans, { answer }) => {
42
- return ans === answer;
80
+ return numberVEA(ans, answer);
43
81
  };
44
82
  export const scientificToDecimal = {
45
83
  id: "scientificToDecimal",
@@ -52,4 +90,6 @@ export const scientificToDecimal = {
52
90
  getPropositions,
53
91
  isAnswerValid,
54
92
  subject: "Mathématiques",
93
+ getQuestionFromIdentifiers,
94
+ hasHintAndCorrection: true,
55
95
  };