Merge branch 'master' into master

This commit is contained in:
Luke Weiler
2020-10-15 09:17:02 -04:00
committed by GitHub
3 changed files with 98 additions and 15 deletions

View File

@@ -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 |

View File

@@ -78,6 +78,84 @@ 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
def squareFunc(maxSquareNum = 20):
a = random.randint(1, maxSquareNum)
b = a * a
problem = str(a) + "^2" + "="
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
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
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
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:
@@ -88,4 +166,11 @@ 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)
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)
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)

View File

@@ -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'
],
},
}
)