math-exercises 3.0.76 → 3.0.78

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 (108) hide show
  1. package/lib/exercises/math/calcul/arithmetics/calculateDistanceWithAbsoluteValue.d.ts +10 -0
  2. package/lib/exercises/math/calcul/arithmetics/calculateDistanceWithAbsoluteValue.d.ts.map +1 -0
  3. package/lib/exercises/math/calcul/arithmetics/calculateDistanceWithAbsoluteValue.js +112 -0
  4. package/lib/exercises/math/calcul/arithmetics/calculateWithAbsoluteValue.d.ts +8 -0
  5. package/lib/exercises/math/calcul/arithmetics/calculateWithAbsoluteValue.d.ts.map +1 -0
  6. package/lib/exercises/math/calcul/arithmetics/calculateWithAbsoluteValue.js +123 -0
  7. package/lib/exercises/math/calcul/arithmetics/compareInverseValues.d.ts +10 -0
  8. package/lib/exercises/math/calcul/arithmetics/compareInverseValues.d.ts.map +1 -0
  9. package/lib/exercises/math/calcul/arithmetics/compareInverseValues.js +136 -0
  10. package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.d.ts +9 -0
  11. package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.d.ts.map +1 -0
  12. package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.js +143 -0
  13. package/lib/exercises/math/calcul/arithmetics/index.d.ts +5 -0
  14. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/arithmetics/index.js +5 -0
  16. package/lib/exercises/math/calcul/arithmetics/sqrtInequality.d.ts +10 -0
  17. package/lib/exercises/math/calcul/arithmetics/sqrtInequality.d.ts.map +1 -0
  18. package/lib/exercises/math/calcul/arithmetics/sqrtInequality.js +160 -0
  19. package/lib/exercises/math/calcul/sign/absoluteNumber.js +1 -1
  20. package/lib/exercises/math/functions/absolute/absoluteValueInequations.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/absolute/absoluteValueInequations.js +5 -1
  22. package/lib/exercises/math/functions/basics/graphicEquation.d.ts.map +1 -1
  23. package/lib/exercises/math/functions/basics/graphicEquation.js +33 -1
  24. package/lib/exercises/math/functions/basics/twoFunctionsEquation.d.ts.map +1 -1
  25. package/lib/exercises/math/functions/basics/twoFunctionsEquation.js +27 -0
  26. package/lib/exercises/math/functions/cube/compareCubeValues.d.ts +8 -0
  27. package/lib/exercises/math/functions/cube/compareCubeValues.d.ts.map +1 -0
  28. package/lib/exercises/math/functions/cube/compareCubeValues.js +113 -0
  29. package/lib/exercises/math/functions/cube/index.d.ts +1 -0
  30. package/lib/exercises/math/functions/cube/index.d.ts.map +1 -1
  31. package/lib/exercises/math/functions/cube/index.js +1 -0
  32. package/lib/exercises/math/functions/index.d.ts +1 -0
  33. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  34. package/lib/exercises/math/functions/index.js +1 -0
  35. package/lib/exercises/math/functions/sqrt/compareSqrtValues.d.ts +8 -0
  36. package/lib/exercises/math/functions/sqrt/compareSqrtValues.d.ts.map +1 -0
  37. package/lib/exercises/math/functions/sqrt/compareSqrtValues.js +83 -0
  38. package/lib/exercises/math/functions/sqrt/index.d.ts +2 -0
  39. package/lib/exercises/math/functions/sqrt/index.d.ts.map +1 -0
  40. package/lib/exercises/math/functions/sqrt/index.js +1 -0
  41. package/lib/exercises/math/functions/variations/varTableExtremaReading.d.ts.map +1 -1
  42. package/lib/exercises/math/functions/variations/varTableExtremaReading.js +23 -8
  43. package/lib/exercises/math/geometry/angles/index.d.ts +1 -0
  44. package/lib/exercises/math/geometry/angles/index.d.ts.map +1 -1
  45. package/lib/exercises/math/geometry/angles/index.js +1 -0
  46. package/lib/exercises/math/geometry/angles/parallelogramFourthAngle.d.ts +8 -0
  47. package/lib/exercises/math/geometry/angles/parallelogramFourthAngle.d.ts.map +1 -0
  48. package/lib/exercises/math/geometry/angles/parallelogramFourthAngle.js +92 -0
  49. package/lib/exercises/math/geometry/cartesian/placeAbscissOnLine.d.ts.map +1 -1
  50. package/lib/exercises/math/geometry/cartesian/placeAbscissOnLine.js +26 -1
  51. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -1
  52. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +47 -13
  53. package/lib/exercises/math/geometry/lines/linesRelativePositions.d.ts.map +1 -1
  54. package/lib/exercises/math/geometry/lines/linesRelativePositions.js +29 -5
  55. package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.d.ts +8 -0
  56. package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.d.ts.map +1 -0
  57. package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.js +108 -0
  58. package/lib/exercises/math/probaStat/checkEquiprobability.d.ts +9 -0
  59. package/lib/exercises/math/probaStat/checkEquiprobability.d.ts.map +1 -0
  60. package/lib/exercises/math/probaStat/checkEquiprobability.js +129 -0
  61. package/lib/exercises/math/probaStat/getComplementaryProbability.d.ts +7 -0
  62. package/lib/exercises/math/probaStat/getComplementaryProbability.d.ts.map +1 -0
  63. package/lib/exercises/math/probaStat/getComplementaryProbability.js +90 -0
  64. package/lib/exercises/math/probaStat/getMissingProbabilityValue.d.ts +9 -0
  65. package/lib/exercises/math/probaStat/getMissingProbabilityValue.d.ts.map +1 -0
  66. package/lib/exercises/math/probaStat/getMissingProbabilityValue.js +109 -0
  67. package/lib/exercises/math/probaStat/index.d.ts +6 -0
  68. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  69. package/lib/exercises/math/probaStat/index.js +6 -0
  70. package/lib/exercises/math/probaStat/mostLeastProbable.d.ts +8 -0
  71. package/lib/exercises/math/probaStat/mostLeastProbable.d.ts.map +1 -0
  72. package/lib/exercises/math/probaStat/mostLeastProbable.js +114 -0
  73. package/lib/exercises/math/probaStat/unionIntersectionProba.d.ts +11 -0
  74. package/lib/exercises/math/probaStat/unionIntersectionProba.d.ts.map +1 -0
  75. package/lib/exercises/math/probaStat/unionIntersectionProba.js +164 -0
  76. package/lib/exercises/math/python/conditionIfElifElse.d.ts +9 -0
  77. package/lib/exercises/math/python/conditionIfElifElse.d.ts.map +1 -0
  78. package/lib/exercises/math/python/conditionIfElifElse.js +121 -0
  79. package/lib/exercises/math/python/index.d.ts +1 -0
  80. package/lib/exercises/math/python/index.d.ts.map +1 -1
  81. package/lib/exercises/math/python/index.js +1 -0
  82. package/lib/exercises/math/python/pyNestedForLoopExercise.d.ts.map +1 -1
  83. package/lib/exercises/math/python/pyNestedForLoopExercise.js +26 -10
  84. package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts +0 -1
  85. package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts.map +1 -1
  86. package/lib/exercises/math/python/pyWhileLoop1Exercise.js +54 -31
  87. package/lib/exercises/math/python/pythonFunctionTrinom.d.ts.map +1 -1
  88. package/lib/exercises/math/python/pythonFunctionTrinom.js +23 -1
  89. package/lib/exercises/math/python/whileLoop.js +2 -2
  90. package/lib/exercises/math/python/whileLoopCount.js +1 -1
  91. package/lib/exercises/math/sequences/explicitFormulaUsage.js +3 -3
  92. package/lib/exercises/math/sequences/genericSequenceVariations.js +2 -2
  93. package/lib/exercises/math/sets/index.d.ts +2 -0
  94. package/lib/exercises/math/sets/index.d.ts.map +1 -1
  95. package/lib/exercises/math/sets/index.js +2 -0
  96. package/lib/exercises/math/sets/nameOfNumberSets.d.ts +8 -0
  97. package/lib/exercises/math/sets/nameOfNumberSets.d.ts.map +1 -0
  98. package/lib/exercises/math/sets/nameOfNumberSets.js +125 -0
  99. package/lib/exercises/math/sets/subsetsOfKnownSets.d.ts +8 -0
  100. package/lib/exercises/math/sets/subsetsOfKnownSets.d.ts.map +1 -0
  101. package/lib/exercises/math/sets/subsetsOfKnownSets.js +99 -0
  102. package/lib/index.d.ts +61 -6
  103. package/lib/index.d.ts.map +1 -1
  104. package/lib/latexTester.d.ts.map +1 -1
  105. package/lib/latexTester.js +25 -7
  106. package/lib/tests/pdfExo.test.d.ts.map +1 -1
  107. package/lib/tests/pdfExo.test.js +2 -2
  108. package/package.json +1 -1
