From 7aea7b3f9e7baa554b60afe5841edbd13ece2ce7 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Wed, 14 Oct 2020 14:34:18 -0400 Subject: [PATCH 1/4] Added to List of Generators --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9c005dd..e958a5b 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ problem, solution = mathgen.addition() ``` ## List of Generators -| Id | Skill | Example problem | Example Solution | Function Name | Status | -|------|----------------------------|-----------------|-------------------|----------------|-------------| -| 2 | Addition | 1+5= | 6 | addition | Complete | -| 3 | Subtraction | 9-4= | 5 | subtraction | Complete | -| 4 | Multiplication | 4*6= | 24 | | Not Started | -| 5 | Division | 4/2= | 2 | | Not Started | -| - | Factoring | x^2+x-6 | (x-2)(x+3) | | Not Started | -| - | Power Rule Differentiation | x^5 | 5x^4 | | Not Started | +| Id | Skill | Example problem | Example Solution | Function Name | Status | +|------|----------------------------|-----------------|-------------------|--------------------|-------------| +| 2 | Addition | 1+5= | 6 | addition | Complete | +| 3 | Subtraction | 9-4= | 5 | subtraction | Complete | +| 4 | Multiplication | 4*6= | 24 | multiplication | Complete | +| 5 | Division | 4/2= | 2 | division | Complete | +| 6 | Binary Complement 1s | 1010= | 0101 | binaryComplement1s | Complete | +| 7 | Modulo Division | 10%3= | 1 | moduloDivision | Complete | From 8e1277a56aa550a66db56890cd426a980a656e60 Mon Sep 17 00:00:00 2001 From: mushahidq Date: Thu, 15 Oct 2020 00:27:03 +0530 Subject: [PATCH 2/4] Added square root --- mathgenerator/mathgen.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 109c9b8..0931109 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -71,6 +71,13 @@ def moduloFunc(maxRes = 99, maxModulo= 99): solution = str(c) return problem, solution +def squareRootFunction(minNo = 1, maxNo = 12): + b = random.randint(minNo, maxNo) + a = b*b + problem = "sqrt(" + str(a) + ")=" + solution = str(b) + return problem, solution + # || Class Instances #Format is: @@ -81,4 +88,4 @@ multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) binaryComplement1s = Generator("binary_complement_1s", 6, "1010=", "0101", binaryComplement1sFunc) moduloDivision = Generator("Modulo_Division", 7, "a%b=", "c", moduloFunc) - +squareRoot = Generator("Square _Root", 8, "sqrt(a)=", "b", squareRootFunction) \ No newline at end of file From e01f17c0a62c311d54f2e3123aeeeb5ca162897f Mon Sep 17 00:00:00 2001 From: Akash Saravanan Date: Thu, 15 Oct 2020 00:50:08 +0530 Subject: [PATCH 3/4] Add power rule differentiation. --- mathgenerator/mathgen.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 0931109..911f979 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -78,6 +78,20 @@ def squareRootFunction(minNo = 1, maxNo = 12): solution = str(b) return problem, solution +def powerRuleDifferentiationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5): + numTerms = random.randint(1, maxTerms) + problem = "" + solution = "" + for i in range(numTerms): + if i > 0: + problem += " + " + solution += " + " + coefficient = random.randint(1, maxCoef) + exponent = random.randint(1, maxExp) + problem += str(coefficient) + "x^" + str(exponent) + solution += str(coefficient * exponent) + "x^" + str(exponent - 1) + return problem, solution + # || Class Instances #Format is: @@ -88,4 +102,5 @@ multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) binaryComplement1s = Generator("binary_complement_1s", 6, "1010=", "0101", binaryComplement1sFunc) moduloDivision = Generator("Modulo_Division", 7, "a%b=", "c", moduloFunc) -squareRoot = Generator("Square _Root", 8, "sqrt(a)=", "b", squareRootFunction) \ No newline at end of file +squareRoot = Generator("Square _Root", 8, "sqrt(a)=", "b", squareRootFunction) +powerRuleDifferentiation = Generator("Power_Rule_Differentiation", 9, "nx^m=", "(n*m)x^(m-1)", powerRuleDifferentiationFunc) \ No newline at end of file From 0a9cdade7364ffa443bcaa790aa8bd595858adb9 Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Wed, 14 Oct 2020 19:34:48 -0400 Subject: [PATCH 4/4] Fix title inconsistency --- mathgenerator/mathgen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 911f979..87f6d56 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -102,5 +102,5 @@ multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) binaryComplement1s = Generator("binary_complement_1s", 6, "1010=", "0101", binaryComplement1sFunc) moduloDivision = Generator("Modulo_Division", 7, "a%b=", "c", moduloFunc) -squareRoot = Generator("Square _Root", 8, "sqrt(a)=", "b", squareRootFunction) -powerRuleDifferentiation = Generator("Power_Rule_Differentiation", 9, "nx^m=", "(n*m)x^(m-1)", powerRuleDifferentiationFunc) \ No newline at end of file +squareRoot = Generator("Square_Root", 8, "sqrt(a)=", "b", squareRootFunction) +powerRuleDifferentiation = Generator("Power_Rule_Differentiation", 9, "nx^m=", "(n*m)x^(m-1)", powerRuleDifferentiationFunc)