math-exercises 3.0.151 → 3.0.153

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 (199) hide show
  1. package/lib/exercises/exercise.d.ts +7 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.d.ts +5 -1
  4. package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.d.ts.map +1 -1
  5. package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.js +92 -38
  6. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
  7. package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +5 -1
  8. package/lib/exercises/math/calcul/proportionality/isTableProportional.d.ts.map +1 -1
  9. package/lib/exercises/math/calcul/proportionality/isTableProportional.js +7 -1
  10. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
  11. package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +5 -1
  12. package/lib/exercises/math/calcul/proportionality/proportionalityTable.d.ts.map +1 -1
  13. package/lib/exercises/math/calcul/proportionality/proportionalityTable.js +5 -1
  14. package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.js +8 -2
  16. package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -1
  17. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/equation/index.js +1 -1
  19. package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.d.ts +10 -0
  20. package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.d.ts.map +1 -0
  21. package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.js +183 -0
  22. package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.d.ts +10 -0
  23. package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.d.ts.map +1 -0
  24. package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.js +173 -0
  25. package/lib/exercises/math/calculLitteral/equation/square/index.d.ts +3 -0
  26. package/lib/exercises/math/calculLitteral/equation/square/index.d.ts.map +1 -0
  27. package/lib/exercises/math/calculLitteral/equation/square/index.js +2 -0
  28. package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.d.ts.map +1 -1
  29. package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.js +7 -0
  30. package/lib/exercises/math/dataRepresentations/tableReading.d.ts.map +1 -1
  31. package/lib/exercises/math/dataRepresentations/tableReading.js +7 -0
  32. package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -1
  33. package/lib/exercises/math/functions/affines/affineAdjustment.js +7 -1
  34. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -1
  35. package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +7 -1
  36. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -1
  37. package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +7 -1
  38. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts.map +1 -1
  39. package/lib/exercises/math/functions/basics/inverseImageFunctionTable.js +7 -1
  40. package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts.map +1 -1
  41. package/lib/exercises/math/functions/basics/placePointsFromValueTable.js +7 -0
  42. package/lib/exercises/math/functions/sqrt/squareRootCalculation.d.ts.map +1 -1
  43. package/lib/exercises/math/functions/sqrt/squareRootCalculation.js +4 -2
  44. package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.d.ts +15 -0
  45. package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.d.ts.map +1 -0
  46. package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.js +301 -0
  47. package/lib/exercises/math/geometry/euclidian/index.d.ts +7 -0
  48. package/lib/exercises/math/geometry/euclidian/index.d.ts.map +1 -1
  49. package/lib/exercises/math/geometry/euclidian/index.js +7 -0
  50. package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.d.ts +21 -0
  51. package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.d.ts.map +1 -0
  52. package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.js +406 -0
  53. package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.d.ts +18 -0
  54. package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.d.ts.map +1 -0
  55. package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.js +315 -0
  56. package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.d.ts +20 -0
  57. package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.d.ts.map +1 -0
  58. package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.js +314 -0
  59. package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.d.ts +18 -0
  60. package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.d.ts.map +1 -0
  61. package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.js +387 -0
  62. package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.d.ts +18 -0
  63. package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.d.ts.map +1 -0
  64. package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.js +309 -0
  65. package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.d.ts +17 -0
  66. package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.d.ts.map +1 -0
  67. package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.js +301 -0
  68. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.d.ts.map +1 -1
  69. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.js +22 -8
  70. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.d.ts +11 -0
  71. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.d.ts.map +1 -0
  72. package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.js +169 -0
  73. package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +2 -0
  74. package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -1
  75. package/lib/exercises/math/geometry/euclidianConstructions/index.js +2 -0
  76. package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.d.ts +16 -0
  77. package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.d.ts.map +1 -0
  78. package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.js +309 -0
  79. package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.d.ts.map +1 -1
  80. package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.js +7 -0
  81. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts.map +1 -1
  82. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.js +7 -0
  83. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.d.ts +9 -0
  84. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.d.ts.map +1 -0
  85. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.js +120 -0
  86. package/lib/exercises/math/probaStat/basicProbas/index.d.ts +2 -0
  87. package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
  88. package/lib/exercises/math/probaStat/basicProbas/index.js +2 -0
  89. package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts +12 -0
  90. package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts.map +1 -0
  91. package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.js +374 -0
  92. package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
  93. package/lib/exercises/math/probaStat/probaFromTableNoContext.js +7 -0
  94. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  95. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +7 -0
  96. package/lib/exercises/math/probaStat/stats1var/averageWithClasses.d.ts +9 -0
  97. package/lib/exercises/math/probaStat/stats1var/averageWithClasses.d.ts.map +1 -0
  98. package/lib/exercises/math/probaStat/stats1var/averageWithClasses.js +140 -0
  99. package/lib/exercises/math/probaStat/stats1var/averageWithTable.d.ts.map +1 -1
  100. package/lib/exercises/math/probaStat/stats1var/averageWithTable.js +7 -1
  101. package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.d.ts +8 -0
  102. package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.d.ts.map +1 -0
  103. package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.js +113 -0
  104. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts.map +1 -1
  105. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.js +7 -0
  106. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts.map +1 -1
  107. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +7 -0
  108. package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts.map +1 -1
  109. package/lib/exercises/math/probaStat/stats1var/etendueTable.js +7 -1
  110. package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.d.ts.map +1 -1
  111. package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.js +7 -0
  112. package/lib/exercises/math/probaStat/stats1var/index.d.ts +2 -0
  113. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  114. package/lib/exercises/math/probaStat/stats1var/index.js +2 -0
  115. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts.map +1 -1
  116. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +5 -1
  117. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.d.ts.map +1 -1
  118. package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +7 -0
  119. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts +2 -0
  120. package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
  121. package/lib/exercises/math/probaStat/stats1var/medianWithList.js +67 -14
  122. package/lib/exercises/math/probaStat/stats1var/medianWithTable.d.ts.map +1 -1
  123. package/lib/exercises/math/probaStat/stats1var/medianWithTable.js +7 -1
  124. package/lib/exercises/math/probaStat/stats1var/quartiles.d.ts.map +1 -1
  125. package/lib/exercises/math/probaStat/stats1var/quartiles.js +7 -1
  126. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts.map +1 -1
  127. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +5 -1
  128. package/lib/exercises/math/probaStat/stats1var/varianceTable.d.ts.map +1 -1
  129. package/lib/exercises/math/probaStat/stats1var/varianceTable.js +5 -1
  130. package/lib/exercises/math/probaStat/stats2var/averagePoint.d.ts.map +1 -1
  131. package/lib/exercises/math/probaStat/stats2var/averagePoint.js +7 -1
  132. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.d.ts +7 -0
  133. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.d.ts.map +1 -0
  134. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.js +171 -0
  135. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.d.ts +7 -0
  136. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.d.ts.map +1 -0
  137. package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.js +155 -0
  138. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts +3 -0
  139. package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts.map +1 -1
  140. package/lib/exercises/math/probaStat/twoStepExperiments/index.js +3 -0
  141. package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.d.ts +7 -0
  142. package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.d.ts.map +1 -0
  143. package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.js +189 -0
  144. package/lib/exercises/math/scratch/index.d.ts +3 -0
  145. package/lib/exercises/math/scratch/index.d.ts.map +1 -1
  146. package/lib/exercises/math/scratch/index.js +3 -0
  147. package/lib/exercises/math/scratch/scratchListElemAtIndex.d.ts +13 -0
  148. package/lib/exercises/math/scratch/scratchListElemAtIndex.d.ts.map +1 -0
  149. package/lib/exercises/math/scratch/scratchListElemAtIndex.js +189 -0
  150. package/lib/exercises/math/scratch/scratchListElemAtIndex2.d.ts +23 -0
  151. package/lib/exercises/math/scratch/scratchListElemAtIndex2.d.ts.map +1 -0
  152. package/lib/exercises/math/scratch/scratchListElemAtIndex2.js +207 -0
  153. package/lib/exercises/math/scratch/scratchListFilter.d.ts +13 -0
  154. package/lib/exercises/math/scratch/scratchListFilter.d.ts.map +1 -0
  155. package/lib/exercises/math/scratch/scratchListFilter.js +397 -0
  156. package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.d.ts +14 -0
  157. package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.d.ts.map +1 -0
  158. package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.js +347 -0
  159. package/lib/exercises/math/spaceGeometry/basis/index.d.ts +1 -0
  160. package/lib/exercises/math/spaceGeometry/basis/index.d.ts.map +1 -1
  161. package/lib/exercises/math/spaceGeometry/basis/index.js +1 -0
  162. package/lib/exercises/math/spaceGeometry/index.d.ts +2 -0
  163. package/lib/exercises/math/spaceGeometry/index.d.ts.map +1 -1
  164. package/lib/exercises/math/spaceGeometry/index.js +2 -0
  165. package/lib/exercises/math/spaceGeometry/sections/areaOfConeSection.js +3 -3
  166. package/lib/exercises/math/spaceGeometry/solids/index.d.ts +3 -0
  167. package/lib/exercises/math/spaceGeometry/solids/index.d.ts.map +1 -0
  168. package/lib/exercises/math/spaceGeometry/solids/index.js +2 -0
  169. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.d.ts +15 -0
  170. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.d.ts.map +1 -0
  171. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.js +440 -0
  172. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.d.ts +11 -0
  173. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.d.ts.map +1 -0
  174. package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.js +1089 -0
  175. package/lib/exercises/math/spaceGeometry/sphere/index.d.ts +3 -0
  176. package/lib/exercises/math/spaceGeometry/sphere/index.d.ts.map +1 -0
  177. package/lib/exercises/math/spaceGeometry/sphere/index.js +2 -0
  178. package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.d.ts +9 -0
  179. package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.d.ts.map +1 -0
  180. package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.js +127 -0
  181. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.d.ts +14 -0
  182. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.d.ts.map +1 -0
  183. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.js +390 -0
  184. package/lib/geogebra/geogebraConstructor.d.ts +2 -0
  185. package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
  186. package/lib/geogebra/geogebraConstructor.js +6 -0
  187. package/lib/index.d.ts +198 -6
  188. package/lib/index.d.ts.map +1 -1
  189. package/lib/math/geometry/point.d.ts +6 -0
  190. package/lib/math/geometry/point.d.ts.map +1 -1
  191. package/lib/math/geometry/point.js +28 -0
  192. package/lib/tree/nodes/equations/equalNode.d.ts +1 -1
  193. package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
  194. package/lib/tree/nodes/equations/equalNode.js +0 -1
  195. package/lib/tree/utilities/nodeSimplifier.d.ts +1 -1
  196. package/lib/utils/arrays/arrayZip.d.ts +2 -0
  197. package/lib/utils/arrays/arrayZip.d.ts.map +1 -0
  198. package/lib/utils/arrays/arrayZip.js +12 -0
  199. package/package.json +1 -1
