math-exercises 3.0.55 → 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 (147) hide show
  1. package/lib/exercises/math/calcul/arithmetics/index.d.ts +1 -0
  2. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/arithmetics/index.js +1 -0
  4. package/lib/exercises/math/calcul/arithmetics/ppcmCalcul.d.ts +8 -0
  5. package/lib/exercises/math/calcul/arithmetics/ppcmCalcul.d.ts.map +1 -0
  6. package/lib/exercises/math/calcul/arithmetics/ppcmCalcul.js +87 -0
  7. package/lib/exercises/math/calcul/proportionality/proportionalityTable.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/proportionality/proportionalityTable.js +2 -2
  9. package/lib/exercises/math/calculLitteral/equation/binomialsTrinomialsProposedSolutions.d.ts.map +1 -1
  10. package/lib/exercises/math/calculLitteral/equation/binomialsTrinomialsProposedSolutions.js +7 -1
  11. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.d.ts.map +1 -1
  12. package/lib/exercises/math/calculLitteral/equation/choseOperationToSolveEquation.js +65 -13
  13. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
  14. package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +43 -0
  15. package/lib/exercises/math/calculLitteral/systems/basicNiceValuesSystemResolution.d.ts.map +1 -1
  16. package/lib/exercises/math/calculLitteral/systems/basicNiceValuesSystemResolution.js +23 -0
  17. package/lib/exercises/math/calculLitteral/systems/basicSystemResolution.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/systems/basicSystemResolution.js +23 -0
  19. package/lib/exercises/math/calculLitteral/systems/verifySystemSolution.d.ts.map +1 -1
  20. package/lib/exercises/math/calculLitteral/systems/verifySystemSolution.js +49 -0
  21. package/lib/exercises/math/conversion/capacityConversion.d.ts.map +1 -1
  22. package/lib/exercises/math/conversion/capacityConversion.js +68 -12
  23. package/lib/exercises/math/conversion/hoursToDecimal.d.ts.map +1 -1
  24. package/lib/exercises/math/conversion/hoursToDecimal.js +73 -15
  25. package/lib/exercises/math/conversion/lengthConversion.d.ts.map +1 -1
  26. package/lib/exercises/math/conversion/lengthConversion.js +55 -6
  27. package/lib/exercises/math/conversion/massConversion.d.ts.map +1 -1
  28. package/lib/exercises/math/conversion/massConversion.js +72 -16
  29. package/lib/exercises/math/conversion/volumeConversion.d.ts.map +1 -1
  30. package/lib/exercises/math/conversion/volumeConversion.js +72 -12
  31. package/lib/exercises/math/functions/affines/signFunction.d.ts.map +1 -1
  32. package/lib/exercises/math/functions/affines/signFunction.js +23 -11
  33. package/lib/exercises/math/functions/basics/imageFunctionGeogebra.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/basics/imageFunctionGeogebra.js +16 -0
  35. package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
  36. package/lib/exercises/math/geometry/areas/triangleArea.js +34 -2
  37. package/lib/exercises/math/geometry/areas/triangleAreaV2.d.ts.map +1 -1
  38. package/lib/exercises/math/geometry/areas/triangleAreaV2.js +54 -8
  39. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.d.ts.map +1 -1
  40. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLine.js +12 -5
  41. package/lib/exercises/math/geometry/cartesian/readAbscissOnLine.d.ts.map +1 -1
  42. package/lib/exercises/math/geometry/cartesian/readAbscissOnLine.js +29 -1
  43. package/lib/exercises/math/geometry/cartesian/readAbscissOnSemiLine.d.ts.map +1 -1
  44. package/lib/exercises/math/geometry/cartesian/readAbscissOnSemiLine.js +25 -1
  45. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.d.ts.map +1 -1
  46. package/lib/exercises/math/geometry/lines/cartesianEquationToReduced.js +68 -29
  47. package/lib/exercises/math/geometry/lines/cartesianEquationsIntersection.d.ts.map +1 -1
  48. package/lib/exercises/math/geometry/lines/cartesianEquationsIntersection.js +56 -4
  49. package/lib/exercises/math/geometry/lines/directorVectorFromAnother.d.ts.map +1 -1
  50. package/lib/exercises/math/geometry/lines/directorVectorFromAnother.js +1 -0
  51. package/lib/exercises/math/geometry/lines/drawLineFromCartesianEquation.d.ts.map +1 -1
  52. package/lib/exercises/math/geometry/lines/drawLineFromCartesianEquation.js +71 -25
  53. package/lib/exercises/math/geometry/lines/index.d.ts +1 -0
  54. package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -1
  55. package/lib/exercises/math/geometry/lines/index.js +1 -0
  56. package/lib/exercises/math/geometry/vectors/findCoordForAligment.d.ts +6 -0
  57. package/lib/exercises/math/geometry/vectors/findCoordForAligment.d.ts.map +1 -1
  58. package/lib/exercises/math/geometry/vectors/findCoordForAligment.js +161 -92
  59. package/lib/exercises/math/geometry/vectors/index.d.ts +1 -0
  60. package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
  61. package/lib/exercises/math/geometry/vectors/index.js +1 -0
  62. package/lib/exercises/math/geometry/volumes/coneVolume.d.ts.map +1 -1
  63. package/lib/exercises/math/geometry/volumes/coneVolume.js +68 -6
  64. package/lib/exercises/math/geometry/volumes/parallelepipedVolume.d.ts.map +1 -1
  65. package/lib/exercises/math/geometry/volumes/parallelepipedVolume.js +55 -11
  66. package/lib/exercises/math/geometry/volumes/sphereVolume.d.ts.map +1 -1
  67. package/lib/exercises/math/geometry/volumes/sphereVolume.js +31 -3
  68. package/lib/exercises/math/geometry/volumes/volumeOfCube.d.ts.map +1 -1
  69. package/lib/exercises/math/geometry/volumes/volumeOfCube.js +46 -18
  70. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithSquareOrRectBase.d.ts.map +1 -1
  71. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithSquareOrRectBase.js +114 -63
  72. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.d.ts.map +1 -1
  73. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleBase.js +102 -64
  74. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.d.ts.map +1 -1
  75. package/lib/exercises/math/geometry/volumes/volumeOfPyramidWithTriangleRectBase.js +99 -53
  76. package/lib/exercises/math/limits/polynomLimit.d.ts +1 -1
  77. package/lib/exercises/math/limits/polynomLimit.d.ts.map +1 -1
  78. package/lib/exercises/math/limits/polynomLimit.js +28 -9
  79. package/lib/exercises/math/limits/polynomLimitNoFI.d.ts +1 -1
  80. package/lib/exercises/math/limits/polynomLimitNoFI.d.ts.map +1 -1
  81. package/lib/exercises/math/limits/polynomLimitNoFI.js +29 -10
  82. package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
  83. package/lib/exercises/math/powers/calculateNegativePower.js +59 -16
  84. package/lib/exercises/math/powers/decimalToScientific.d.ts.map +1 -1
  85. package/lib/exercises/math/powers/decimalToScientific.js +55 -11
  86. package/lib/exercises/math/powers/index.d.ts +1 -0
  87. package/lib/exercises/math/powers/index.d.ts.map +1 -1
  88. package/lib/exercises/math/powers/index.js +1 -0
  89. package/lib/exercises/math/powers/powersDivision.d.ts +5 -2
  90. package/lib/exercises/math/powers/powersDivision.d.ts.map +1 -1
  91. package/lib/exercises/math/powers/powersDivision.js +68 -53
  92. package/lib/exercises/math/powers/powersMixOperations.d.ts +1 -0
  93. package/lib/exercises/math/powers/powersMixOperations.d.ts.map +1 -1
  94. package/lib/exercises/math/powers/powersMixOperations.js +88 -17
  95. package/lib/exercises/math/powers/powersOfTenMixOperations.d.ts +10 -0
  96. package/lib/exercises/math/powers/powersOfTenMixOperations.d.ts.map +1 -0
  97. package/lib/exercises/math/powers/powersOfTenMixOperations.js +129 -0
  98. package/lib/exercises/math/powers/powersOfTenToDecimal.d.ts.map +1 -1
  99. package/lib/exercises/math/powers/powersOfTenToDecimal.js +32 -3
  100. package/lib/exercises/math/powers/powersProduct.d.ts.map +1 -1
  101. package/lib/exercises/math/powers/powersProduct.js +1 -0
  102. package/lib/exercises/math/powers/scientificToDecimal.d.ts.map +1 -1
  103. package/lib/exercises/math/powers/scientificToDecimal.js +50 -10
  104. package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
  105. package/lib/exercises/math/primitive/polynomialPrimitive.js +1 -0
  106. package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.d.ts.map +1 -1
  107. package/lib/exercises/math/sequences/geometric/geometricFirstTermsGeneralSum.js +50 -3
  108. package/lib/exercises/math/sequences/geometric/geometricFirstTermsSum.d.ts.map +1 -1
  109. package/lib/exercises/math/sequences/geometric/geometricFirstTermsSum.js +32 -0
  110. package/lib/exercises/math/trigonometry/remarkableValues.d.ts.map +1 -1
  111. package/lib/exercises/math/trigonometry/remarkableValues.js +8 -0
  112. package/lib/exercises/math/trigonometry/trigonometry.d.ts.map +1 -1
  113. package/lib/exercises/math/trigonometry/trigonometry.js +67 -1
  114. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts.map +1 -1
  115. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.js +89 -0
  116. package/lib/index.d.ts +22 -4
  117. package/lib/index.d.ts.map +1 -1
  118. package/lib/math/geometry/angle.d.ts.map +1 -1
  119. package/lib/math/geometry/angle.js +0 -5
  120. package/lib/math/geometry/vector.d.ts +3 -0
  121. package/lib/math/geometry/vector.d.ts.map +1 -1
  122. package/lib/math/geometry/vector.js +25 -0
  123. package/lib/math/numbers/decimals/decimal.d.ts +1 -0
  124. package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
  125. package/lib/math/numbers/decimals/decimal.js +2 -0
  126. package/lib/math/systems/generalSystem.d.ts +6 -1
  127. package/lib/math/systems/generalSystem.d.ts.map +1 -1
  128. package/lib/math/systems/generalSystem.js +137 -0
  129. package/lib/math/utils/arithmetic/lcm.d.ts +2 -0
  130. package/lib/math/utils/arithmetic/lcm.d.ts.map +1 -0
  131. package/lib/math/utils/arithmetic/lcm.js +5 -0
  132. package/lib/playground.d.ts.map +1 -1
  133. package/lib/playground.js +1 -3
  134. package/lib/tree/nodes/algebraicNode.d.ts +1 -0
  135. package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
  136. package/lib/tree/nodes/equations/equalNode.d.ts +7 -1
  137. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  138. package/lib/tree/nodes/equations/equalNode.js +17 -9
  139. package/lib/tree/nodes/operators/addNode.js +1 -1
  140. package/lib/tree/nodes/operators/fractionNode.d.ts +2 -2
  141. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  142. package/lib/tree/nodes/operators/fractionNode.js +37 -17
  143. package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
  144. package/lib/tree/nodes/operators/powerNode.js +5 -0
  145. package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
  146. package/lib/tree/nodes/sets/intervalNode.js +3 -1
  147. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"decimalToScientific.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/decimalToScientific.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAoDF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAYrD,CAAC"}