@@ -0,0 +1,121 @@
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 { random } from "../../../utils/alea/random.js";
5
+ const operations = [
6
+ { name: "+", func: (x, step) => x + step },
7
+ { name: "-", func: (x, step) => x - step },
8
+ { name: "*", func: (x, step) => x * step },
9
+ { name: "//", func: (x, step) => Math.floor(x / step) },
10
+ ];
11
+ const getAnswer = ({ a, b, opName }) => {
12
+ const operation = operations.find((op) => op.name === opName);
13
+ const opresult = operation.func(a, b);
14
+ let result;
15
+ if (opresult < b) {
16
+ result = b;
17
+ }
18
+ else if (opresult === b) {
19
+ result = opresult + b;
20
+ }
21
+ else {
22
+ result = opresult + 1;
23
+ }
24
+ return result.frenchify();
25
+ };
26
+ const getInstruction = ({ a, b, opName }) => `
27
+ Quel sera l'affichage du code suivant ?
28
+ \`\`\`python
29
+ a = ${a}
30
+ b = ${b}
31
+ a = a ${opName} b
32
+ if a < b:
33
+ a = b
34
+ elif a == b:
35
+ a = a + b
36
+ else:
37
+ a = a + 1
38
+ print(a)
39
+ \`\`\`
40
+ `;
41
+ const getHint = ({ opName }) => `Calcule la valeur de $a$ avec $a = a ${opName} b$ puis applique la condition if-elif-else.`;
42
+ const getCorrection = ({ a, b, opName }) => {
43
+ const operation = operations.find((op) => op.name === opName);
44
+ const opresult = operation.func(a, b);
45
+ let branch;
46
+ let finalValue;
47
+ if (opresult < b) {
48
+ branch = `La condition $a < b$ est vraie $(${opresult} < ${b})$, on exécute le bloc if donc : $a = ${b}$.`;
49
+ finalValue = b;
50
+ }
51
+ else if (opresult === b) {
52
+ branch = `La condition $a < b$ est fausse mais la condition $a == b$ est vraie $(${opresult} == ${b})$, on exécute le bloc elif donc : $a = ${opresult} + ${b} = ${opresult + b}$.`;
53
+ finalValue = opresult + b;
54
+ }
55
+ else {
56
+ branch = `Les deux conditions précédentes (If, Elif) sont fausses, on exécute le bloc else donc : $a = ${opresult} + 1 = ${opresult + 1}$.`;
57
+ finalValue = opresult + 1;
58
+ }
59
+ return `On calcule l'opération $a ${opName} b$ ce qui donne : $${a} ${opName} ${b} = ${opresult}$.
60
+
61
+ ${branch}
62
+
63
+ Le résultat final affiché sera : $${finalValue}$.`;
64
+ };
65
+ const getConditionIfElifElseQuestion = () => {
66
+ const targets = ["lt", "eq", "gt"];
67
+ const target = random(targets);
68
+ let a, b, operation, opresult;
69
+ do {
70
+ a = randint(0, 50);
71
+ b = randint(0, 50);
72
+ operation = random(operations);
73
+ opresult = operation.func(a, b);
74
+ } while ((target === "lt" && !(opresult < b)) ||
75
+ (target === "eq" && !(opresult === b)) ||
76
+ (target === "gt" && !(opresult > b)));
77
+ return getQuestionFromIdentifiers({ a, b, opName: operation.name });
78
+ };
79
+ const getQuestionFromIdentifiers = (identifiers) => {
80
+ const question = {
81
+ answer: getAnswer(identifiers),
82
+ hint: getHint(identifiers),
83
+ correction: getCorrection(identifiers),
84
+ instruction: getInstruction(identifiers),
85
+ keys: ["a", "b", "equal"],
86
+ answerFormat: "tex",
87
+ identifiers,
88
+ };
89
+ return question;
90
+ };
91
+ const getPropositions = (n, { answer, a, b, opName }) => {
92
+ const propositions = [];
93
+ const operation = operations.find((op) => op.name === opName);
94
+ const opresult = operation.func(a, b);
95
+ const equalResult = opresult + b;
96
+ const elseResult = opresult + 1;
97
+ addValidProp(propositions, answer);
98
+ tryToAddWrongProp(propositions, a.frenchify());
99
+ tryToAddWrongProp(propositions, b.frenchify());
100
+ tryToAddWrongProp(propositions, equalResult.frenchify());
101
+ tryToAddWrongProp(propositions, elseResult.frenchify());
102
+ while (propositions.length < n) {
103
+ tryToAddWrongProp(propositions, randint(0, 10).frenchify());
104
+ }
105
+ return shuffleProps(propositions, n);
106
+ };
107
+ const isAnswerValid = (ans, { answer }) => ans === answer;
108
+ export const conditionIfElifElse = {
109
+ id: "conditionIfElifElse",
110
+ label: "Condition if-elif-else",
111
+ isSingleStep: true,
112
+ generator: (nb) => getDistinctQuestions(getConditionIfElifElseQuestion, nb),
113
+ qcmTimer: 60,
114
+ freeTimer: 60,
115
+ getPropositions,
116
+ getHint,
117
+ isAnswerValid,
118
+ subject: "Mathématiques",
119
+ getQuestionFromIdentifiers,
120
+ hasHintAndCorrection: true,
121
+ };
@@ -11,4 +11,5 @@ export * from "./variableType.js";
11
11
  export * from "./whileLoopCount.js";