@@ -0,0 +1,397 @@
1
+ import { addValidProp, tryToAddWrongProp, shuffleProps, } 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 { random } from "../../../utils/alea/random.js";
6
+ import { mdTable } from "../../../utils/markdown/mdTable.js";
7
+ const getInstruction = (identifiers) => {
8
+ const { l1Start, randCounter, randX, randCondition, isGreaterCond, k, randListAdd, } = identifiers;
9
+ const cStart = (() => {
10
+ switch (randCounter) {
11
+ case 0:
12
+ case 3:
13
+ return 0;
14
+ case 1:
15
+ case 2:
16
+ return 1;
17
+ case 4:
18
+ case 5:
19
+ return l1Start.length;
20
+ }
21
+ })();
22
+ //special care with newline is needed
23
+ const strScratchProgram = `quand @greenFlag est cliqué
24
+ mettre [c v] à [${cStart}]
25
+ répéter (longueur de [l1 v]) fois ${(() => {
26
+ switch (randCounter) {
27
+ case 0:
28
+ case 2:
29
+ return `
30
+ mettre [c v] à ((c) + [1])`;
31
+ default:
32
+ return "";
33
+ }
34
+ })()}
35
+ ${(() => {
36
+ switch (randX) {
37
+ case 0:
38
+ return "mettre [x v] à (élément (c) de [l1 v])";
39
+ case 1:
40
+ return "mettre [x v] à (c)";
41
+ case 2:
42
+ return "mettre [x v] à (longueur de [l1 v])";
43
+ case 3:
44
+ return "mettre [x v] à (élément [1] de [l1 v])";
45
+ default:
46
+ throw new Error("unsupported randX: " + randX);
47
+ }
48
+ })()}
49
+ ${(() => {
50
+ switch (randCondition) {
51
+ case 0:
52
+ return `si <(x) ${isGreaterCond ? ">" : "\\<"} [${k}]> alors`;
53
+ case 1:
54
+ return `si <(c) ${isGreaterCond ? ">" : "\\<"} [${k}]> alors`;
55
+ case 2:
56
+ return `si <(x) ${isGreaterCond ? ">" : "\\<"} (c)> alors`;
57
+ default:
58
+ throw new Error("unsupported randCondition: " + randCondition);
59
+ }
60
+ })()}
61
+ ${(() => {
62
+ switch (randListAdd) {
63
+ case 0:
64
+ return `ajouter (x) à [l2 v]`;
65
+ case 1:
66
+ return `ajouter (c) à [l2 v]`;
67
+ default:
68
+ throw new Error("unsupported randListAdd: " + randListAdd);
69
+ }
70
+ })()}
71
+ fin ${(() => {
72
+ switch (randCounter) {
73
+ case 1:
74
+ return `
75
+ mettre [c v] à ((c) + [1])`;
76
+ case 4:
77
+ return `
78
+ mettre [c v] à ((c) - [1])`;
79
+ default:
80
+ return "";
81
+ }
82
+ })()}
83
+ fin
84
+ dire (l2)`;
85
+ return `On considère le programme Scratch ci-dessous :
86
+
87
+ <svg id="scratch">
88
+ ${strScratchProgram}
89
+ </svg>
90
+
91
+ Si, initialement, la liste $l1$ vaut $[${l1Start.join(";")}]$ et que la liste $l2$ est vide, que va dire le lutin suite à l'exécution du programme ?`;
92
+ };
93
+ const getFunctionForScratchProgram = (identifiers) => {
94
+ const { l1Start, randCounter, randX, randCondition, isGreaterCond, k, randListAdd, } = identifiers;
95
+ const cStart = (() => {
96
+ switch (randCounter) {
97
+ case 0:
98
+ case 3:
99
+ return 0;
100
+ case 1:
101
+ case 2:
102
+ return 1;
103
+ case 4:
104
+ case 5:
105
+ return l1Start.length;
106
+ }
107
+ })();
108
+ return (_) => {
109
+ const outDict = {};
110
+ //init
111
+ const l1 = [...l1Start];
112
+ let c = cStart;
113
+ let x;
114
+ const l2 = [];
115
+ outDict[0] = {
116
+ c,
117
+ l2: [...l2],
118
+ };
119
+ function listAdd(x, c, l2) {
120
+ switch (randListAdd) {
121
+ case 0:
122
+ {
123
+ l2.push(x);
124
+ }
125
+ break;
126
+ case 1:
127
+ {
128
+ l2.push(c);
129
+ }
130
+ break;
131
+ default:
132
+ break;
133
+ }
134
+ }
135
+ //loop
136
+ let counter = 0;
137
+ l1.forEach(() => {
138
+ counter++;
139
+ switch (randCounter) {
140
+ case 0:
141
+ case 2:
142
+ {
143
+ c = c + 1;
144
+ }
145
+ break;
146
+ default:
147
+ break;
148
+ }
149
+ switch (randX) {
150
+ case 0:
151
+ {
152
+ x = l1[c - 1];
153
+ }
154
+ break;
155
+ case 1:
156
+ {
157
+ x = c;
158
+ }
159
+ break;
160
+ case 2:
161
+ {
162
+ x = l1.length;
163
+ }
164
+ break;
165
+ case 3:
166
+ {
167
+ x = l1[0];
168
+ }
169
+ break;
170
+ default:
171
+ break;
172
+ }
173
+ switch (randCondition) {
174
+ case 0:
175
+ {
176
+ if (isGreaterCond ? x > k : x < k) {
177
+ listAdd(x, c, l2);
178
+ }
179
+ }
180
+ break;
181
+ case 1:
182
+ {
183
+ if (isGreaterCond ? c > k : c < k) {
184
+ listAdd(x, c, l2);
185
+ }
186
+ }
187
+ break;
188
+ case 2:
189
+ {
190
+ if (isGreaterCond ? x > c : x < c) {
191
+ listAdd(x, c, l2);
192
+ }
193
+ }
194
+ break;
195
+ default:
196
+ return "";
197
+ }
198
+ switch (randCounter) {
199
+ case 1:
200
+ {
201
+ c = c + 1;
202
+ }
203
+ break;
204
+ case 4:
205
+ {
206
+ c = c - 1;
207
+ }
208
+ break;
209
+ default:
210
+ break;
211
+ }
212
+ //store step dict
213
+ outDict[counter] = {
214
+ c,
215
+ x,
216
+ l2: [...l2],
217
+ };
218
+ });
219
+ //convenience: store last step in -1
220
+ outDict[-1] = outDict[Math.max(...Object.keys(outDict).map((k) => +k))];
221
+ return outDict;
222
+ };
223
+ };
224
+ const getAnswer = (identifiers) => {
225
+ const l2 = getFunctionForScratchProgram(identifiers)(identifiers)[-1].l2;
226
+ return l2.map((v) => `${v.frenchify()}`).join(" \\ ");
227
+ };
228
+ const getHint = () => {
229
+ return `La liste $l2$ change au cours de l'exécution du programme.
230
+
231
+ À chaque itération, détermine comment la liste évolue.`;
232
+ };
233
+ const getCorrection = (identifiers) => {
234
+ const dictSteps = getFunctionForScratchProgram(identifiers)(identifiers);
235
+ const maxLength = dictSteps[-1].l2.length;
236
+ return `Voici l'évolution de la liste $l2$ au fil des instructions.
237
+
238
+ ${mdTable([
239
+ (() => {
240
+ const l2 = dictSteps[0].l2;
241
+ return [
242
+ "\\text{Initialement: vide}",
243
+ ...[...Array(maxLength).keys()].map((i) => l2.length > i ? `${l2[i]}` : "\\text{}"),
244
+ ];
245
+ })(),
246
+ ...Object.entries(dictSteps)
247
+ .filter(([k, _]) => +k > 0)
248
+ .map(([i, stepDict]) => {
249
+ const l2 = stepDict.l2;
250
+ return [
251
+ `\\text{Après l'itération ${i}}`,
252
+ ...[...Array(maxLength).keys()].map((i) => l2.length > i ? `${l2[i]}` : "\\text{}"),
253
+ ];
254
+ }),
255
+ ], true)}
256
+
257
+ À la fin de l'exécution du programme, $l2$ vaut donc $[${dictSteps[-1].l2.join(";")}]$.
258
+
259
+ Le lutin dira : "${dictSteps[-1].l2.map((v) => `$${v}$`).join(" ")}".`;
260
+ };
261
+ const getPropositions = (n, { answer, ...identifiers }) => {
262
+ const { l1Start } = identifiers;
263
+ const propositions = [];
264
+ addValidProp(propositions, answer);
265
+ let arrList = [];
266
+ let arrListFoundation = [];
267
+ {
268
+ //variations on randListAdd
269
+ [0, 1, 2].forEach((randListAdd) => {
270
+ const identifiersVariation = Object.assign({}, identifiers, {
271
+ randListAdd,
272
+ });
273
+ const l2 = getFunctionForScratchProgram(identifiersVariation)(identifiersVariation)[-1].l2;
274
+ arrListFoundation.push(l2);
275
+ });
276
+ //l1
277
+ {
278
+ arrListFoundation.push(l1Start);
279
+ }
280
+ //variations on randX
281
+ {
282
+ [0, 1, 2, 3].forEach((randX) => {
283
+ const identifiersVariation = Object.assign({}, identifiers, {
284
+ randX,
285
+ });
286
+ const l2 = getFunctionForScratchProgram(identifiersVariation)(identifiersVariation)[-1].l2;
287
+ arrListFoundation.push(l2);
288
+ });
289
+ }
290
+ arrListFoundation = arrListFoundation.filter((list) => !list.includes(undefined));
291
+ }
292
+ arrList = arrListFoundation.filter((list) => list.length > 0);
293
+ //more if needed
294
+ const nbInvalidRound1 = arrList.filter((list) => {
295
+ const tex = list.map((v) => `${v.frenchify()}`).join(" \\ ");
296
+ return tex !== answer;
297
+ }).length;
298
+ if (nbInvalidRound1 < n - 1) {
299
+ arrList.push(...arrListFoundation.map((list) => list.slice(0, -1)));
300
+ arrList.push(...arrListFoundation.map((list) => list.slice(1)));
301
+ }
302
+ arrList = arrList.filter((list) => list.length > 0);
303
+ //even more if needed
304
+ const nbInvalidRound2 = arrList.filter((list) => {
305
+ const tex = list.map((v) => `${v.frenchify()}`).join(" \\ ");
306
+ return tex !== answer;
307
+ }).length;
308
+ if (nbInvalidRound2 < n - 1) {
309
+ arrList.push(...arrListFoundation.map((list) => list.slice(0, -2)));
310
+ arrList.push(...arrListFoundation.map((list) => list.slice(2)));
311
+ }
312
+ arrList = arrList.filter((list) => list.length > 0);
313
+ arrList.forEach((list) => {
314
+ const tex = list.map((v) => `${v.frenchify()}`).join(" \\ ");
315
+ if (tex !== answer) {
316
+ tryToAddWrongProp(propositions, tex);
317
+ }
318
+ });
319
+ return shuffleProps(propositions, n);
320
+ };
321
+ const getScratchListFilterQuestion = () => {
322
+ const lengthL1 = 5;
323
+ const poolSmall = [...Array(lengthL1).keys()].map((i) => i + 1);
324
+ const poolStd = [...Array(20).keys()].map((i) => i + 1);
325
+ const isL1Small = coinFlip();
326
+ const l1Start = [...Array(5).keys()].map(() => random(isL1Small ? poolSmall : poolStd));
327
+ let identifiers;
328
+ let isValid = false;
329
+ let counter = -1;
330
+ while (!isValid && counter < 100) {
331
+ counter++;
332
+ const randCounter = randint(0, 6);
333
+ const randX = randint(0, 4);
334
+ const randCondition = randint(0, 3);
335
+ const randListAdd = randint(0, 2);
336
+ const isGreaterCond = coinFlip();
337
+ const k = isL1Small
338
+ ? random(coinFlip() ? l1Start : poolSmall)
339
+ : random(coinFlip() ? l1Start : poolStd);
340
+ const identifiersCandidate = {
341
+ l1Start,
342
+ randCounter,
343
+ randX,
344
+ randCondition,
345
+ isGreaterCond,
346
+ k,
347
+ randListAdd,
348
+ };
349
+ const l2 = getFunctionForScratchProgram(identifiersCandidate)(identifiersCandidate)[-1].l2;
350
+ isValid =
351
+ l2.length > 0 && !l2.includes(undefined);
352
+ if (isValid) {
353
+ identifiers = identifiersCandidate;
354
+ }
355
+ }
356
+ if (!isValid) {
357
+ const identifiersDefault = {
358
+ l1Start: [1, 2, 3, 4, 5],
359
+ randCounter: 0,
360
+ randX: 0,
361
+ randCondition: 0,
362
+ randListAdd: randint(0, 2),
363
+ isGreaterCond: false,
364
+ k: 3,
365
+ };
366
+ identifiers = identifiersDefault;
367
+ }
368
+ return getQuestionFromIdentifiers(identifiers);
369
+ };
370
+ const getQuestionFromIdentifiers = (identifiers) => {
371
+ return {
372
+ answer: getAnswer(identifiers),
373
+ instruction: getInstruction(identifiers),
374
+ answerFormat: "tex",
375
+ identifiers,
376
+ hint: getHint(identifiers),
377
+ correction: getCorrection(identifiers),
378
+ };
379
+ };
380
+ export const scratchListFilter = {
381
+ id: "scratchListFilter",
382
+ connector: "=",
383
+ label: "Filtrer une liste en Scratch",
384
+ isSingleStep: true,
385
+ generator: (nb, opts) => getDistinctQuestions(() => getScratchListFilterQuestion(opts), nb),
386
+ qcmTimer: 60,
387
+ freeTimer: 60,
388
+ getPropositions,
389
+ subject: "Mathématiques",
390
+ getInstruction,
391
+ getHint,
392
+ getCorrection,
393
+ getAnswer,
394
+ getQuestionFromIdentifiers,
395
+ hasHintAndCorrection: true,
396
+ answerType: "QCU",
397
+ };
@@ -0,0 +1,14 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { SpacePointIdentifiers } from "../../../../math/geometry/spacePoint.js";
3
+ type Identifiers = {
4
+ rectangularPrismOrigin: SpacePointIdentifiers;
5
+ L: number;
6
+ l: number;
7
+ h: number;
8
+ arrGivenSpacePointIds: SpacePointIdentifiers[];
9
+ arrPoolSpacePointIds: SpacePointIdentifiers[];
10
+ indexAsked: number;
11
+ };
12
+ export declare const findSpacePointOnRectangularPrism: Exercise<Identifiers>;
13
+ export {};
14
+ //# sourceMappingURL=findSpacePointOnRectangularPrism.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findSpacePointOnRectangularPrism.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAGL,qBAAqB,EACtB,MAAM,mCAAmC,CAAC;AAkB3C,KAAK,WAAW,GAAG;IAEjB,sBAAsB,EAAE,qBAAqB,CAAC;IAC9C,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAEV,qBAAqB,EAAE,qBAAqB,EAAE,CAAC;IAE/C,oBAAoB,EAAE,qBAAqB,EAAE,CAAC;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAqgBF,eAAO,MAAM,gCAAgC,EAAE,QAAQ,CAAC,WAAW,CAiBlE,CAAC"}