1
+ {"version":3,"file":"decimalToScientific.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/decimalToScientific.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,QAAQ,EAeT,MAAM,mBAAmB,CAAC;AAG3B,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAqGF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAcrD,CAAC"}
@@ -5,8 +5,59 @@ import { NumberNode } from "../../../tree/nodes/numbers/numberNode.js";
5
5
  import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode.js";
6
6
  import { PowerNode } from "../../../tree/nodes/operators/powerNode.js";
7
7
  import { probaFlip } from "../../../utils/alea/probaFlip.js";
8
+ import { pluralize } from "../../../utils/strings/pluralize.js";
8
9
  import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../exercise.js";
9
10
  import { getDistinctQuestions } from "../../utils/getDistinctQuestions.js";
11
+ const getInstruction = (identifiers) => {
12
+ const { decimal } = identifiers;
13
+ return `Donner l'écriture scientifique du nombre suivant :
14
+
15
+ $$
16
+ ${decimal.frenchify()}
17
+ $$`;
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { decimal } = identifiers;
21
+ const dec = new Decimal(decimal);
22
+ const answer = dec.toScientificNotation().toTex();
23
+ return answer;
24
+ };
25
+ const getHint = (identifiers) => {
26
+ return `Pour écrire un nombre en notation scientifique, il faut qu'il soit sous la forme :
27
+
28
+ $$
29
+ a\\times 10^n
30
+ $$
31
+
32
+ où $a$ est un nombre compris entre $1$ et $10$ (exclus). Repère où placer la virgule pour que $a$ soit correct, puis compte combien de fois il faut déplacer la virgule.`;
33
+ };
34
+ const getCorrection = (identifiers) => {
35
+ const { decimal } = identifiers;
36
+ const isZero = decimal < 1;
37
+ const order = isZero ? "droite" : "gauche";
38
+ const dec = new Decimal(decimal);
39
+ const absExp = Math.abs(dec.tenthExponentBelow);
40
+ return `On déplace la virgule après le premier chiffre non nul :
41
+
42
+ $$
43
+ ${decimal.frenchify()} = ${getAnswer(identifiers)}
44
+ $$
45
+
46
+ On a déplacé la virgule de $${absExp}$ ${pluralize("rang", absExp)} vers la ${order}, donc l'exposant est $${dec.tenthExponentBelow}$.`;
47
+ };
48
+ const getQuestionFromIdentifiers = (identifiers) => {
49
+ const question = {
50
+ instruction: getInstruction(identifiers),
51
+ startStatement: identifiers.decimal.frenchify(),
52
+ answer: getAnswer(identifiers),
53
+ keys: [],
54
+ answerFormat: "tex",
55
+ identifiers,
56
+ hint: getHint(identifiers),
57
+ correction: getCorrection(identifiers),
58
+ };
59
+ return question;
60
+ };
10
61
  const getDecimalToScientificQuestion = () => {
11
62
  const isZero = probaFlip(0.2);
12
63
  let intPart, dec;
@@ -17,17 +68,8 @@ const getDecimalToScientificQuestion = () => {
17
68
  intPart = IntegerConstructor.random(randint(2, 5));
18
69
  dec = DecimalConstructor.fromParts(intPart.toString(), DecimalConstructor.randomFracPart(randint(1, 3)));
19
70
  }
20
- const decTex = dec.toTree().toTex().replace(".", ",");
21
- const answer = dec.toScientificNotation().toTex();
22
- const question = {
23
- instruction: `Donner l'écriture scientifique de : $${decTex}$`,
24
- startStatement: decTex,
25
- answer: answer,
26
- keys: [],
27
- answerFormat: "tex",
28
- identifiers: { decimal: dec.value },
29
- };
30
- return question;
71
+ const identifiers = { decimal: dec.value };
72
+ return getQuestionFromIdentifiers(identifiers);
31
73
  };