12
12
  export * from "./conditionIfElse.js";
13
13
  export * from "./variableAffectation.js";
14
+ export * from "./conditionIfElifElse.js";
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC"}
@@ -11,3 +11,4 @@ export * from "./variableType.js";
11
11
  export * from "./whileLoopCount.js";
12
12
  export * from "./conditionIfElse.js";
13
13
  export * from "./variableAffectation.js";
14
+ export * from "./conditionIfElifElse.js";
@@ -1 +1 @@
1
- {"version":3,"file":"pyNestedForLoopExercise.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pyNestedForLoopExercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAGX,CAAC;AA+EF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAazD,CAAC"}
1
+ {"version":3,"file":"pyNestedForLoopExercise.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pyNestedForLoopExercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAGX,CAAC;AAuGF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAczD,CAAC"}
@@ -19,18 +19,31 @@ const getAnswer = (identifiers) => {
19
19
  };
20
20
  const getInstruction = (identifiers) => {
21
21
  const { n, p, op } = identifiers;
22
- return `Qu'affichera le programme suivant ?
23
- \`\`\`
24
- s=0
25
- n=${n}
26
- p=${p}
27
- for i in range(1,n+1):
28
- for j in range(1,p+1):
29
- s=s${op}1
30
- print(s)
31
- \`\`\`
22
+ return `Qu'affichera le script en Python suivant ?
23
+ \`\`\`
24
+ s=0
25
+ n=${n}
26
+ p=${p}
27
+ for i in range(1,n+1):
28
+ for j in range(1,p+1):
29
+ s=s${op}1
30
+ print(s)
31
+ \`\`\`
32
32
  `;
33
33
  };
