math-exercises 3.0.171 → 3.0.173
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/math/derivation/variations/signVarTable3dDegree.js +38 -10
- package/lib/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableFromDerivativeGraph.js +7 -4
- package/lib/exercises/math/derivation/variations/signVarTableFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableFromGraph.js +2 -3
- package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/devForm/variationsFromAlgebricForm.js +12 -0
- package/lib/exercises/math/functions/trinoms/parabole/index.d.ts +2 -0
- package/lib/exercises/math/functions/trinoms/parabole/index.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/parabole/index.js +2 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts +8 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/parabole/parabolaVarTable.js +106 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts +14 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.d.ts.map +1 -0
- package/lib/exercises/math/functions/trinoms/parabole/paraboleSolveGraphEquation.js +186 -0
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts +6 -2
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/summitAndCanonical/extremumTypeFromAlgebricForm.js +98 -13
- package/lib/exercises/math/functions/variations/partialVarTableFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/variations/partialVarTableFromGraph.js +2 -1
- package/lib/exercises/math/functions/variations/varTableFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/variations/varTableFromGraph.js +2 -1
- package/lib/exercises/math/functions/variations/varTableFromSentences.d.ts.map +1 -1
- package/lib/exercises/math/functions/variations/varTableFromSentences.js +2 -1
- package/lib/exercises/math/geometry/circles/circleCenterAndRadiusFromEquation.d.ts.map +1 -1
- package/lib/exercises/math/geometry/circles/circleCenterAndRadiusFromEquation.js +0 -2
- package/lib/exercises/math/geometry/lines/index.d.ts +1 -0
- package/lib/exercises/math/geometry/lines/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/lines/index.js +1 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts +13 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.d.ts.map +1 -0
- package/lib/exercises/math/geometry/lines/readLineNormalVectorOnGraph.js +195 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiAngle.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiAngle.js +64 -60
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts +1 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.js +173 -47
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiSideLength.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiSideLength.js +112 -46
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductInOrthonormalBasisIJ.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductInOrthonormalBasisIJ.js +6 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductLamdbaULambdaV.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductLamdbaULambdaV.js +60 -82
- package/lib/exercises/math/geometry/vectors/scalarProduct/angleFromScalarProduct.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/angleFromScalarProduct.js +92 -6
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts +6 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/index.js +6 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsBasisIJ.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsBasisIJ.js +6 -0
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsUsingCoords.js +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnCircle.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnCircle.js +15 -5
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnPerpendicularBisector.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnPerpendicularBisector.js +18 -14
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsRightTriangleUsingPointCoords.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsRightTriangleUsingPointCoords.js +15 -5
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.js +38 -4
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOfVectsOnGrid1.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOfVectsOnGrid1.js +77 -26
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductParallelogramDiagonalPlus.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductParallelogramDiagonalPlus.js +6 -7
- package/lib/exercises/math/probaStat/basicProbas/calculateProbaFromProbaLaw.js +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +3 -16
- package/lib/exercises/math/probaStat/randomVariable/decideWhichGameIsLessRisky.d.ts +14 -0
- package/lib/exercises/math/probaStat/randomVariable/decideWhichGameIsLessRisky.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/decideWhichGameIsLessRisky.js +167 -0
- package/lib/exercises/math/probaStat/randomVariable/findValueForFairRandomVariable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/findValueForFairRandomVariable.js +29 -56
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/index.js +9 -0
- package/lib/exercises/math/probaStat/randomVariable/isTableProbabilityLaw.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/isTableProbabilityLaw.js +6 -6
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/missingValueInRandomVariableProbabilityLaw.js +119 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableAverage.js +1 -1
- package/lib/exercises/math/probaStat/randomVariable/randomVariableFindMissingProbabilityInLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableFindMissingProbabilityInLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableFindMissingProbabilityInLaw.js +116 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationAverage.d.ts +11 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationAverage.js +112 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationComputeProbability.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationComputeProbability.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationComputeProbability.js +176 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationIsGameFavorable.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationIsGameFavorable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationIsGameFavorable.js +94 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts +9 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationProbabilityLaw.js +162 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationStandardDeviation.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationStandardDeviation.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationStandardDeviation.js +133 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationValues.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationValues.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationValues.js +211 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationVariance.d.ts +8 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationVariance.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableSituationVariance.js +113 -0
- package/lib/exercises/math/probaStat/randomVariable/randomVariableStandardDeviation.js +1 -1
- package/lib/exercises/math/probaStat/randomVariable/randomVariableVariance.js +1 -1
- package/lib/exercises/math/probaStat/randomVariable/utils/buildVAOfGivenAverage.d.ts +31 -0
- package/lib/exercises/math/probaStat/randomVariable/utils/buildVAOfGivenAverage.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/randomVariable/utils/buildVAOfGivenAverage.js +192 -0
- package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts +40 -11
- package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/randomVariable/utils/randomVariableSituations.js +172 -30
- package/lib/exercises/math/probaStat/stats1var/medianWithList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/medianWithList.js +16 -2
- package/lib/exercises/math/python/sequences/index.d.ts +8 -0
- package/lib/exercises/math/python/sequences/index.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/index.js +7 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts +11 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFactorialInstructionFalseOneOut.js +274 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts +12 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.js +368 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts +13 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.js +254 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts +14 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceProgramReading.js +365 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts +11 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceTermForLoopInstructionCompletion.js +298 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts +12 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceTermFromFunctionCallInstructionCompletion.js +408 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts +17 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.d.ts.map +1 -0
- package/lib/exercises/math/python/sequences/pySequenceThresholdInstructionCompletion.js +498 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts +12 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/arithmeticFindExplicitFormulaFromTwoTerms.js +191 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindExplicitFormulaFromSituation.js +153 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRankFromSituation.js +184 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindRecurrenceFormulaFromSituation.js +210 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindTermFromSituation.js +161 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts +17 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/arithmeticFindThresholdFromSituation.js +188 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts +6 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/situations/index.js +5 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts +15 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticComputeSumWithDots.js +233 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts +13 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSum.js +111 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts +13 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/arithmeticFirstTermsSumThreshold.js +216 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts +7 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/firstIntegersSum.js +94 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts +5 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/arithmetic/sum/index.js +4 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormulaFromTwoTerms.js +301 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/geometricFindRandomTermFromTwoTerms.js +260 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindExplicitFormulaFromSituation.js +186 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRankFromSituation.js +142 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindRecurrenceFormulaFromSituation.js +205 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindTermFromSituation.js +208 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts +17 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/geometricFindThresholdFromSituation.js +152 -0
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts +4 -0
- package/lib/exercises/math/sequences/geometric/situations/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/situations/index.js +5 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts +15 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricComputeSumWithDots.js +248 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts +14 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsGeneralSum.js +126 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts +8 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/geometricFirstTermsSum.js +91 -0
- package/lib/exercises/math/sequences/geometric/sum/index.d.ts +4 -0
- package/lib/exercises/math/sequences/geometric/sum/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/geometric/sum/index.js +3 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts +2 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.d.ts.map +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/index.js +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts +14 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.d.ts.map +1 -0
- package/lib/exercises/math/sequences/seqArithmGeom/seqArithmGeomRecurrenceFormulaUsage.js +202 -0
- package/lib/exercises/math/trigonometry/circle/placeAssociateAngleOnCircle.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/circle/placeAssociateAngleOnCircle.js +0 -2
- package/lib/exercises/options/optionFirstTermRankOne.d.ts +16 -0
- package/lib/exercises/options/optionFirstTermRankOne.d.ts.map +1 -0
- package/lib/exercises/options/optionFirstTermRankOne.js +17 -0
- package/lib/exercises/options/optionIsUsePythonDef.d.ts +16 -0
- package/lib/exercises/options/optionIsUsePythonDef.d.ts.map +1 -0
- package/lib/exercises/options/optionIsUsePythonDef.js +17 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.d.ts +16 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.d.ts.map +1 -0
- package/lib/exercises/options/optionIsWithSuperfluousData.js +17 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
- package/lib/exercises/vea/colinearVectorVEA.d.ts +2 -0
- package/lib/exercises/vea/colinearVectorVEA.d.ts.map +1 -0
- package/lib/exercises/vea/colinearVectorVEA.js +11 -0
- package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
- package/lib/exercises/vea/rationalVEA.js +7 -3
- package/lib/exercises/vea/varLineVEA.d.ts.map +1 -1
- package/lib/exercises/vea/varLineVEA.js +7 -3
- package/lib/exercises/vea/varSignTableVEA.d.ts +8 -0
- package/lib/exercises/vea/varSignTableVEA.d.ts.map +1 -1
- package/lib/exercises/vea/varSignTableVEA.js +8 -0
- package/lib/exercises/vea/xTableLineVEA.d.ts +1 -0
- package/lib/exercises/vea/xTableLineVEA.d.ts.map +1 -1
- package/lib/exercises/vea/xTableLineVEA.js +1 -0
- package/lib/index.d.ts +104 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/latexTester.d.ts.map +1 -1
- package/lib/latexTester.js +3 -1
- package/lib/math/geometry/angle.d.ts +2 -0
- package/lib/math/geometry/angle.d.ts.map +1 -1
- package/lib/math/geometry/angle.js +17 -0
- package/lib/math/geometry/line.d.ts +1 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +3 -3
- package/lib/math/geometry/point.d.ts +1 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +4 -1
- package/lib/math/geometry/segment.js +1 -1
- package/lib/math/numbers/reals/real.d.ts.map +1 -1
- package/lib/math/numbers/reals/real.js +4 -0
- package/lib/math/probability/randomVariable.d.ts +2 -1
- package/lib/math/probability/randomVariable.d.ts.map +1 -1
- package/lib/math/probability/randomVariable.js +7 -1
- package/lib/math/utils/arithmetic/primeFactors.d.ts +1 -1
- package/lib/math/utils/arithmetic/primeFactors.d.ts.map +1 -1
- package/lib/math/utils/arithmetic/primeFactors.js +23 -9
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts +53 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqArithmeticSituations.js +1928 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts +15 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqArithmeticUtils.js +136 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts +42 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqGeometricSituations.js +932 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts +12 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.d.ts.map +1 -0
- package/lib/math/utils/sequences/situations/seqGeometricUtils.js +90 -0
- package/lib/tests/pdfs/mdTableToLatexTabular.js +1 -1
- package/lib/tree/nodes/algebraicNode.d.ts +1 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.d.ts +1 -0
- package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.js +3 -0
- package/lib/tree/nodes/equations/equalNode.d.ts +1 -0
- package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.js +3 -0
- package/lib/tree/nodes/equations/equationSolutionNode.d.ts +1 -0
- package/lib/tree/nodes/equations/equationSolutionNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equationSolutionNode.js +3 -0
- package/lib/tree/nodes/equations/multiEqualNode.d.ts +1 -0
- package/lib/tree/nodes/equations/multiEqualNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/multiEqualNode.js +3 -0
- package/lib/tree/nodes/equations/notEqualNode.d.ts +1 -0
- package/lib/tree/nodes/equations/notEqualNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/notEqualNode.js +3 -0
- package/lib/tree/nodes/functions/absNode.d.ts +1 -0
- package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/absNode.js +7 -0
- package/lib/tree/nodes/functions/arcSinNode.d.ts +1 -0
- package/lib/tree/nodes/functions/arcSinNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/arcSinNode.js +7 -0
- package/lib/tree/nodes/functions/arccosNode.d.ts +1 -0
- package/lib/tree/nodes/functions/arccosNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/arccosNode.js +7 -0
- package/lib/tree/nodes/functions/arctanNode.d.ts +1 -0
- package/lib/tree/nodes/functions/arctanNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/arctanNode.js +7 -0
- package/lib/tree/nodes/functions/cosNode.d.ts +1 -0
- package/lib/tree/nodes/functions/cosNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/cosNode.js +7 -0
- package/lib/tree/nodes/functions/expNode.d.ts +1 -0
- package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/expNode.js +7 -0
- package/lib/tree/nodes/functions/factorialNode.d.ts +30 -0
- package/lib/tree/nodes/functions/factorialNode.d.ts.map +1 -0
- package/lib/tree/nodes/functions/factorialNode.js +79 -0
- package/lib/tree/nodes/functions/functionNode.d.ts +2 -1
- package/lib/tree/nodes/functions/functionNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/functionNode.js +1 -0
- package/lib/tree/nodes/functions/integralNode.d.ts +1 -0
- package/lib/tree/nodes/functions/integralNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/integralNode.js +7 -0
- package/lib/tree/nodes/functions/log10Node.d.ts +1 -0
- package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
- package/lib/tree/nodes/functions/log10Node.js +7 -0
- package/lib/tree/nodes/functions/logNode.d.ts +1 -0
- package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/logNode.js +9 -0
- package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -0
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.js +7 -0
- package/lib/tree/nodes/functions/sinNode.d.ts +1 -0
- package/lib/tree/nodes/functions/sinNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sinNode.js +7 -0
- package/lib/tree/nodes/functions/sqrtNode.d.ts +1 -0
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +7 -0
- package/lib/tree/nodes/functions/tanNode.d.ts +1 -0
- package/lib/tree/nodes/functions/tanNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/tanNode.js +7 -0
- package/lib/tree/nodes/geometry/degree.d.ts +1 -0
- package/lib/tree/nodes/geometry/degree.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/degree.js +7 -0
- package/lib/tree/nodes/geometry/lengthNode.d.ts +1 -0
- package/lib/tree/nodes/geometry/lengthNode.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/lengthNode.js +7 -0
- package/lib/tree/nodes/geometry/pointNode.d.ts +1 -0
- package/lib/tree/nodes/geometry/pointNode.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/pointNode.js +7 -0
- package/lib/tree/nodes/geometry/vectorNode.d.ts +1 -0
- package/lib/tree/nodes/geometry/vectorNode.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/vectorNode.js +7 -0
- package/lib/tree/nodes/inequations/inequationNode.d.ts +1 -0
- package/lib/tree/nodes/inequations/inequationNode.d.ts.map +1 -1
- package/lib/tree/nodes/inequations/inequationNode.js +7 -0
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts +1 -0
- package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts.map +1 -1
- package/lib/tree/nodes/inequations/inequationSolutionNode.js +7 -0
- package/lib/tree/nodes/node.d.ts +2 -1
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/node.js +2 -0
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.js +4 -0
- package/lib/tree/nodes/numbers/percentNode.d.ts +1 -0
- package/lib/tree/nodes/numbers/percentNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/percentNode.js +7 -0
- package/lib/tree/nodes/operators/addNode.d.ts +1 -0
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +7 -0
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts +4 -3
- package/lib/tree/nodes/operators/binomialCoefficientNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/binomialCoefficientNode.js +24 -5
- package/lib/tree/nodes/operators/divideNode.d.ts +1 -0
- package/lib/tree/nodes/operators/divideNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/divideNode.js +7 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts +1 -0
- package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/fractionNode.js +7 -0
- package/lib/tree/nodes/operators/limitNode.d.ts +1 -0
- package/lib/tree/nodes/operators/limitNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/limitNode.js +7 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -0
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +7 -0
- package/lib/tree/nodes/operators/powerNode.d.ts +1 -0
- package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/powerNode.js +7 -0
- package/lib/tree/nodes/operators/substractNode.d.ts +1 -0
- package/lib/tree/nodes/operators/substractNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/substractNode.js +7 -0
- package/lib/tree/nodes/polynomials/monomNode.d.ts +1 -0
- package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -1
- package/lib/tree/nodes/polynomials/monomNode.js +7 -0
- package/lib/tree/nodes/polynomials/trinomNode.d.ts +1 -0
- package/lib/tree/nodes/polynomials/trinomNode.d.ts.map +1 -1
- package/lib/tree/nodes/polynomials/trinomNode.js +7 -0
- package/lib/tree/nodes/sets/belongsNode.d.ts +1 -0
- package/lib/tree/nodes/sets/belongsNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/belongsNode.js +7 -0
- package/lib/tree/nodes/sets/discreteSetNode.d.ts +1 -0
- package/lib/tree/nodes/sets/discreteSetNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/discreteSetNode.js +7 -0
- package/lib/tree/nodes/sets/intervalNode.d.ts +1 -0
- package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/intervalNode.js +7 -0
- package/lib/tree/nodes/sets/unionIntervalNode.d.ts +1 -0
- package/lib/tree/nodes/sets/unionIntervalNode.d.ts.map +1 -1
- package/lib/tree/nodes/sets/unionIntervalNode.js +7 -0
- package/lib/tree/nodes/variables/variableNode.d.ts +1 -0
- package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
- package/lib/tree/nodes/variables/variableNode.js +7 -0
- package/lib/tree/parsers/vectorParser.d.ts.map +1 -1
- package/lib/tree/parsers/vectorParser.js +8 -0
- package/lib/tree/utilities/nodeShuffler.d.ts.map +1 -1
- package/lib/tree/utilities/nodeShuffler.js +3 -0
- package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -1
- package/lib/tree/utilities/nodeSimplifier.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getOptionIsUsePythonDefStuff, } from "../../../../exercises/options/optionIsUsePythonDef.js";
|
|
3
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
4
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
5
|
+
const codify = (strPython) => {
|
|
6
|
+
return `\`\`\`python
|
|
7
|
+
${strPython}
|
|
8
|
+
\`\`\``;
|
|
9
|
+
};
|
|
10
|
+
const codifyChunk = (strPython) => {
|
|
11
|
+
return `\`${strPython}\``;
|
|
12
|
+
};
|
|
13
|
+
const _createStrPythonForNode = (nodeUNext) => {
|
|
14
|
+
return nodeUNext.toMathString().replaceAll("^", "**");
|
|
15
|
+
};
|
|
16
|
+
const uncypherRandModFour = (cyRandModFour) => {
|
|
17
|
+
return (cyRandModFour - 1) % 4;
|
|
18
|
+
};
|
|
19
|
+
const cypherRandModFour = (randModFour) => {
|
|
20
|
+
return randModFour + 1;
|
|
21
|
+
};
|
|
22
|
+
const _getStrPythonProgram = (opts) => {
|
|
23
|
+
const { isUsePythonDef } = opts;
|
|
24
|
+
if (isUsePythonDef) {
|
|
25
|
+
return `def factorielle(n):
|
|
26
|
+
v = 1
|
|
27
|
+
for i in range(1,n):
|
|
28
|
+
v = v * i
|
|
29
|
+
return v
|
|
30
|
+
|
|
31
|
+
print(factorielle(n))
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return `v = 1
|
|
36
|
+
for i in range(1,n):
|
|
37
|
+
v = v * i
|
|
38
|
+
print(v)
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const getStrPythonProgramValid = (identifiers, opts) => {
|
|
43
|
+
const identifiersTweaked = {
|
|
44
|
+
...identifiers,
|
|
45
|
+
cyRandModFour: undefined,
|
|
46
|
+
};
|
|
47
|
+
return getStrPythonProgramInvalid(identifiersTweaked, opts);
|
|
48
|
+
};
|
|
49
|
+
const getStrPythonProgramInvalid = (identifiers, opts) => {
|
|
50
|
+
const { isUsePythonDef } = opts;
|
|
51
|
+
const { cyRandModFour } = identifiers;
|
|
52
|
+
const randModFour = cyRandModFour ? uncypherRandModFour(cyRandModFour) : -1;
|
|
53
|
+
const { strInitialization, strForLoop, strLoopBody, strPrint } = Object.fromEntries(Object.entries(getDictStrCompletion(identifiers, opts)).map(([key, miniDict], i) => i === randModFour ? [key, miniDict.invalid] : [key, miniDict.valid]));
|
|
54
|
+
if (isUsePythonDef) {
|
|
55
|
+
return `def factorielle(n):
|
|
56
|
+
${strInitialization}
|
|
57
|
+
${strForLoop}
|
|
58
|
+
${strLoopBody}
|
|
59
|
+
return v
|
|
60
|
+
|
|
61
|
+
${strPrint}
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return `${strInitialization}
|
|
66
|
+
${strForLoop}
|
|
67
|
+
${strLoopBody}
|
|
68
|
+
${strPrint}
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const getDictStrCompletion = (identifiers, opts) => {
|
|
73
|
+
const { isUsePythonDef } = opts;
|
|
74
|
+
const { nAsked, arrRandForStr } = identifiers;
|
|
75
|
+
const [randStrInitialization, randStrForLoop, randStrLoopBody, randStrPrint] = arrRandForStr;
|
|
76
|
+
function getStrFromArr(arrStr, rand) {
|
|
77
|
+
const i = rand % arrStr.length;
|
|
78
|
+
return arrStr[i];
|
|
79
|
+
}
|
|
80
|
+
if (isUsePythonDef) {
|
|
81
|
+
return {
|
|
82
|
+
strInitialization: {
|
|
83
|
+
valid: getStrFromArr(["v = 1"], randStrInitialization),
|
|
84
|
+
invalid: getStrFromArr([
|
|
85
|
+
//inits with 0
|
|
86
|
+
"v = 0",
|
|
87
|
+
//wrong variable
|
|
88
|
+
"x = 1",
|
|
89
|
+
"n = 1",
|
|
90
|
+
], randStrInitialization),
|
|
91
|
+
},
|
|
92
|
+
strForLoop: {
|
|
93
|
+
valid: getStrFromArr(["for i in range(1,n+1):"], randStrForLoop),
|
|
94
|
+
invalid: getStrFromArr([
|
|
95
|
+
//starts at 0
|
|
96
|
+
"for i in range(n+1):",
|
|
97
|
+
"for i in range(n):",
|
|
98
|
+
"for i in range(n-1):",
|
|
99
|
+
//missing :
|
|
100
|
+
"for i in range(1,n+1)",
|
|
101
|
+
"for i in range(1,n)",
|
|
102
|
+
"for i in range(1,n-1)",
|
|
103
|
+
], randStrForLoop),
|
|
104
|
+
},
|
|
105
|
+
strLoopBody: {
|
|
106
|
+
valid: getStrFromArr(["v = v * i", "v = i * v"], randStrLoopBody),
|
|
107
|
+
invalid: getStrFromArr([
|
|
108
|
+
//uses n
|
|
109
|
+
"n = n * i",
|
|
110
|
+
"n = i * n",
|
|
111
|
+
"v = i * n",
|
|
112
|
+
"v = n * i",
|
|
113
|
+
//i -> (i+1)
|
|
114
|
+
"v = v * (i+1)",
|
|
115
|
+
"v = (i+1) * v",
|
|
116
|
+
], randStrLoopBody),
|
|
117
|
+
},
|
|
118
|
+
strPrint: {
|
|
119
|
+
valid: getStrFromArr([`print(factorielle(${nAsked}))`], randStrPrint),
|
|
120
|
+
invalid: getStrFromArr([
|
|
121
|
+
"print(factorielle(n))",
|
|
122
|
+
"factorielle(n)",
|
|
123
|
+
`print(factorielle(${nAsked - 1}))`,
|
|
124
|
+
`factorielle(${nAsked - 1})`,
|
|
125
|
+
`factorielle(${nAsked})`,
|
|
126
|
+
"print(factorielle)",
|
|
127
|
+
`print(factorielle[${nAsked}])`,
|
|
128
|
+
], randStrPrint),
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
return {
|
|
134
|
+
strInitialization: {
|
|
135
|
+
valid: getStrFromArr(["v = 1"], randStrInitialization),
|
|
136
|
+
invalid: getStrFromArr([
|
|
137
|
+
//inits with 0
|
|
138
|
+
"v = 0",
|
|
139
|
+
//wrong variable
|
|
140
|
+
"x = 1",
|
|
141
|
+
"n = 1",
|
|
142
|
+
], randStrInitialization),
|
|
143
|
+
},
|
|
144
|
+
strForLoop: {
|
|
145
|
+
valid: getStrFromArr([`for i in range(1,${nAsked + 1}):`], randStrForLoop),
|
|
146
|
+
invalid: getStrFromArr([
|
|
147
|
+
//starts at 0
|
|
148
|
+
`for i in range(${nAsked + 1}):`,
|
|
149
|
+
`for i in range(${nAsked}):`,
|
|
150
|
+
`for i in range(${nAsked - 1}):`,
|
|
151
|
+
//missing :
|
|
152
|
+
`for i in range(1,${nAsked + 1})`,
|
|
153
|
+
`for i in range(1,${nAsked})`,
|
|
154
|
+
`for i in range(1,${nAsked - 1})`,
|
|
155
|
+
], randStrForLoop),
|
|
156
|
+
},
|
|
157
|
+
strLoopBody: {
|
|
158
|
+
valid: getStrFromArr(["v = v * i", "v = i * v"], randStrLoopBody),
|
|
159
|
+
invalid: getStrFromArr([
|
|
160
|
+
//uses n
|
|
161
|
+
"n = n * i",
|
|
162
|
+
"n = i * n",
|
|
163
|
+
"v = i * n",
|
|
164
|
+
"v = n * i",
|
|
165
|
+
//i -> (i+1)
|
|
166
|
+
"v = v * (i+1)",
|
|
167
|
+
"v = (i+1) * v",
|
|
168
|
+
], randStrLoopBody),
|
|
169
|
+
},
|
|
170
|
+
strPrint: {
|
|
171
|
+
valid: getStrFromArr([`print(v)`], randStrPrint),
|
|
172
|
+
invalid: getStrFromArr([
|
|
173
|
+
"v",
|
|
174
|
+
"print(n)",
|
|
175
|
+
`print(i)`,
|
|
176
|
+
`print(v*${nAsked})`,
|
|
177
|
+
`print(v[${nAsked}])`,
|
|
178
|
+
], randStrPrint),
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const getInstruction = (identifiers, optsIn) => {
|
|
184
|
+
const opts = optsIn ?? optsDefault;
|
|
185
|
+
const { nAsked } = identifiers;
|
|
186
|
+
return `Quelqu'un a codé ce programme Python dans le but d'afficher la valeur de $${nAsked}!$ (pour $n \\geq 1$, $n!$ ("factorielle $n$") est le produit des entiers compris entre $1$ et $n$ inclus).
|
|
187
|
+
|
|
188
|
+
${codify(getStrPythonProgramInvalid(identifiers, opts))}
|
|
189
|
+
|
|
190
|
+
Quelle instruction est erronée dans ce programme ?
|
|
191
|
+
|
|
192
|
+
`;
|
|
193
|
+
};
|
|
194
|
+
const getAnswer = (identifiers, optsIn) => {
|
|
195
|
+
const opts = optsIn ?? optsDefault;
|
|
196
|
+
const { cyRandModFour } = identifiers;
|
|
197
|
+
const randModFour = cyRandModFour ? uncypherRandModFour(cyRandModFour) : -1;
|
|
198
|
+
const arrEntry = Object.entries(getDictStrCompletion(identifiers, opts));
|
|
199
|
+
const [_, miniDict] = arrEntry[randModFour];
|
|
200
|
+
const strInstructionInvalid = miniDict.invalid;
|
|
201
|
+
return codifyChunk(strInstructionInvalid);
|
|
202
|
+
};
|
|
203
|
+
const getHint = () => {
|
|
204
|
+
return `Regarde s'il y a des erreurs de syntaxe et s'il n'y en a pas, essaye d'exécuter le programme pour détecter ce qui ne va pas.`;
|
|
205
|
+
};
|
|
206
|
+
const getCorrection = (identifiers, optsIn) => {
|
|
207
|
+
const opts = optsIn ?? optsDefault;
|
|
208
|
+
return `Voici le programme corrigé :
|
|
209
|
+
|
|
210
|
+
${codify(getStrPythonProgramValid(identifiers, opts))}
|
|
211
|
+
|
|
212
|
+
`;
|
|
213
|
+
};
|
|
214
|
+
const getPropositions = (_n, { answer, ...identifiers }, optsIn) => {
|
|
215
|
+
const opts = optsIn ?? optsDefault;
|
|
216
|
+
const { cyRandModFour } = identifiers;
|
|
217
|
+
const randModFour = cyRandModFour ? uncypherRandModFour(cyRandModFour) : -1;
|
|
218
|
+
const propositions = [];
|
|
219
|
+
Object.entries(getDictStrCompletion(identifiers, opts)).forEach(([_, miniDict], i) => {
|
|
220
|
+
if (i === randModFour) {
|
|
221
|
+
const strInstruction = miniDict.invalid;
|
|
222
|
+
addValidProp(propositions, codifyChunk(strInstruction), "raw");
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const strInstruction = miniDict.valid;
|
|
226
|
+
tryToAddWrongProp(propositions, codifyChunk(strInstruction), "raw");
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
return propositions;
|
|
230
|
+
};
|
|
231
|
+
const createRandomIdentifiers = (_opts) => {
|
|
232
|
+
const cyRandModFour = cypherRandModFour(randint(20, 100));
|
|
233
|
+
const nAsked = randint(9, 20);
|
|
234
|
+
const arrRandForStr = [...Array(4).keys()].map(() => randint(10, 50));
|
|
235
|
+
const identifiers = { cyRandModFour, nAsked, arrRandForStr };
|
|
236
|
+
return identifiers;
|
|
237
|
+
};
|
|
238
|
+
const getPySequenceFactorialInstructionFalseOneOutQuestion = (optsIn) => {
|
|
239
|
+
const opts = optsIn ?? optsDefault;
|
|
240
|
+
const identifiers = createRandomIdentifiers(opts);
|
|
241
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
242
|
+
};
|
|
243
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
244
|
+
const question = {
|
|
245
|
+
answer: getAnswer(identifiers, opts),
|
|
246
|
+
instruction: getInstruction(identifiers, opts),
|
|
247
|
+
keys: [],
|
|
248
|
+
answerFormat: "tex",
|
|
249
|
+
identifiers,
|
|
250
|
+
hint: getHint(identifiers, opts),
|
|
251
|
+
correction: getCorrection(identifiers, opts),
|
|
252
|
+
options: opts,
|
|
253
|
+
};
|
|
254
|
+
return question;
|
|
255
|
+
};
|
|
256
|
+
const { optsDefaultIsUsePythonDef, generatorOptionIsUsePythonDef } = getOptionIsUsePythonDefStuff(false);
|
|
257
|
+
const optsDefault = {
|
|
258
|
+
...optsDefaultIsUsePythonDef,
|
|
259
|
+
};
|
|
260
|
+
const options = [generatorOptionIsUsePythonDef];
|
|
261
|
+
export const pySequenceFactorialInstructionFalseOneOut = {
|
|
262
|
+
id: "pySequenceFactorialInstructionFalseOneOut",
|
|
263
|
+
label: "Déterminer l'instruction fausse dans un algorithme de calcul de factorielle",
|
|
264
|
+
isSingleStep: true,
|
|
265
|
+
generator: (nb, opts) => getDistinctQuestions(() => getPySequenceFactorialInstructionFalseOneOutQuestion(opts), nb),
|
|
266
|
+
options,
|
|
267
|
+
qcmTimer: 60,
|
|
268
|
+
freeTimer: 60,
|
|
269
|
+
getPropositions,
|
|
270
|
+
subject: "Mathématiques",
|
|
271
|
+
getQuestionFromIdentifiers,
|
|
272
|
+
hasHintAndCorrection: true,
|
|
273
|
+
answerType: "QCU",
|
|
274
|
+
};
|
package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { OptionFirstTermRankOne } from "../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
firstValue: number;
|
|
5
|
+
lengthAsked: number;
|
|
6
|
+
coeffs: number[];
|
|
7
|
+
isUseFuncRecur: boolean;
|
|
8
|
+
};
|
|
9
|
+
type Options = OptionFirstTermRankOne;
|
|
10
|
+
export declare const pySequenceFirstTermsListInstructionCompletion: Exercise<Identifiers, Options>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=pySequenceFirstTermsListInstructionCompletion.d.ts.map
|
package/lib/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pySequenceFirstTermsListInstructionCompletion.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/python/sequences/pySequenceFirstTermsListInstructionCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AA2E3D,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAyWF,KAAK,OAAO,GAAG,sBAAsB,CAAC;AAMtC,eAAO,MAAM,6CAA6C,EAAE,QAAQ,CAClE,WAAW,EACX,OAAO,CAmBR,CAAC"}
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { getOptionFirstTermRankOneStuff, } from "../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
4
|
+
import { Trinom } from "../../../../math/polynomials/trinom.js";
|
|
5
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
6
|
+
import { randint } from "../../../../math/utils/random/randint.js";
|
|
7
|
+
import { add } from "../../../../tree/nodes/operators/addNode.js";
|
|
8
|
+
import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
|
|
9
|
+
import { power } from "../../../../tree/nodes/operators/powerNode.js";
|
|
10
|
+
import { substract } from "../../../../tree/nodes/operators/substractNode.js";
|
|
11
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
12
|
+
const codify = (strPython) => {
|
|
13
|
+
return `\`\`\`python
|
|
14
|
+
${strPython}
|
|
15
|
+
\`\`\``;
|
|
16
|
+
};
|
|
17
|
+
const codifyChunk = (strPython) => {
|
|
18
|
+
return `\`${strPython}\``;
|
|
19
|
+
};
|
|
20
|
+
const createStrPythonForNodeUNext = (nodeUNext) => {
|
|
21
|
+
return nodeUNext
|
|
22
|
+
.toMathString()
|
|
23
|
+
.replaceAll("u_{n}", "u")
|
|
24
|
+
.replaceAll("^", "**");
|
|
25
|
+
};
|
|
26
|
+
const createNodeUNext = (coeffs) => {
|
|
27
|
+
const nodeUn = "u_{n}".toTree();
|
|
28
|
+
let nodeUNext;
|
|
29
|
+
const [c, b, a] = coeffs;
|
|
30
|
+
if (a !== undefined) {
|
|
31
|
+
//trinom recur
|
|
32
|
+
const trinom = new Trinom(a, b, c, { variable: nodeUn.toTex() });
|
|
33
|
+
nodeUNext = trinom.toTree();
|
|
34
|
+
}
|
|
35
|
+
else if (b !== undefined) {
|
|
36
|
+
if (c !== 0) {
|
|
37
|
+
//arithmetico-geometric (=== affine recur)
|
|
38
|
+
nodeUNext = add(multiply(b, nodeUn), c);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
//geometric
|
|
42
|
+
nodeUNext = multiply(b, nodeUn);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
//arithmetic
|
|
47
|
+
nodeUNext = add(nodeUn, c);
|
|
48
|
+
}
|
|
49
|
+
return nodeUNext;
|
|
50
|
+
};
|
|
51
|
+
const createNodeUExplicit = (firstValue, firstRank, coeffs) => {
|
|
52
|
+
const nodeFactor = firstRank === 0 ? "n".toTree() : substract("n".toTree(), firstRank);
|
|
53
|
+
const [c, b, a] = coeffs;
|
|
54
|
+
if (a !== undefined) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
else if (b !== undefined) {
|
|
58
|
+
if (c !== 0) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
//geometric
|
|
63
|
+
return multiply(firstValue, power(b, nodeFactor));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
//arithmetic
|
|
68
|
+
return add(firstValue, multiply(c, nodeFactor));
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const getStrPythonProgramIncomplete = (identifiers, optsIn) => {
|
|
72
|
+
const opts = optsIn ?? optsDefault;
|
|
73
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
74
|
+
const { firstValue, isUseFuncRecur, coeffs, lengthAsked } = identifiers;
|
|
75
|
+
if (isUseFuncRecur) {
|
|
76
|
+
const nodeUNext = createNodeUNext(coeffs);
|
|
77
|
+
return `def terme_suivant(u):
|
|
78
|
+
return ${createStrPythonForNodeUNext(nodeUNext)}
|
|
79
|
+
|
|
80
|
+
def creer_liste(n):
|
|
81
|
+
u = [${firstValue}]
|
|
82
|
+
for i in range(n - 1):
|
|
83
|
+
...
|
|
84
|
+
|
|
85
|
+
print(creer_liste(${lengthAsked}))
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const nodeUExplicit = createNodeUExplicit(firstValue, firstRank, coeffs);
|
|
90
|
+
return `def terme_u(n):
|
|
91
|
+
return ${createStrPythonForNodeUNext(nodeUExplicit)}
|
|
92
|
+
|
|
93
|
+
def creer_liste(n):
|
|
94
|
+
u = [${firstValue}]
|
|
95
|
+
for i in range(n - 1):
|
|
96
|
+
...
|
|
97
|
+
|
|
98
|
+
print(creer_liste(${lengthAsked}))
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const getInstruction = (identifiers, optsIn) => {
|
|
103
|
+
const opts = optsIn ?? optsDefault;
|
|
104
|
+
const { lengthAsked } = identifiers;
|
|
105
|
+
return `Le programme suivant sert à créer la liste des $${lengthAsked}$ premiers termes d'une suite $u_{n}$.
|
|
106
|
+
|
|
107
|
+
Par quoi faut-il remplacer les pointillés dans le programme suivant pour que le programme fonctionne correctement ?
|
|
108
|
+
|
|
109
|
+
${codify(getStrPythonProgramIncomplete(identifiers, opts))}
|
|
110
|
+
|
|
111
|
+
`;
|
|
112
|
+
};
|
|
113
|
+
const getAnswer = (identifiers, optsIn) => {
|
|
114
|
+
const opts = optsIn ?? optsDefault;
|
|
115
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
116
|
+
const { isUseFuncRecur } = identifiers;
|
|
117
|
+
if (isUseFuncRecur) {
|
|
118
|
+
return codifyChunk("u.append(terme_suivant(u[i]))");
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return codifyChunk(`u.append(terme_u(${firstRank + 1}+i))`);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const getHint = () => {
|
|
125
|
+
return `Trouve une instruction qui va :
|
|
126
|
+
- créer un nouveau terme (en appelant une fonction définie dans le programme)
|
|
127
|
+
- mettre cette valeur en bout de liste
|
|
128
|
+
`;
|
|
129
|
+
};
|
|
130
|
+
const getCorrection = (identifiers, optsIn) => {
|
|
131
|
+
const opts = optsIn ?? optsDefault;
|
|
132
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
133
|
+
const { isUseFuncRecur } = identifiers;
|
|
134
|
+
if (isUseFuncRecur) {
|
|
135
|
+
return `La fonction mise à disposition s'appelle ${codifyChunk("terme_suivant")}.
|
|
136
|
+
Elle calcule le terme qui suit le terme ${codifyChunk("u")} passé en argument.
|
|
137
|
+
|
|
138
|
+
Dans la fonction ${codifyChunk("creer_liste")}, ${codifyChunk("u")} désigne la liste qui est créée progressivement.
|
|
139
|
+
À la première itération (quand ${codifyChunk("i")} vaut $0$), on va utiliser ${codifyChunk("u[0]")}.
|
|
140
|
+
À la deuxième itération (quand ${codifyChunk("i")} vaut $1$), on va utiliser ${codifyChunk("u[1]")}.
|
|
141
|
+
Autrement dit, à l'itération ${codifyChunk("i")}, on va utiliser ${codifyChunk("u[i]")}.
|
|
142
|
+
|
|
143
|
+
Le nouveau terme sera donc ${codifyChunk("terme_suivant(u[i])")}
|
|
144
|
+
|
|
145
|
+
Il ne reste plus qu'à l'ajouter à la liste pour que tout s'enchaîne correctement.
|
|
146
|
+
On veut donc écrire
|
|
147
|
+
|
|
148
|
+
${codify("u.append(terme_suivant(u[i]))")}
|
|
149
|
+
|
|
150
|
+
`;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
return `La fonction mise à disposition s'appelle ${codifyChunk("terme_u")}.
|
|
154
|
+
Elle calcule le terme à l'indice ${codifyChunk("n")} passé en argument.
|
|
155
|
+
|
|
156
|
+
Dans la fonction ${codifyChunk("creer_liste")}, ${codifyChunk("u")} désigne la liste qui est créée progressivement.
|
|
157
|
+
${codifyChunk("u[0]")} est la valeur de $u_{${firstRank}}$.
|
|
158
|
+
Pour créer ${codifyChunk("u[1]")} ($u_{${firstRank + 1}}$), on appelle donc ${codifyChunk(`terme_u(${firstRank + 1})`)}.
|
|
159
|
+
Pour créer ${codifyChunk("u[1+i]")} ($u_{i}$), on appelle donc ${codifyChunk(`terme_u(${firstRank + 1}+i)`)}.
|
|
160
|
+
|
|
161
|
+
Le nouveau terme sera donc ${codifyChunk(`terme_u(${firstRank + 1}+i)`)}
|
|
162
|
+
|
|
163
|
+
Il ne reste plus qu'à l'ajouter à la liste pour que tout s'enchaîne correctement.
|
|
164
|
+
On veut donc écrire
|
|
165
|
+
|
|
166
|
+
${codify(`u.append(terme_u(${firstRank + 1}+i))`)}
|
|
167
|
+
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const getPropositions = (n, { answer, ...identifiers }, optsIn) => {
|
|
172
|
+
const opts = optsIn ?? optsDefault;
|
|
173
|
+
const firstRank = opts.firstTermRankOne ? 1 : 0;
|
|
174
|
+
const propositions = [];
|
|
175
|
+
addValidProp(propositions, answer, "raw");
|
|
176
|
+
const { isUseFuncRecur } = identifiers;
|
|
177
|
+
if (isUseFuncRecur) {
|
|
178
|
+
const _strValid = "u.append(terme_suivant(u[i]))";
|
|
179
|
+
//student: forgets to append
|
|
180
|
+
{
|
|
181
|
+
const strProgramChunk = codifyChunk(`terme_suivant(u[i])`);
|
|
182
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
183
|
+
}
|
|
184
|
+
//student: u.append(...) -> u=...
|
|
185
|
+
{
|
|
186
|
+
const strProgramChunk = codifyChunk(`u=terme_suivant(u[i])`);
|
|
187
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
188
|
+
}
|
|
189
|
+
//student: i -> i+1
|
|
190
|
+
{
|
|
191
|
+
{
|
|
192
|
+
const strProgramChunk = codifyChunk(`u.append(terme_suivant(u[i+1]))`);
|
|
193
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
194
|
+
}
|
|
195
|
+
//student: forgets to append
|
|
196
|
+
{
|
|
197
|
+
const strProgramChunk = codifyChunk(`terme_suivant(u[i+1])`);
|
|
198
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
199
|
+
}
|
|
200
|
+
//student: u.append(...) -> u=...
|
|
201
|
+
{
|
|
202
|
+
const strProgramChunk = codifyChunk(`u=terme_suivant(u[i+1])`);
|
|
203
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
//student: magic thinking u[i+1] auto creates itself
|
|
207
|
+
{
|
|
208
|
+
{
|
|
209
|
+
const strProgramChunk = codifyChunk(`u=u[i+1]`);
|
|
210
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
211
|
+
}
|
|
212
|
+
{
|
|
213
|
+
const strProgramChunk = codifyChunk(`u.append(u[i+1])`);
|
|
214
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
215
|
+
}
|
|
216
|
+
{
|
|
217
|
+
const strProgramChunk = codifyChunk(`u[i+1]`);
|
|
218
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//student: u[i].append(...)
|
|
222
|
+
{
|
|
223
|
+
{
|
|
224
|
+
const strProgramChunk = codifyChunk(`u[i].append(terme_suivant(u[i]))`);
|
|
225
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
226
|
+
}
|
|
227
|
+
{
|
|
228
|
+
const strProgramChunk = codifyChunk(`u[i].append(u[i+1])`);
|
|
229
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
const _strValid = `u.append(terme_u(${firstRank + 1}+i))`;
|
|
235
|
+
//student: forgets to append
|
|
236
|
+
{
|
|
237
|
+
const strProgramChunk = codifyChunk(`terme_u(${firstRank + 1}+i)`);
|
|
238
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
239
|
+
}
|
|
240
|
+
//student: u.append(...) -> u=...
|
|
241
|
+
{
|
|
242
|
+
const strProgramChunk = codifyChunk(`u=terme_u(${firstRank + 1}+i)`);
|
|
243
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
244
|
+
}
|
|
245
|
+
//student: i -> i-1
|
|
246
|
+
{
|
|
247
|
+
{
|
|
248
|
+
const strProgramChunk = codifyChunk(`u.append(terme_u(${firstRank}+i))`);
|
|
249
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
250
|
+
}
|
|
251
|
+
//student: forgets to append
|
|
252
|
+
{
|
|
253
|
+
const strProgramChunk = codifyChunk(`terme_u(${firstRank}+i)`);
|
|
254
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
255
|
+
}
|
|
256
|
+
//student: u.append(...) -> u=...
|
|
257
|
+
{
|
|
258
|
+
const strProgramChunk = codifyChunk(`u=terme_u(${firstRank}+i)`);
|
|
259
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
//student: magic thinking u[i+1] auto creates itself
|
|
263
|
+
{
|
|
264
|
+
{
|
|
265
|
+
const strProgramChunk = codifyChunk(`u=u[i+1]`);
|
|
266
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
267
|
+
}
|
|
268
|
+
{
|
|
269
|
+
const strProgramChunk = codifyChunk(`u.append(u[i+1])`);
|
|
270
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
271
|
+
}
|
|
272
|
+
{
|
|
273
|
+
const strProgramChunk = codifyChunk(`u[i+1]`);
|
|
274
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
//student: u[i].append(...)
|
|
278
|
+
{
|
|
279
|
+
{
|
|
280
|
+
const strProgramChunk = codifyChunk(`u[i].append(terme_u(${firstRank + 1}+i))`);
|
|
281
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
282
|
+
}
|
|
283
|
+
{
|
|
284
|
+
const strProgramChunk = codifyChunk(`u[i].append(u[i+1])`);
|
|
285
|
+
tryToAddWrongProp(propositions, strProgramChunk, "raw");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return shuffleProps(propositions, n);
|
|
290
|
+
};
|
|
291
|
+
const createRandomIdentifiers = (_opts) => {
|
|
292
|
+
const firstValue = randint(-10, 10);
|
|
293
|
+
const lengthAsked = randint(5, 8);
|
|
294
|
+
const isUseFuncRecur = coinFlip();
|
|
295
|
+
const coeffs = [];
|
|
296
|
+
const rand = isUseFuncRecur ? randint(0, 4) : randint(0, 2);
|
|
297
|
+
switch (rand) {
|
|
298
|
+
case 0:
|
|
299
|
+
{
|
|
300
|
+
//arithmetic
|
|
301
|
+
const c = randint(-10, 10, [0]);
|
|
302
|
+
coeffs.push(c);
|
|
303
|
+
}
|
|
304
|
+
break;
|
|
305
|
+
case 1:
|
|
306
|
+
{
|
|
307
|
+
//geometric
|
|
308
|
+
const c = 0;
|
|
309
|
+
const b = randfloat(-10, 10, 2, [0]);
|
|
310
|
+
coeffs.push(...[c, b]);
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
case 2:
|
|
314
|
+
{
|
|
315
|
+
//arithmetico-geometric (=== affine recur)
|
|
316
|
+
const c = randint(-10, 10, [0]);
|
|
317
|
+
const b = randfloat(-10, 10, 2, [0]);
|
|
318
|
+
coeffs.push(...[c, b]);
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
case 3:
|
|
322
|
+
{
|
|
323
|
+
//trinom recur
|
|
324
|
+
const c = randint(-10, 10, [0]);
|
|
325
|
+
const b = randfloat(-10, 10, 2, [0]);
|
|
326
|
+
const a = randint(-2, 3, [0]);
|
|
327
|
+
coeffs.push(...[c, b, a]);
|
|
328
|
+
}
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
const identifiers = { firstValue, lengthAsked, coeffs, isUseFuncRecur };
|
|
332
|
+
return identifiers;
|
|
333
|
+
};
|
|
334
|
+
const getPySequenceFirstTermsListInstructionCompletionQuestion = (optsIn) => {
|
|
335
|
+
const opts = optsIn ?? optsDefault;
|
|
336
|
+
const identifiers = createRandomIdentifiers(opts);
|
|
337
|
+
return getQuestionFromIdentifiers(identifiers, opts);
|
|
338
|
+
};
|
|
339
|
+
const getQuestionFromIdentifiers = (identifiers, opts) => {
|
|
340
|
+
const question = {
|
|
341
|
+
answer: getAnswer(identifiers, opts),
|
|
342
|
+
instruction: getInstruction(identifiers, opts),
|
|
343
|
+
keys: [],
|
|
344
|
+
answerFormat: "tex",
|
|
345
|
+
identifiers,
|
|
346
|
+
hint: getHint(identifiers, opts),
|
|
347
|
+
correction: getCorrection(identifiers, opts),
|
|
348
|
+
options: opts,
|
|
349
|
+
};
|
|
350
|
+
return question;
|
|
351
|
+
};
|
|
352
|
+
const { optsDefaultFirstTermRankOne, generatorOptionFirstTermRankOne } = getOptionFirstTermRankOneStuff(false);
|
|
353
|
+
const optsDefault = Object.assign({}, optsDefaultFirstTermRankOne);
|
|
354
|
+
const options = [generatorOptionFirstTermRankOne];
|
|
355
|
+
export const pySequenceFirstTermsListInstructionCompletion = {
|
|
356
|
+
id: "pySequenceFirstTermsListInstructionCompletion",
|
|
357
|
+
label: "Compléter un algorithme créant la liste des premiers termes d'une suite",
|
|
358
|
+
isSingleStep: true,
|
|
359
|
+
generator: (nb, opts) => getDistinctQuestions(() => getPySequenceFirstTermsListInstructionCompletionQuestion(opts), nb),
|
|
360
|
+
options,
|
|
361
|
+
qcmTimer: 60,
|
|
362
|
+
freeTimer: 60,
|
|
363
|
+
getPropositions,
|
|
364
|
+
subject: "Mathématiques",
|
|
365
|
+
getQuestionFromIdentifiers,
|
|
366
|
+
hasHintAndCorrection: true,
|
|
367
|
+
answerType: "QCU",
|
|
368
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { OptionFirstTermRankOne } from "../../../../exercises/options/optionFirstTermRankOne.js";
|
|
3
|
+
import { OptionIsUsePythonDef } from "../../../../exercises/options/optionIsUsePythonDef.js";
|
|
4
|
+
type Identifiers = {
|
|
5
|
+
firstValue: number;
|
|
6
|
+
lengthAsked: number;
|
|
7
|
+
coeffs: number[];
|
|
8
|
+
isAnswerAlternative: boolean;
|
|
9
|
+
};
|
|
10
|
+
type Options = OptionFirstTermRankOne & OptionIsUsePythonDef;
|
|
11
|
+
export declare const pySequenceFirstTermsSumInstructionCompletion: Exercise<Identifiers, Options>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=pySequenceFirstTermsSumInstructionCompletion.d.ts.map
|
package/lib/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pySequenceFirstTermsSumInstructionCompletion.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/python/sequences/pySequenceFirstTermsSumInstructionCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,sBAAsB,EACvB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAEL,oBAAoB,EACrB,MAAM,iDAAiD,CAAC;AAkDzD,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AA4OF,KAAK,OAAO,GAAG,sBAAsB,GAAG,oBAAoB,CAAC;AAe7D,eAAO,MAAM,4CAA4C,EAAE,QAAQ,CACjE,WAAW,EACX,OAAO,CAmBR,CAAC"}
|