32
74
  const getPropositions = (n, { answer, decimal }) => {
33
75
  const propositions = [];
@@ -55,4 +97,6 @@ export const decimalToScientific = {
55
97
  getPropositions,
56
98
  isAnswerValid,
57
99
  subject: "Mathématiques",
100
+ hasHintAndCorrection: true,
101
+ getQuestionFromIdentifiers,
58
102
  };
@@ -8,4 +8,5 @@ export * from "./powersPower.js";
8
8
  export * from "./powersProduct.js";
9
9
  export * from "./scientificToDecimal.js";
10
10
  export * from "./powersMixOperations.js";
11
+ export * from "./powersOfTenMixOperations.js";
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC"}
@@ -8,3 +8,4 @@ export * from "./powersPower.js";
8
8
  export * from "./powersProduct.js";
9
9
  export * from "./scientificToDecimal.js";
10
10
  export * from "./powersMixOperations.js";
11
+ export * from "./powersOfTenMixOperations.js";
@@ -7,7 +7,10 @@ type Identifiers = {
7
7
  b: number;
8
8
  c: number;
9
9
  };
10
- export declare const powersDivision: Exercise<Identifiers>;
11
- export declare const powersOfTenDivision: Exercise<Identifiers>;
10
+ type Options = {
11
+ useOnlyPowersOfTen: boolean;
12
+ };
13
+ export declare const powersDivision: Exercise<Identifiers, Options>;
14
+ export declare const powersOfTenDivision: Exercise<Identifiers, Options>;
12
15
  export {};
13
16
  //# sourceMappingURL=powersDivision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"powersDivision.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersDivision.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EACL,QAAQ,EAQT,MAAM,mBAAmB,CAAC;AAK3B,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA8FF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CA6BhD,CAAC;AACF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}
1
+ {"version":3,"file":"powersDivision.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/powers/powersDivision.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,OAAO,EACL,QAAQ,EAcT,MAAM,mBAAmB,CAAC;AAK3B,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;CAC7B,CAAC;AA6HF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiBzD,CAAC;AACF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAiB9D,CAAC"}
@@ -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"}