34
+ const getHint = (identifiers) => {
35
+ return `La deuxième boucle for s'exécute entièrement à chaque éxécution de la première boucle.`;
36
+ };
37
+ const getCorrection = (identifiers) => {
38
+ const { n, p, op } = identifiers;
39
+ return `La première boucle for s'exécute $${n}$ fois (car \`range(1, ${n + 1})\` correspond aux nombres de $1$ à $${n}$).
40
+
41
+ A chaque exécution de la première boucle, on exécute la deuxième boucle. Cette deuxième boucle s'exécute $${p}$ fois, à chaque exécution de la première boucle.
42
+
43
+ Au final, il y a donc $${n} \\times ${p} = ${n * p}$ exécutions de la deuxième boucle.
44
+
45
+ A chaque exécution, on ${op === "+" ? "ajoute" : "soustrait"} $1$ à la variable $s$. Au total, on obtient donc $s = ${getAnswer(identifiers)}$.`;
46
+ };
34
47
  const getQuestionFromIdentifiers = (identifiers) => {
35
48
  const question = {
36
49
  answer: getAnswer(identifiers),
@@ -38,6 +51,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
38
51
  keys: [],
39
52
  answerFormat: "tex",
40
53
  identifiers,
54
+ hint: getHint(identifiers),
55
+ correction: getCorrection(identifiers),
41
56
  };
42
57
  return question;
43
58
  };
@@ -77,4 +92,5 @@ export const pyNestedForLoopExercise = {
77
92
  subject: "Mathématiques",
78
93
  getQuestionFromIdentifiers,
79
94
  rebuildIdentifiers,
95
+ hasHintAndCorrection: true,
80
96
  };
@@ -3,7 +3,6 @@ type Identifiers = {
3
3
  a: number;
4
4
  b: number;
5
5
  op: string;
6
- withInput: boolean;
7
6
  };
8
7
  export declare const pyWhileLoop1Exercise: Exercise<Identifiers>;
9
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"pyWhileLoop1Exercise.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pyWhileLoop1Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;CAGpB,CAAC;AAyGF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CActD,CAAC"}
1
+ {"version":3,"file":"pyWhileLoop1Exercise.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pyWhileLoop1Exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;CAKZ,CAAC;AAwIF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAatD,CAAC"}
@@ -2,20 +2,18 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercis
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { numberVEA } from "../../../exercises/vea/numberVEA.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
- import { coinFlip } from "../../../utils/alea/coinFlip.js";
6
5
  import { random } from "../../../utils/alea/random.js";
