From 503a92f136242848188d3db5bb14a07e53f04bdb Mon Sep 17 00:00:00 2001 From: Luke Weiler Date: Wed, 14 Oct 2020 14:28:01 -0400 Subject: [PATCH 01/11] Update 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 e01f17c0a62c311d54f2e3123aeeeb5ca162897f Mon Sep 17 00:00:00 2001 From: Akash Saravanan Date: Thu, 15 Oct 2020 00:50:08 +0530 Subject: [PATCH 02/11] 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 03/11] 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) From eb4160b6660c6f251aa9f3cd47888be73349cbce Mon Sep 17 00:00:00 2001 From: Ganesh Futane <63470761+ganesh003@users.noreply.github.com> Date: Wed, 14 Oct 2020 16:37:29 -0700 Subject: [PATCH 04/11] Update mathgen.py --- mathgenerator/mathgen.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 87f6d56..a099fd5 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -92,6 +92,14 @@ def powerRuleDifferentiationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5): solution += str(coefficient * exponent) + "x^" + str(exponent - 1) return problem, solution +def squareFunc(maxSquareNum = 20): + a = random.randint(1, maxSquareNum) + b = a * a + problem = str(a) + "^2" + "=" + solution = str(b) + return problem, solution + + # || Class Instances #Format is: @@ -104,3 +112,4 @@ binaryComplement1s = Generator("binary_complement_1s", 6, "1010=", "0101", binar 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) +square = Generator("Square", 10,"a^2", "b", squareFunc) From 2b5a8e4c6f52a2821dd23cf059df83d7f593501c Mon Sep 17 00:00:00 2001 From: lukew3 Date: Wed, 14 Oct 2020 19:42:51 -0400 Subject: [PATCH 05/11] Updated list of generators --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e958a5b..d2043a6 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,13 @@ 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 | 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 | +| 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 | +| 8 | Square Root | sqrt(a)= | b | squareRootFunction | Complete | +| 9 | Power Rule Differentiation | nx^m | (n*m)x^(m-1) | powerRuleDifferentiation | Complete | From c55298a91080b743026344bece6f9b691a22129d Mon Sep 17 00:00:00 2001 From: lukew3 Date: Wed, 14 Oct 2020 19:45:16 -0400 Subject: [PATCH 06/11] Changed version number and removed unecessary entry point --- setup.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 27cc2a5..e2e36d7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='mathgenerator', - version='1.0.2', + version='1.1.0', description='An open source solution for generating math problems', url='https://github.com/todarith/mathgenerator', author='Luke Weiler', @@ -10,11 +10,7 @@ setup( license='MIT', packages=find_packages(), install_requires=[ - ], entry_points={ - 'console_scripts': [ - 'mathgenerator=mathgenerator.generator:main' - ], - }, + } ) From 8cfbb07ac3ef9a3fcfd5076965f79ccf07f2d2dd Mon Sep 17 00:00:00 2001 From: Ganesh Futane <63470761+ganesh003@users.noreply.github.com> Date: Wed, 14 Oct 2020 16:57:35 -0700 Subject: [PATCH 07/11] LCM, GCD fucntion update Updated the maxVal default --- mathgenerator/mathgen.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index a099fd5..33061c8 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -99,6 +99,27 @@ def squareFunc(maxSquareNum = 20): solution = str(b) return problem, solution +def gcdFunc(maxVal=20): + a = random.randint(1, maxVal) + b = random.randint(1, maxVal) + x, y = a, b + while(y): + x, y = y, x % y + problem = f"GCD of {a} and {b} = " + solution = str(x) + return problem, solution + +def lcmFunc(maxVal=20): + a = random.randint(1, maxVal) + b = random.randint(1, maxVal) + x, y = a, b + c = a * b + while(y): + x, y = y, x % y + d = c // x + problem = f"LCM of {a} and {b} = " + solution = str(d) + return problem, solution # || Class Instances @@ -113,3 +134,5 @@ 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) square = Generator("Square", 10,"a^2", "b", squareFunc) +lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc) +gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc) From d3468fe9263d78dec82159e6de6adcb7e4cf6272 Mon Sep 17 00:00:00 2001 From: Ganesh Futane <63470761+ganesh003@users.noreply.github.com> Date: Wed, 14 Oct 2020 17:10:40 -0700 Subject: [PATCH 08/11] Updated Basic Algebra Function fixed the denominator issue --- mathgenerator/mathgen.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 33061c8..791a047 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -121,6 +121,26 @@ def lcmFunc(maxVal=20): solution = str(d) return problem, solution +def basicAlgebraFunc(maxVariable = 10): + a = random.randint(1, maxVariable) + b = random.randint(1, maxVariable) + c = random.randint(b, maxVariable) + # calculate gcd + def calculate_gcd(x, y): + while(y): + x, y = y, x % y + return x + i = calculate_gcd((c - b), a) + x = f"{(c - b)//i}/{a//i}" + if (c - b == 0): + x = "0" + elif a == 1 or a == i : + x = f"{c - b}" + problem = f"{a}x + {b} = {c}" + solution = x + return problem, solution + + # || Class Instances #Format is: @@ -136,3 +156,4 @@ powerRuleDifferentiation = Generator("Power_Rule_Differentiation", 9, "nx^m=", " square = Generator("Square", 10,"a^2", "b", squareFunc) lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc) gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc) +basicAlgebra = Generator("Basic_Algebra", 13, "ax + b = c", "d", basicAlgebraFunc) From 991da6949e3af35bc1b5cd39676b766ba00f3095 Mon Sep 17 00:00:00 2001 From: Thromax Date: Thu, 15 Oct 2020 02:46:41 +0200 Subject: [PATCH 09/11] Added logarithm Added logarithm --- mathgenerator/mathgen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 791a047..322f429 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -140,6 +140,13 @@ def basicAlgebraFunc(maxVariable = 10): solution = x return problem, solution +def logFunc(maxBase=3, maxVal=8): + a = random.randint(1, maxVal) + b = random.randint(2, maxBase) + c = pow(b,a) + problem = "log"+str(b)+"("+str(c)+")" + solution = str(a) + return problem, solution # || Class Instances @@ -157,3 +164,4 @@ square = Generator("Square", 10,"a^2", "b", squareFunc) lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc) gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc) basicAlgebra = Generator("Basic_Algebra", 13, "ax + b = c", "d", basicAlgebraFunc) +log = Generator("Logarithm", 13, "log2(8)", "3", logFunc) From bcffaa0f470af341385e495a182826878166c675 Mon Sep 17 00:00:00 2001 From: bottleInALightning Date: Thu, 15 Oct 2020 11:03:23 +0200 Subject: [PATCH 10/11] Added Easy Division --- mathgenerator/mathgen.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 322f429..9884a29 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -148,6 +148,14 @@ def logFunc(maxBase=3, maxVal=8): solution = str(a) return problem, solution +def divisionToIntFunc(maxA=25, maxB=25): + a = random.randint(1,maxA) + b = random.randint(1,maxB) + divisor = a*b + dividend=random.choice([a,b]) + problem = f"{divisor}/{dividend} = " + solution=int(divisor/dividend) + return problem,solution # || Class Instances #Format is: From f789eee26c5cf90c615df0470564ae18aad3963a Mon Sep 17 00:00:00 2001 From: bottleInALightning Date: Thu, 15 Oct 2020 11:07:14 +0200 Subject: [PATCH 11/11] Added Easy Division --- mathgenerator/mathgen.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 9884a29..ed5a3ab 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -173,3 +173,4 @@ lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc) gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc) basicAlgebra = Generator("Basic_Algebra", 13, "ax + b = c", "d", basicAlgebraFunc) log = Generator("Logarithm", 13, "log2(8)", "3", logFunc) +intdivision = Generator("Easy Divisio",14,"a/b=","c",divisionToIntFunc) \ No newline at end of file