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.
- package/lib/exercises/exercise.d.ts +7 -0
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.d.ts +5 -1
- package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionToPercentToDecimal.js +92 -38
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +5 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportional.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportional.js +7 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +5 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTable.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTable.js +5 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/proportionalityTableCoefficient.js +8 -2
- package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -1
- package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/index.js +1 -1
- package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.d.ts +10 -0
- package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/square/equationSimpleSquare.js +183 -0
- package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.d.ts +10 -0
- package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.js +173 -0
- package/lib/exercises/math/calculLitteral/equation/square/index.d.ts +3 -0
- package/lib/exercises/math/calculLitteral/equation/square/index.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/square/index.js +2 -0
- package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/histogram/histogramIsSameData.js +7 -0
- package/lib/exercises/math/dataRepresentations/tableReading.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/tableReading.js +7 -0
- package/lib/exercises/math/functions/affines/affineAdjustment.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustment.js +7 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentComplete.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentComplete.js +7 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineAdjustmentRsquared.js +7 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionTable.js +7 -1
- package/lib/exercises/math/functions/basics/placePointsFromValueTable.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/placePointsFromValueTable.js +7 -0
- package/lib/exercises/math/functions/sqrt/squareRootCalculation.d.ts.map +1 -1
- package/lib/exercises/math/functions/sqrt/squareRootCalculation.js +4 -2
- package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.d.ts +15 -0
- package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/homothetyFactorFromPoints.js +301 -0
- package/lib/exercises/math/geometry/euclidian/index.d.ts +7 -0
- package/lib/exercises/math/geometry/euclidian/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidian/index.js +7 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.d.ts +21 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromAxialOrCentralSymmetry.js +406 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.d.ts +18 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromRotation.js +315 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.d.ts +20 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/pinPointFromTranslation.js +314 -0
- package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.d.ts +18 -0
- package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.js +387 -0
- package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.d.ts +18 -0
- package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/recognizeAngleFromRotation.js +309 -0
- package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.d.ts +17 -0
- package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/recognizeHomothetyCenter.js +301 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.js +22 -8
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.d.ts +11 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromCentralSymmetry.js +169 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +2 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/index.js +2 -0
- package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.d.ts +16 -0
- package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/placeHomothetyCenter.js +309 -0
- package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.js +7 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.js +7 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.d.ts +9 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValueMiddleSchool.js +120 -0
- package/lib/exercises/math/probaStat/basicProbas/index.d.ts +2 -0
- package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/basicProbas/index.js +2 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts +12 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/basicProbas/pickEquiprobableTo.js +374 -0
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.js +7 -0
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/averageWithClasses.d.ts +9 -0
- package/lib/exercises/math/probaStat/stats1var/averageWithClasses.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/averageWithClasses.js +140 -0
- package/lib/exercises/math/probaStat/stats1var/averageWithTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/averageWithTable.js +7 -1
- package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.d.ts +8 -0
- package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/averageWithTableWithContext.js +113 -0
- package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/etendueTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/etendueTable.js +7 -1
- package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/getQuartileProportionQuestion.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/index.d.ts +2 -0
- package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/index.js +2 -0
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +5 -1
- package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/marginalAndConditionalFrequency.js +7 -0
- package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts +2 -0
- package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianWithList.js +67 -14
- package/lib/exercises/math/probaStat/stats1var/medianWithTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianWithTable.js +7 -1
- package/lib/exercises/math/probaStat/stats1var/quartiles.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/quartiles.js +7 -1
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +5 -1
- package/lib/exercises/math/probaStat/stats1var/varianceTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/varianceTable.js +5 -1
- package/lib/exercises/math/probaStat/stats2var/averagePoint.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats2var/averagePoint.js +7 -1
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.d.ts +7 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceOutcomes.js +171 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.d.ts +7 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/headsOrTailsTwiceProbas.js +155 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts +3 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/twoStepExperiments/index.js +3 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.d.ts +7 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/twoStepExperiments/numberPoolTwiceProbas.js +189 -0
- package/lib/exercises/math/scratch/index.d.ts +3 -0
- package/lib/exercises/math/scratch/index.d.ts.map +1 -1
- package/lib/exercises/math/scratch/index.js +3 -0
- package/lib/exercises/math/scratch/scratchListElemAtIndex.d.ts +13 -0
- package/lib/exercises/math/scratch/scratchListElemAtIndex.d.ts.map +1 -0
- package/lib/exercises/math/scratch/scratchListElemAtIndex.js +189 -0
- package/lib/exercises/math/scratch/scratchListElemAtIndex2.d.ts +23 -0
- package/lib/exercises/math/scratch/scratchListElemAtIndex2.d.ts.map +1 -0
- package/lib/exercises/math/scratch/scratchListElemAtIndex2.js +207 -0
- package/lib/exercises/math/scratch/scratchListFilter.d.ts +13 -0
- package/lib/exercises/math/scratch/scratchListFilter.d.ts.map +1 -0
- package/lib/exercises/math/scratch/scratchListFilter.js +397 -0
- package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.d.ts +14 -0
- package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.js +347 -0
- package/lib/exercises/math/spaceGeometry/basis/index.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/basis/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/basis/index.js +1 -0
- package/lib/exercises/math/spaceGeometry/index.d.ts +2 -0
- package/lib/exercises/math/spaceGeometry/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/index.js +2 -0
- package/lib/exercises/math/spaceGeometry/sections/areaOfConeSection.js +3 -3
- package/lib/exercises/math/spaceGeometry/solids/index.d.ts +3 -0
- package/lib/exercises/math/spaceGeometry/solids/index.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/solids/index.js +2 -0
- package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.d.ts +15 -0
- package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFrom3D.js +440 -0
- package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.d.ts +11 -0
- package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/solids/recognizeSolidFromSolidPattern.js +1089 -0
- package/lib/exercises/math/spaceGeometry/sphere/index.d.ts +3 -0
- package/lib/exercises/math/spaceGeometry/sphere/index.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sphere/index.js +2 -0
- package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.d.ts +9 -0
- package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sphere/pickIsPointInSphereOrBall.js +127 -0
- package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.d.ts +14 -0
- package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.d.ts.map +1 -0
- package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.js +390 -0
- package/lib/geogebra/geogebraConstructor.d.ts +2 -0
- package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
- package/lib/geogebra/geogebraConstructor.js +6 -0
- package/lib/index.d.ts +198 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/point.d.ts +6 -0
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +28 -0
- package/lib/tree/nodes/equations/equalNode.d.ts +1 -1
- package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.js +0 -1
- package/lib/tree/utilities/nodeSimplifier.d.ts +1 -1
- package/lib/utils/arrays/arrayZip.d.ts +2 -0
- package/lib/utils/arrays/arrayZip.d.ts.map +1 -0
- package/lib/utils/arrays/arrayZip.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { addValidProp, 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 { random, randomMany } from "../../../utils/alea/random.js";
|
|
6
|
+
import { shuffle } from "../../../utils/alea/shuffle.js";
|
|
7
|
+
import { mdTable } from "../../../utils/markdown/mdTable.js";
|
|
8
|
+
const getInstruction = (identifiers) => {
|
|
9
|
+
const { arrInsertion, indexAsked } = identifiers;
|
|
10
|
+
return `On considère le programme Scratch ci-dessous :
|
|
11
|
+
|
|
12
|
+
<svg id="scratch">
|
|
13
|
+
quand @greenFlag est cliqué
|
|
14
|
+
supprimer tous les éléments de la liste [l v]
|
|
15
|
+
${arrInsertion.map(({ index, value }) => {
|
|
16
|
+
if (index === -1) {
|
|
17
|
+
return `ajouter [${value}] à [l v]`;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return `insérer [${value}] en position [${index + 1}] de [l v]`;
|
|
21
|
+
}
|
|
22
|
+
}).join(`
|
|
23
|
+
`)}
|
|
24
|
+
dire (élément [${indexAsked + 1}] de [l v])
|
|
25
|
+
</svg>
|
|
26
|
+
|
|
27
|
+
Que va dire le lutin suite à l'exécution du programme ?`;
|
|
28
|
+
};
|
|
29
|
+
const getFunctionForScratchProgram = (identifiers) => {
|
|
30
|
+
const { arrInsertion, indexAsked } = identifiers;
|
|
31
|
+
return (_) => {
|
|
32
|
+
const outDict = {};
|
|
33
|
+
//init
|
|
34
|
+
const l = [];
|
|
35
|
+
outDict[0] = {
|
|
36
|
+
l: [...l],
|
|
37
|
+
};
|
|
38
|
+
//loop
|
|
39
|
+
let counter = 0;
|
|
40
|
+
arrInsertion.forEach(({ index, value }) => {
|
|
41
|
+
counter++;
|
|
42
|
+
if (index === -1 || index === l.length) {
|
|
43
|
+
l.push(value);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
l.splice(index, 0, value);
|
|
47
|
+
}
|
|
48
|
+
//store step dict
|
|
49
|
+
outDict[counter] = {
|
|
50
|
+
l: [...l],
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
//convenience: store last step in -1
|
|
54
|
+
outDict[-1] = outDict[Math.max(...Object.keys(outDict).map((k) => +k))];
|
|
55
|
+
outDict[-1].x = outDict[-1].l[indexAsked];
|
|
56
|
+
return outDict;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const getAnswer = (identifiers) => {
|
|
60
|
+
const { isUsingLetters } = identifiers;
|
|
61
|
+
const xRaw = getFunctionForScratchProgram(identifiers)(identifiers)[-1].x;
|
|
62
|
+
if (isUsingLetters) {
|
|
63
|
+
return xRaw;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return xRaw.frenchify();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const getHint = () => {
|
|
70
|
+
return `La liste $l$ change au cours de l'exécution du programme.
|
|
71
|
+
|
|
72
|
+
À chaque instruction, détermine comment la liste évolue.
|
|
73
|
+
|
|
74
|
+
Insérer un élement à une position décale l'élément existant à cette position et tous les suivants, pour laisser la place au nouvel arrivant.
|
|
75
|
+
|
|
76
|
+
L'état final de $l$ te permettra de répondre à la question posée.`;
|
|
77
|
+
};
|
|
78
|
+
const getCorrection = (identifiers) => {
|
|
79
|
+
const { arrInsertion, indexAsked } = identifiers;
|
|
80
|
+
const dictSteps = getFunctionForScratchProgram(identifiers)(identifiers);
|
|
81
|
+
return `Voici l'évolution de la liste $l$ au fil des instructions.
|
|
82
|
+
|
|
83
|
+
${mdTable([
|
|
84
|
+
["\\text{Initialement: vide}", "\\text{}", "\\text{}", "\\text{}"],
|
|
85
|
+
...arrInsertion.map(({ index, value }, i) => {
|
|
86
|
+
const l = dictSteps[i + 1].l;
|
|
87
|
+
return [
|
|
88
|
+
index === -1
|
|
89
|
+
? `\\text{Après "ajouter ${value} à l"}`
|
|
90
|
+
: `\\text{Après "insérer ${value} en pos. ${index + 1}"}`,
|
|
91
|
+
l.length > 0 ? `${l[0]}` : "\\text{}",
|
|
92
|
+
l.length > 1 ? `${l[1]}` : "\\text{}",
|
|
93
|
+
l.length > 2 ? `${l[2]}` : "\\text{}",
|
|
94
|
+
];
|
|
95
|
+
}),
|
|
96
|
+
], true)}
|
|
97
|
+
|
|
98
|
+
À la fin de l'exécution du programme, $l$ vaut donc $[${dictSteps[-1].l.join(";")}]$.
|
|
99
|
+
|
|
100
|
+
L'élément à la position $${indexAsked + 1}$ de $l$ est $${dictSteps[-1].x}$.`;
|
|
101
|
+
};
|
|
102
|
+
const getPropositions = (_, { answer, ...identifiers }) => {
|
|
103
|
+
const { isUsingLetters } = identifiers;
|
|
104
|
+
const propositions = [];
|
|
105
|
+
if (isUsingLetters) {
|
|
106
|
+
const valuesPool = ["A", "B", "C"];
|
|
107
|
+
valuesPool.forEach((str) => {
|
|
108
|
+
(str === answer ? addValidProp : tryToAddWrongProp)(propositions, str);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const valuesPool = [1, 2, 3];
|
|
113
|
+
valuesPool.forEach((v) => {
|
|
114
|
+
const tex = v.frenchify();
|
|
115
|
+
(tex === answer ? addValidProp : tryToAddWrongProp)(propositions, tex);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return propositions;
|
|
119
|
+
};
|
|
120
|
+
const getKeys = ({ isUsingLetters }) => {
|
|
121
|
+
return isUsingLetters ? ["A", "B", "C"] : [];
|
|
122
|
+
};
|
|
123
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
124
|
+
return ans === answer;
|
|
125
|
+
};
|
|
126
|
+
const getScratchListElemAtIndexQuestion = () => {
|
|
127
|
+
const shuffleArray = coinFlip()
|
|
128
|
+
? shuffle([0, 1, 2])
|
|
129
|
+
: shuffle([...randomMany([0, 1, 2], 2), random([0, 1, 2])]);
|
|
130
|
+
const isUsingLetters = coinFlip();
|
|
131
|
+
let arrInsertion = [];
|
|
132
|
+
if (isUsingLetters) {
|
|
133
|
+
const valuesPool = ["A", "B", "C"];
|
|
134
|
+
const values = shuffleArray.map((i) => valuesPool[i]);
|
|
135
|
+
arrInsertion = values.map((v, i) => {
|
|
136
|
+
return {
|
|
137
|
+
index: coinFlip() ? -1 : randint(0, i + 1),
|
|
138
|
+
value: v,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const valuesPool = [1, 2, 3];
|
|
144
|
+
const values = shuffleArray.map((i) => valuesPool[i]);
|
|
145
|
+
arrInsertion = values.map((v, i) => {
|
|
146
|
+
return {
|
|
147
|
+
index: coinFlip() ? -1 : randint(0, i + 1),
|
|
148
|
+
value: v,
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const indexRawLast = arrInsertion[arrInsertion.length - 1].index;
|
|
153
|
+
const indexAsked = randint(0, arrInsertion.length, indexRawLast !== -1 ? [indexRawLast] : []);
|
|
154
|
+
const identifiers = {
|
|
155
|
+
isUsingLetters,
|
|
156
|
+
arrInsertion,
|
|
157
|
+
indexAsked,
|
|
158
|
+
};
|
|
159
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
160
|
+
};
|
|
161
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
162
|
+
return {
|
|
163
|
+
answer: getAnswer(identifiers),
|
|
164
|
+
instruction: getInstruction(identifiers),
|
|
165
|
+
keys: getKeys(identifiers),
|
|
166
|
+
answerFormat: "tex",
|
|
167
|
+
identifiers,
|
|
168
|
+
hint: getHint(identifiers),
|
|
169
|
+
correction: getCorrection(identifiers),
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export const scratchListElemAtIndex = {
|
|
173
|
+
id: "scratchListElemAtIndex",
|
|
174
|
+
connector: "=",
|
|
175
|
+
label: "Donner un élément d'une liste en Scratch",
|
|
176
|
+
isSingleStep: true,
|
|
177
|
+
generator: (nb, opts) => getDistinctQuestions(() => getScratchListElemAtIndexQuestion(opts), nb),
|
|
178
|
+
qcmTimer: 60,
|
|
179
|
+
freeTimer: 60,
|
|
180
|
+
getPropositions,
|
|
181
|
+
isAnswerValid,
|
|
182
|
+
subject: "Mathématiques",
|
|
183
|
+
getInstruction,
|
|
184
|
+
getHint,
|
|
185
|
+
getCorrection,
|
|
186
|
+
getAnswer,
|
|
187
|
+
getQuestionFromIdentifiers,
|
|
188
|
+
hasHintAndCorrection: true,
|
|
189
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Insertion<T> = {
|
|
3
|
+
index: number;
|
|
4
|
+
value: T;
|
|
5
|
+
};
|
|
6
|
+
type Injection<T> = {
|
|
7
|
+
index: number;
|
|
8
|
+
value: T;
|
|
9
|
+
};
|
|
10
|
+
type Instruction<T> = ({
|
|
11
|
+
type: "insertion";
|
|
12
|
+
} & Insertion<T>) | ({
|
|
13
|
+
type: "injection";
|
|
14
|
+
} & Injection<T>);
|
|
15
|
+
type Identifiers = {
|
|
16
|
+
lStart: number[] | string[];
|
|
17
|
+
isUsingLetters: boolean;
|
|
18
|
+
arrInstruction: Instruction<number>[] | Instruction<string>[];
|
|
19
|
+
indexAsked: number;
|
|
20
|
+
};
|
|
21
|
+
export declare const scratchListElemAtIndex2: Exercise<Identifiers>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=scratchListElemAtIndex2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scratchListElemAtIndex2.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/scratch/scratchListElemAtIndex2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,SAAS,CAAC,CAAC,IAAI;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,SAAS,CAAC,CAAC,IAAI;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,IACd,CAAC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,GACtC,CAAC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE3C,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9D,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AA4OF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAkBzD,CAAC"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { addValidProp, 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 { random, randomMany } from "../../../utils/alea/random.js";
|
|
6
|
+
import { shuffle } from "../../../utils/alea/shuffle.js";
|
|
7
|
+
import { mdTable } from "../../../utils/markdown/mdTable.js";
|
|
8
|
+
const getInstruction = (identifiers) => {
|
|
9
|
+
const { lStart, arrInstruction, indexAsked } = identifiers;
|
|
10
|
+
return `On considère le programme Scratch ci-dessous :
|
|
11
|
+
|
|
12
|
+
<svg id="scratch">
|
|
13
|
+
quand @greenFlag est cliqué
|
|
14
|
+
${arrInstruction.map(({ type, index, value }) => {
|
|
15
|
+
if (type === "insertion") {
|
|
16
|
+
if (index === -1) {
|
|
17
|
+
return `ajouter [${value}] à [l v]`;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return `insérer [${value}] en position [${index + 1}] de [l v]`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return `remplacer l'élément [${index + 1}] de la liste [l v] par [${value}]`;
|
|
25
|
+
}
|
|
26
|
+
}).join(`
|
|
27
|
+
`)}
|
|
28
|
+
dire (élément [${indexAsked + 1}] de [l v])
|
|
29
|
+
</svg>
|
|
30
|
+
|
|
31
|
+
Si la liste $l$ vaut initialement $[${lStart.join(";")}]$, que va dire le lutin suite à l'exécution du programme ?`;
|
|
32
|
+
};
|
|
33
|
+
const getFunctionForScratchProgram = (identifiers) => {
|
|
34
|
+
const { lStart, arrInstruction, indexAsked } = identifiers;
|
|
35
|
+
return (_) => {
|
|
36
|
+
const outDict = {};
|
|
37
|
+
//init
|
|
38
|
+
const l = [...lStart];
|
|
39
|
+
outDict[0] = {
|
|
40
|
+
l: [...l],
|
|
41
|
+
};
|
|
42
|
+
//loop
|
|
43
|
+
let counter = 0;
|
|
44
|
+
arrInstruction.forEach(({ type, index, value }) => {
|
|
45
|
+
counter++;
|
|
46
|
+
if (type === "insertion") {
|
|
47
|
+
if (index === -1 || index === l.length) {
|
|
48
|
+
l.push(value);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
l.splice(index, 0, value);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
l[index] = value;
|
|
56
|
+
}
|
|
57
|
+
//store step dict
|
|
58
|
+
outDict[counter] = {
|
|
59
|
+
l: [...l],
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
//convenience: store last step in -1
|
|
63
|
+
outDict[-1] = outDict[Math.max(...Object.keys(outDict).map((k) => +k))];
|
|
64
|
+
outDict[-1].x = outDict[-1].l[indexAsked];
|
|
65
|
+
return outDict;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const getAnswer = (identifiers) => {
|
|
69
|
+
const { isUsingLetters } = identifiers;
|
|
70
|
+
const xRaw = getFunctionForScratchProgram(identifiers)(identifiers)[-1].x;
|
|
71
|
+
if (isUsingLetters) {
|
|
72
|
+
return xRaw;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return xRaw.frenchify();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const getHint = () => {
|
|
79
|
+
return `La liste $l$ change au cours de l'exécution du programme.
|
|
80
|
+
|
|
81
|
+
À chaque instruction, détermine comment la liste évolue.
|
|
82
|
+
|
|
83
|
+
Insérer un élement à une position décale l'élément existant à cette position et tous les suivants, pour laisser la place au nouvel arrivant.
|
|
84
|
+
|
|
85
|
+
Remplacer un élément de la liste écrase l'ancien élément avec le nouveau.
|
|
86
|
+
|
|
87
|
+
L'état final de $l$ te permettra de répondre à la question posée.`;
|
|
88
|
+
};
|
|
89
|
+
const getCorrection = (identifiers) => {
|
|
90
|
+
const { arrInstruction, indexAsked } = identifiers;
|
|
91
|
+
const dictSteps = getFunctionForScratchProgram(identifiers)(identifiers);
|
|
92
|
+
const maxLength = dictSteps[-1].l.length;
|
|
93
|
+
return `Voici l'évolution de la liste $l$ au fil des instructions.
|
|
94
|
+
|
|
95
|
+
${mdTable([
|
|
96
|
+
(() => {
|
|
97
|
+
const l = dictSteps[0].l;
|
|
98
|
+
return [
|
|
99
|
+
"\\text{Initialement}",
|
|
100
|
+
...[...Array(maxLength).keys()].map((i) => l.length > i ? `${l[i]}` : "\\text{}"),
|
|
101
|
+
];
|
|
102
|
+
})(),
|
|
103
|
+
...arrInstruction.map(({ type, index, value }, i) => {
|
|
104
|
+
const l = dictSteps[i + 1].l;
|
|
105
|
+
return [
|
|
106
|
+
type === "insertion"
|
|
107
|
+
? index === -1
|
|
108
|
+
? `\\text{Après "ajouter ${value} à l"}`
|
|
109
|
+
: `\\text{Après "insérer ${value} en pos. ${index + 1}"}`
|
|
110
|
+
: `\\text{Après "rempl. l'élém. ${index + 1} par ${value}"}`,
|
|
111
|
+
...[...Array(maxLength).keys()].map((i) => l.length > i ? `${l[i]}` : "\\text{}"),
|
|
112
|
+
];
|
|
113
|
+
}),
|
|
114
|
+
], true)}
|
|
115
|
+
|
|
116
|
+
À la fin de l'exécution du programme, $l$ vaut donc $[${dictSteps[-1].l.join(";")}]$.
|
|
117
|
+
|
|
118
|
+
L'élément à la position $${indexAsked + 1}$ de $l$ est $${dictSteps[-1].x}$.`;
|
|
119
|
+
};
|
|
120
|
+
const getPropositions = (_, { answer, ...identifiers }) => {
|
|
121
|
+
const { isUsingLetters } = identifiers;
|
|
122
|
+
const propositions = [];
|
|
123
|
+
if (isUsingLetters) {
|
|
124
|
+
const valuesPool = ["A", "B", "C"];
|
|
125
|
+
valuesPool.forEach((str) => {
|
|
126
|
+
(str === answer ? addValidProp : tryToAddWrongProp)(propositions, str);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const valuesPool = [1, 2, 3];
|
|
131
|
+
valuesPool.forEach((v) => {
|
|
132
|
+
const tex = v.frenchify();
|
|
133
|
+
(tex === answer ? addValidProp : tryToAddWrongProp)(propositions, tex);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return propositions;
|
|
137
|
+
};
|
|
138
|
+
const getScratchListElemAtIndex2Question = () => {
|
|
139
|
+
const shuffleArray = coinFlip()
|
|
140
|
+
? shuffle([0, 1, 2])
|
|
141
|
+
: shuffle([...randomMany([0, 1, 2], 2), random([0, 1, 2])]);
|
|
142
|
+
const isUsingLetters = coinFlip();
|
|
143
|
+
const letterPool = ["A", "B", "C"];
|
|
144
|
+
const numberPool = [1, 2, 3];
|
|
145
|
+
const lengthLStart = randint(1, 4);
|
|
146
|
+
const lStart = [...Array(lengthLStart).keys()].map(() => isUsingLetters ? random(letterPool) : random(numberPool));
|
|
147
|
+
const values = shuffleArray.map((i) => (isUsingLetters ? letterPool : numberPool)[i]);
|
|
148
|
+
const arrInstruction = values.map((v, i) => {
|
|
149
|
+
const type = coinFlip() ? "insertion" : "injection";
|
|
150
|
+
return {
|
|
151
|
+
type,
|
|
152
|
+
index: type === "insertion"
|
|
153
|
+
? coinFlip()
|
|
154
|
+
? -1
|
|
155
|
+
: randint(0, i + 1)
|
|
156
|
+
: randint(0, i),
|
|
157
|
+
value: v,
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
const indexRawLast = arrInstruction[arrInstruction.length - 1].index;
|
|
161
|
+
const indexMax = (() => {
|
|
162
|
+
const identifiersProbe = {
|
|
163
|
+
lStart,
|
|
164
|
+
isUsingLetters,
|
|
165
|
+
arrInstruction,
|
|
166
|
+
indexAsked: 0,
|
|
167
|
+
};
|
|
168
|
+
const dictSteps = getFunctionForScratchProgram(identifiersProbe)(identifiersProbe);
|
|
169
|
+
return dictSteps[-1].l.length;
|
|
170
|
+
})();
|
|
171
|
+
const indexAsked = randint(0, indexMax, indexMax !== 1 && indexRawLast !== -1 ? [indexRawLast] : []);
|
|
172
|
+
const identifiers = {
|
|
173
|
+
lStart,
|
|
174
|
+
isUsingLetters,
|
|
175
|
+
arrInstruction,
|
|
176
|
+
indexAsked,
|
|
177
|
+
};
|
|
178
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
179
|
+
};
|
|
180
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
181
|
+
return {
|
|
182
|
+
answer: getAnswer(identifiers),
|
|
183
|
+
instruction: getInstruction(identifiers),
|
|
184
|
+
answerFormat: "tex",
|
|
185
|
+
identifiers,
|
|
186
|
+
hint: getHint(identifiers),
|
|
187
|
+
correction: getCorrection(identifiers),
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
export const scratchListElemAtIndex2 = {
|
|
191
|
+
id: "scratchListElemAtIndex2",
|
|
192
|
+
connector: "=",
|
|
193
|
+
label: "Donner un élément d'une liste en Scratch ($2$)",
|
|
194
|
+
isSingleStep: true,
|
|
195
|
+
generator: (nb, opts) => getDistinctQuestions(() => getScratchListElemAtIndex2Question(opts), nb),
|
|
196
|
+
qcmTimer: 60,
|
|
197
|
+
freeTimer: 60,
|
|
198
|
+
getPropositions,
|
|
199
|
+
subject: "Mathématiques",
|
|
200
|
+
getInstruction,
|
|
201
|
+
getHint,
|
|
202
|
+
getCorrection,
|
|
203
|
+
getAnswer,
|
|
204
|
+
getQuestionFromIdentifiers,
|
|
205
|
+
hasHintAndCorrection: true,
|
|
206
|
+
answerType: "QCU",
|
|
207
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise.js";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
l1Start: number[];
|
|
4
|
+
randCounter: number;
|
|
5
|
+
randX: number;
|
|
6
|
+
randCondition: number;
|
|
7
|
+
isGreaterCond: boolean;
|
|
8
|
+
k?: number;
|
|
9
|
+
randListAdd: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const scratchListFilter: Exercise<Identifiers>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=scratchListFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scratchListFilter.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/scratch/scratchListFilter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAmdF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAkBnD,CAAC"}
|