7
- const rebuildIdentifiers = (oldIds) => {
8
- if (oldIds.op)
9
- return oldIds;
10
- return {
11
- a: oldIds.exercise.a,
12
- b: oldIds.exercise.b,
13
- op: oldIds.exercise.op,
14
- withInput: coinFlip(),
15
- };
16
- };
6
+ // const rebuildIdentifiers: RebuildIdentifiers<Identifiers> = (oldIds) => {
7
+ // if (oldIds.op) return oldIds;
8
+ // return {
9
+ // a: oldIds.exercise.a,
10
+ // b: oldIds.exercise.b,
11
+ // op: oldIds.exercise.op,
12
+ // withInput: coinFlip(),
13
+ // };
14
+ // };
17
15
  const getAnswer = (identifiers) => {
18
- const { a, b, withInput, op } = identifiers;
16
+ const { a, b, op } = identifiers;
19
17
  let n = 1;
20
18
  while (n <= a) {
21
19
  if (op === "+")
@@ -26,18 +24,8 @@ const getAnswer = (identifiers) => {
26
24
  return n.frenchify();
27
25
  };
28
26
  const getInstruction = (identifiers) => {
29
- const { a, b, op, withInput } = identifiers;
30
- if (!withInput)
31
- return `Qu'affichera le programme suivant ?
32
- \`\`\`
33
- a=${a}
34
- n=1
35
- while n<=a:
36
- n=${b}${op}n
37
- print(n)
38
- \`\`\`
39
- `;
40
- return `Qu'affichera le programme suivant, si l'utilisateur entre $${a}$ ?
27
+ const { a, b, op } = identifiers;
28
+ return `Qu'affichera le script Python suivant, si l'utilisateur entre $${a}$ ?
41
29
  \`\`\`
42
30
  a=input("Entrez un entier naturel non nul.")
43
31
  a=int(a)
@@ -48,6 +36,41 @@ const getInstruction = (identifiers) => {
48
36
  \`\`\`
49
37
  `;
50
38
  };
39
+ const operations = [
40
+ { name: "+", func: (x, step) => x + step },
41
+ { name: "*", func: (x, step) => x * step },
42
+ ];
43
+ const getHint = (identifiers) => {
44
+ const { a, b, op } = identifiers;
45
+ const operation = operations.find((o) => o.name === op);
46
+ return `La boucle s'exécute tant que la condition $n \\leq ${a}$ est vraie. À chaque itération, $n$ devient égal à $n ${operation.name} ${b}$.`;
47
+ };
48
+ const getCorrection = (identifiers) => {
49
+ const { a, b, op } = identifiers;
50
+ const operation = operations.find((o) => o.name === op);
51
+ let n = 1;
52
+ let count = 0;
53
+ let allValues = [];
54
+ while (n <= a) {
55
+ allValues.push(n.frenchify());
56
+ n = operation.func(n, b);
57
+ count++;
58
+ }
59
+ allValues.push(n.frenchify());
60
+ return `Puisque l'utilisateur entre $${a}$, la variable $a$ prend la valeur $${a}$.
61
+
62
+ On commence avec $n = 1$ et à chaque itération on effectue l'opération $n = n ${operation.name} ${b}$. La boucle while $n \\leq a$ s'exécute tant que $n$ est inférieur ou égal à $${a}$.
63
+
64
+ $n$ prend donc les valeurs successives suivantes :
65
+
66
+ $$
67
+ ${allValues.join("\\rightarrow ")}
68
+ $$
69
+
70
+ La boucle s'arrête alors car $${allValues[allValues.length - 1]} > ${a}$.
71
+
72
+ Le programme affichera donc $${n.frenchify()}$.`;
73
+ };
51
74
  const getQuestionFromIdentifiers = (identifiers) => {
52
75
  const question = {
53
76
  answer: getAnswer(identifiers),
@@ -55,6 +78,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
55
78
  keys: [],
56
79
  answerFormat: "tex",
57
80
  identifiers,
81
+ hint: getHint(identifiers),
82
+ correction: getCorrection(identifiers),
58
83
  };
59
84
  return question;
60
85
  };
@@ -72,18 +97,17 @@ const getPyWhileLoop1ExerciseQuestion = () => {
72
97
  const nbIter = randint(2, randCombination.maxIter + 1);
73
98
  const aA = op === "+" ? Math.ceil(b * nbIter) : Math.pow(b, nbIter);
74
99
  const a = randint(aA / b, aA);
75
- const withInput = coinFlip();
76
- const identifiers = { a, b, op, withInput };
100
+ const identifiers = { a, b, op };
77
101
  return getQuestionFromIdentifiers(identifiers);
78
102
  };
79
- const getPropositions = (n, { answer, a, b, withInput, op }) => {
103
+ const getPropositions = (n, { answer, a, b, op }) => {
80
104
  const propositions = [];
81
105
  addValidProp(propositions, answer);
82
106
  const firstProposition = op === "*" ? +answer * b : +answer + b;
83
107
  tryToAddWrongProp(propositions, firstProposition + "");
84
108
  const secondProposition = op === "*" ? +answer / b : +answer - b;
85
109
  tryToAddWrongProp(propositions, secondProposition + "");
86
- const correctAnswer = Number(getAnswer({ a, b, withInput, op }));
110
+ const correctAnswer = Number(getAnswer({ a, b, op }));
87
111
  while (propositions.length < n) {
88
112
  tryToAddWrongProp(propositions, randint(correctAnswer - 11, correctAnswer + 11, [correctAnswer, 0]) + "");
89
113
  }
@@ -94,7 +118,7 @@ const isAnswerValid = (ans, { answer, ...identifiers }) => {
94
118
  };
95
119
  export const pyWhileLoop1Exercise = {
96
120
  id: "pyWhileLoop1Exercise",
97
- label: "Boucles while $1$",
121
+ label: "Boucle while en Python (avec entrée utilisateur)",
98
122
  isSingleStep: true,
99
123
  generator: (nb) => getDistinctQuestions(getPyWhileLoop1ExerciseQuestion, nb),
100
124
  qcmTimer: 60,
@@ -103,6 +127,5 @@ export const pyWhileLoop1Exercise = {
103
127
  isAnswerValid,
104
128
  subject: "Mathématiques",
105
129
  getQuestionFromIdentifiers,
106
- rebuildIdentifiers,
107
- // hasHintAndCorrection: true,
130
+ hasHintAndCorrection: true,
108
131
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pythonFunctionTrinom.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonFunctionTrinom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAsEF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAYtD,CAAC"}
1
+ {"version":3,"file":"pythonFunctionTrinom.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/python/pythonFunctionTrinom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA8FF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAatD,CAAC"}
@@ -4,12 +4,13 @@ import { Trinom, TrinomConstructor } from "../../../math/polynomials/trinom.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  import { EqualNode } from "../../../tree/nodes/equations/equalNode.js";
6
6
  import { VariableNode } from "../../../tree/nodes/variables/variableNode.js";
7
+ import { alignTex } from "../../../utils/latex/alignTex.js";
7
8
  const getInstruction = (identifiers) => {
8
9
  const { x, trinom } = identifiers;
9
10
  const tri = new Trinom(trinom[0], trinom[1], trinom[2]);
10
11
  const image = tri.calculate(x);
11
12
  const equation = tri.toPython();
12
- return `Qu'affichera le programme suivant ?
13
+ return `Qu'affichera le script en Python suivant ?
13
14
  \`\`\`
14
15
  def f(x):
15
16
  y = ${equation}
@@ -19,6 +20,24 @@ print(y)
19
20
  \`\`\`
20
21
  `;
21
22
  };
23
+ const getHint = (identifiers) => {
24
+ return `En Python, l'opération ** signifie "puissance". `;
25
+ };
26
+ const getCorrection = (identifiers) => {
27
+ const { image, trinom, x } = identifiers;
28
+ const tri = new Trinom(trinom[0], trinom[1], trinom[2]);
29
+ return `On appelle la fonction $f$ avec comme argument $x=${x}$.
30
+
31
+ Le calcul effectué par la fonction est donc :
32
+
33
+ ${alignTex([
34
+ ["y", "=", tri.toTree().toDetailedEvaluation({ x: x.toTree() }).toTex()],
35
+ ["", "=", getAnswer(identifiers)],
36
+ ])}
37
+
38
+ Le script affiche ensuite la valeur de $y$ : il affichera donc $${getAnswer(identifiers)}$.
39
+ `;
40
+ };
22
41
  const getAnswer = (identifiers) => {
23
42
  const { image } = identifiers;
24
43
  return image.frenchify();
@@ -37,6 +56,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
37
56
  keys: ["f", "x", "y", "equal"],
38
57
  answerFormat: "tex",
39
58
  identifiers,
59
+ hint: getHint(identifiers),
60
+ correction: getCorrection(identifiers),
40
61
  };
41
62
  return question;
42
63
  };
@@ -70,4 +91,5 @@ export const pythonFunctionTrinom = {
70
91
  isAnswerValid,
71
92
  subject: "Mathématiques",
72
93
  getQuestionFromIdentifiers,
94
+ hasHintAndCorrection: true,
73
95
  };
@@ -52,7 +52,7 @@ $$
52
52
  ${allValues.join("\\rightarrow ")}
53
53
  $$
54
54
 
55
- La boucle s'arrêtte alors car $${allValues[allValues.length - 1]} > ${a}$.
55
+ La boucle s'arrête alors car $${allValues[allValues.length - 1]} > ${a}$.
56
56
 
57
57
  Le programme affichera donc $${n.frenchify()}$.`;
58
58
  };
@@ -105,7 +105,7 @@ const isAnswerValid = (ans, { answer }) => {
105
105
  };
106
106
  export const whileLoop = {
107
107
  id: "whileLoop",
108
- label: "Boucle while $2$ (Python)",
108
+ label: "Boucle while en Python",
109
109
  isSingleStep: true,
110
110
  generator: (nb) => getDistinctQuestions(getWhileLoopQuestion, nb),
111
111
  qcmTimer: 60,
@@ -43,7 +43,7 @@ $$
43
43
  ${allValues.join("\\rightarrow ")}
44
44
  $$
45
45
 
46
- La boucle s'arrêtte alors car $${allValues[allValues.length - 1]} < ${threshold}$.
46
+ La boucle s'arrête alors car $${allValues[allValues.length - 1]} < ${threshold}$.
47
47
 
48
48
  La boucle s'exécute donc $${count}$ fois.`;
49
49
  };
@@ -4,7 +4,7 @@ import { Polynomial, PolynomialConstructor, } from "../../../math/polynomials/po
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  const getInstruction = (identifiers) => {
6
6
  const { rank, coeffs } = identifiers;
7
- const u = new Polynomial(coeffs);
7
+ const u = new Polynomial(coeffs, "n");
8
8
  return `Soit $u$ la suite définie pour tout $n\\geq 0$ par
9
9
 
10
10
  $$
@@ -15,7 +15,7 @@ Calculer $u_${rank}$.`;
15
15
  };
16
16
  const getAnswer = (identifiers) => {
17
17
  const { rank, coeffs } = identifiers;
18
- const u = new Polynomial(coeffs);
18
+ const u = new Polynomial(coeffs, "n");
19
19
  const answer = u.calculate(rank) + "";
20
20
  return answer;
21
21
  };
@@ -37,7 +37,7 @@ const getExplicitFormulaUsageQuestion = () => {
37
37
  };
38
38
  const getPropositions = (n, { answer, rank, coeffs }) => {
39
39
  const propositions = [];
40
- const u = new Polynomial(coeffs);
40
+ const u = new Polynomial(coeffs, "n");
41
41
  addValidProp(propositions, answer);
42
42
  tryToAddWrongProp(propositions, u.calculate(rank - 1) + "");
43
43
  tryToAddWrongProp(propositions, u.calculate(rank + 1) + "");
@@ -4,14 +4,14 @@ import { Polynomial, PolynomialConstructor, } from "../../../math/polynomials/po
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
5
  const getInstruction = (identifiers) => {
6
6
  const { coeffs } = identifiers;
7
- const u = new Polynomial(coeffs);
7
+ const u = new Polynomial(coeffs, "n");
8
8
  return `Soit $u$ la suite définie par $u_n = ${u
9
9
  .toTree()
10
10
  .toTex()}$. Quel est le sens de variations de $u$ ?`;
11
11
  };
12
12
  const getAnswer = (identifiers) => {
13
13
  const { coeffs } = identifiers;
14
- const u = new Polynomial(coeffs);
14
+ const u = new Polynomial(coeffs, "n");
15
15
  const [b, a] = u.coefficients.slice(1);
16
16
  const root = Math.ceil((-a - b) / (2 * a));
17
17
  const answer = root <= 0
@@ -1,3 +1,5 @@
1
1
  export * from "./intervals/index.js";
2
2
  export * from "./setBelonging.js";
3
+ export * from "./nameOfNumberSets.js";
4
+ export * from "./subsetsOfKnownSets.js";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sets/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sets/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export * from "./intervals/index.js";
2
2
  export * from "./setBelonging.js";
3
+ export * from "./nameOfNumberSets.js";
4
+ export * from "./subsetsOfKnownSets.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ isQuestionAboutNotation: boolean;
4
+ caseNumber: number;
5
+ };
6
+ export declare const nameOfNumberSets: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=nameOfNumberSets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nameOfNumberSets.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sets/nameOfNumberSets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAMrC,KAAK,WAAW,GAAG;IACjB,uBAAuB,EAAE,OAAO,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAgJF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAgBlD,CAAC"}
@@ -0,0 +1,125 @@
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 { coinFlip } from "../../../utils/alea/coinFlip.js";
5
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
6
+ const getPropositions = (n, { answer, isQuestionAboutNotation }) => {
7
+ const propositions = [];
8
+ if (isQuestionAboutNotation) {
9
+ addValidProp(propositions, answer);
10
+ tryToAddWrongProp(propositions, "\\mathbb{R}");
11
+ tryToAddWrongProp(propositions, "\\mathbb{Q}");
12
+ tryToAddWrongProp(propositions, "\\mathbb{N}");
13
+ tryToAddWrongProp(propositions, "\\mathbb{Z}");
14
+ tryToAddWrongProp(propositions, "\\mathbb{D}");
15
+ }
16
+ else {
17
+ addValidProp(propositions, answer, "raw");
18
+ tryToAddWrongProp(propositions, "nombres réels", "raw");
19
+ tryToAddWrongProp(propositions, "nombres rationnels", "raw");
20
+ tryToAddWrongProp(propositions, "nombres entiers naturels", "raw");
21
+ tryToAddWrongProp(propositions, "nombres entiers relatifs", "raw");
22
+ tryToAddWrongProp(propositions, "nombres décimaux", "raw");
23
+ }
24
+ return shuffleProps(propositions, n);
25
+ };
26
+ const getHint = (identifiers) => {
27
+ return `On a les inclusions suivantes :
28
+
29
+ $$
30
+ \\mathbb{N}\\subset \\mathbb{Z}\\subset \\mathbb{D}\\subset \\mathbb{Q}\\subset \\mathbb{R}
31
+ $$`;
32
+ };
33
+ const getCorrection = (identifiers) => {
34
+ const { caseNumber, isQuestionAboutNotation } = identifiers;
35
+ if (isQuestionAboutNotation)
36
+ return `L'ensemble des ${caseNumberToSetName(!isQuestionAboutNotation, caseNumber)} se note : $${caseNumberToSetName(isQuestionAboutNotation, caseNumber)}$.`;
37
+ return `$${caseNumberToSetName(!isQuestionAboutNotation, caseNumber)}$ est l'ensemble des ${caseNumberToSetName(isQuestionAboutNotation, caseNumber)}.`;
38
+ };
39
+ const caseNumberToSetName = (isQuestionAboutNotation, caseNumber) => {
40
+ if (isQuestionAboutNotation) {
41
+ switch (caseNumber) {
42
+ case 0:
43
+ return "\\mathbb{R}";
44
+ case 1:
45
+ return "\\mathbb{Q}";
46
+ case 2:
47
+ return "\\mathbb{N}";
48
+ case 3:
49
+ return "\\mathbb{Z}";
50
+ case 4:
51
+ default:
52
+ return "\\mathbb{D}";
53
+ }
54
+ }
55
+ else {
56
+ switch (caseNumber) {
57
+ case 0:
58
+ return "nombres réels";
59
+ case 1:
60
+ return "nombres rationnels";
61
+ case 2:
62
+ return "nombres entiers naturels";
63
+ case 3:
64
+ return "nombres entiers relatifs";
65
+ case 4:
66
+ default:
67
+ return "nombres décimaux";
68
+ }
69
+ }
70
+ };
71
+ const getAnswer = ({ isQuestionAboutNotation, caseNumber, }) => {
72
+ return caseNumberToSetName(isQuestionAboutNotation, caseNumber);
73
+ };
74
+ const getInstruction = ({ isQuestionAboutNotation, caseNumber, }) => {
75
+ if (isQuestionAboutNotation) {
76
+ return `Comment se note l'ensemble des ${caseNumberToSetName(!isQuestionAboutNotation, caseNumber)} ?`;
77
+ }
78
+ else {
79
+ return `$${caseNumberToSetName(!isQuestionAboutNotation, caseNumber)}$ est l'ensemble des ...`;
80
+ }
81
+ };
82
+ const getKeys = (identifiers) => {
83
+ return ["naturals", "integers", "rationals", "decimals", "reals"];
84
+ };
85
+ const isAnswerValid = (ans, { answer }) => {
86
+ try {
87
+ return ans === answer;
88
+ }
89
+ catch (err) {
90
+ return handleVEAError(err);
91
+ }
92
+ };
93
+ const getNameOfNumberSetsQuestion = (ops) => {
94
+ const caseNumber = randint(0, 5);
95
+ const isQuestionAboutNotation = coinFlip();
96
+ const identifiers = { caseNumber, isQuestionAboutNotation };
97
+ return getQuestionFromIdentifiers(identifiers);
98
+ };
99
+ const getQuestionFromIdentifiers = (identifiers) => {
100
+ return {
101
+ answer: getAnswer(identifiers),
102
+ instruction: getInstruction(identifiers),
103
+ keys: getKeys(identifiers),
104
+ answerFormat: identifiers.isQuestionAboutNotation ? "tex" : "raw",
105
+ identifiers,
106
+ hint: getHint(identifiers),
107
+ correction: getCorrection(identifiers),
108
+ };
109
+ };
110
+ export const nameOfNumberSets = {
111
+ id: "nameOfNumberSets",
112
+ label: "Nommer les ensembles des nombres",
113
+ answerType: "QCU",
114
+ isSingleStep: true,
115
+ generator: (nb, opts) => getDistinctQuestions(() => getNameOfNumberSetsQuestion(opts), 5),
116
+ qcmTimer: 60,
117
+ freeTimer: 60,
118
+ getPropositions,
119
+ isAnswerValid,
120
+ subject: "Mathématiques",
121
+ getInstruction,
122
+ getAnswer,
123
+ getQuestionFromIdentifiers,
124
+ hasHintAndCorrection: true,
125
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ subset: number;
4
+ set: number;
5
+ };
6
+ export declare const subsetsOfKnownSets: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=subsetsOfKnownSets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subsetsOfKnownSets.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/sets/subsetsOfKnownSets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAIrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAiGF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,WAAW,CAiBpD,CAAC"}