mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Merge branch 'add-flake8' of https://github.com/YuviGold/mathgenerator into YuviGold-add-flake8
This commit is contained in:
2
.github/workflows/tests.yaml
vendored
2
.github/workflows/tests.yaml
vendored
@@ -17,5 +17,7 @@ jobs:
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
python -m pip install -r dev-requirements.txt
|
||||
- name: Linter
|
||||
run: make lint
|
||||
- name: Test
|
||||
run: make test
|
||||
|
||||
5
Makefile
5
Makefile
@@ -1,2 +1,7 @@
|
||||
FLAKE_FLAGS = --ignore=E501,F401,F403,F405
|
||||
|
||||
lint:
|
||||
python -m flake8 $(FLAKE_FLAGS)
|
||||
|
||||
test:
|
||||
python -m pytest --verbose -s tests
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
pytest
|
||||
hypothesis
|
||||
flake8
|
||||
@@ -4,6 +4,7 @@ import fractions
|
||||
|
||||
genList = []
|
||||
|
||||
|
||||
# || Generator class
|
||||
class Generator:
|
||||
def __init__(self, title, id, generalProb, generalSol, func):
|
||||
@@ -20,16 +21,19 @@ class Generator:
|
||||
def __call__(self, **kwargs):
|
||||
return self.func(**kwargs)
|
||||
|
||||
|
||||
# || Non-generator Functions
|
||||
def genById(id):
|
||||
generator = genList[id][2]
|
||||
return(generator())
|
||||
|
||||
|
||||
def getGenList():
|
||||
return(genList)
|
||||
|
||||
# || Generator Functions
|
||||
|
||||
|
||||
def additionFunc(maxSum=99, maxAddend=50):
|
||||
a = random.randint(0, maxAddend)
|
||||
b = random.randint(0, min((maxSum - a), maxAddend)) # The highest value of b will be no higher than the maxsum minus the first number and no higher than the maxAddend as well
|
||||
@@ -38,6 +42,7 @@ def additionFunc(maxSum = 99, maxAddend = 50):
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def subtractionFunc(maxMinuend=99, maxDiff=99):
|
||||
a = random.randint(0, maxMinuend)
|
||||
b = random.randint(max(0, (a - maxDiff)), a)
|
||||
@@ -46,6 +51,7 @@ def subtractionFunc(maxMinuend = 99, maxDiff = 99):
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def multiplicationFunc(maxRes=99, maxMulti=99):
|
||||
a = random.randint(0, maxMulti)
|
||||
b = random.randint(0, min(int(maxMulti / a), maxRes))
|
||||
@@ -54,6 +60,7 @@ def multiplicationFunc(maxRes = 99, maxMulti = 99):
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def divisionFunc(maxRes=99, maxDivid=99):
|
||||
a = random.randint(0, maxDivid)
|
||||
b = random.randint(0, min(maxRes, maxDivid))
|
||||
@@ -62,6 +69,7 @@ def divisionFunc(maxRes = 99, maxDivid = 99):
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def binaryComplement1sFunc(maxDigits=10):
|
||||
question = ''
|
||||
answer = ''
|
||||
@@ -74,6 +82,7 @@ def binaryComplement1sFunc(maxDigits = 10):
|
||||
solution = answer
|
||||
return problem, solution
|
||||
|
||||
|
||||
def moduloFunc(maxRes=99, maxModulo=99):
|
||||
a = random.randint(0, maxModulo)
|
||||
b = random.randint(0, min(maxRes, maxModulo))
|
||||
@@ -82,6 +91,7 @@ def moduloFunc(maxRes = 99, maxModulo= 99):
|
||||
solution = str(c)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def squareRootFunc(minNo=1, maxNo=12):
|
||||
b = random.randint(minNo, maxNo)
|
||||
a = b * b
|
||||
@@ -89,6 +99,7 @@ def squareRootFunc(minNo = 1, maxNo = 12):
|
||||
solution = str(b)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def powerRuleDifferentiationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
||||
numTerms = random.randint(1, maxTerms)
|
||||
problem = ""
|
||||
@@ -103,6 +114,7 @@ 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
|
||||
@@ -110,6 +122,7 @@ def squareFunc(maxSquareNum = 20):
|
||||
solution = str(b)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def gcdFunc(maxVal=20):
|
||||
a = random.randint(1, maxVal)
|
||||
b = random.randint(1, maxVal)
|
||||
@@ -120,6 +133,7 @@ def gcdFunc(maxVal=20):
|
||||
solution = str(x)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def lcmFunc(maxVal=20):
|
||||
a = random.randint(1, maxVal)
|
||||
b = random.randint(1, maxVal)
|
||||
@@ -132,11 +146,13 @@ 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
|
||||
@@ -151,6 +167,7 @@ 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)
|
||||
@@ -159,6 +176,7 @@ 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)
|
||||
@@ -168,6 +186,7 @@ def divisionToIntFunc(maxA=25, maxB=25):
|
||||
solution = int(divisor / dividend)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def DecimalToBinaryFunc(max_dec=99):
|
||||
a = random.randint(1, max_dec)
|
||||
b = bin(a).replace("0b", "")
|
||||
@@ -175,15 +194,17 @@ def DecimalToBinaryFunc(max_dec=99):
|
||||
solution = str(b)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def BinaryToDecimalFunc(max_dig=10):
|
||||
problem = ''
|
||||
for i in range(random.randint(1, max_dig)):
|
||||
temp = str(random.randint(0, 1))
|
||||
problem += temp
|
||||
|
||||
solution=int(problem, 2);
|
||||
solution = int(problem, 2)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def divideFractionsFunc(maxVal=10):
|
||||
a = random.randint(1, maxVal)
|
||||
b = random.randint(1, maxVal)
|
||||
@@ -193,6 +214,7 @@ def divideFractionsFunc(maxVal=10):
|
||||
d = random.randint(1, maxVal)
|
||||
while (c == d):
|
||||
d = random.randint(1, maxVal)
|
||||
|
||||
def calculate_gcd(x, y):
|
||||
while(y):
|
||||
x, y = y, x % y
|
||||
@@ -208,6 +230,7 @@ def divideFractionsFunc(maxVal=10):
|
||||
solution = x
|
||||
return problem, solution
|
||||
|
||||
|
||||
def multiplyIntToMatrix22(maxMatrixVal=10, maxRes=100):
|
||||
a = random.randint(0, maxMatrixVal)
|
||||
b = random.randint(0, maxMatrixVal)
|
||||
@@ -218,6 +241,7 @@ def multiplyIntToMatrix22(maxMatrixVal = 10, maxRes = 100):
|
||||
solution = f"[[{a*constant},{b*constant}],[{c*constant},{d*constant}]]"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
|
||||
a = random.randint(1, maxA)
|
||||
b = random.randint(1, maxB)
|
||||
@@ -228,6 +252,7 @@ def areaOfTriangleFunc(maxA=20, maxB=20, maxC=20):
|
||||
solution = area
|
||||
return problem, solution
|
||||
|
||||
|
||||
def isTriangleValidFunc(maxSideLength=50):
|
||||
sideA = random.randint(1, maxSideLength)
|
||||
sideB = random.randint(1, maxSideLength)
|
||||
@@ -242,6 +267,7 @@ def isTriangleValidFunc(maxSideLength = 50):
|
||||
solution = "No"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def MidPointOfTwoPointFunc(maxValue=20):
|
||||
x1 = random.randint(-20, maxValue)
|
||||
y1 = random.randint(-20, maxValue)
|
||||
@@ -251,9 +277,11 @@ def MidPointOfTwoPointFunc(maxValue=20):
|
||||
solution = f"({(x1+x2)/2},{(y1+y2)/2})"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def factoringFunc(range_x1=10, range_x2=10):
|
||||
x1 = random.randint(-range_x1, range_x1)
|
||||
x2 = random.randint(-range_x2, range_x2)
|
||||
|
||||
def intParser(z):
|
||||
if (z == 0):
|
||||
return ""
|
||||
@@ -278,6 +306,7 @@ def factoringFunc(range_x1 = 10, range_x2 = 10):
|
||||
solution = f"(x{x1})(x{x2})"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def thirdAngleOfTriangleFunc(maxAngle=89):
|
||||
angle1 = random.randint(1, maxAngle)
|
||||
angle2 = random.randint(1, maxAngle)
|
||||
@@ -286,6 +315,7 @@ def thirdAngleOfTriangleFunc(maxAngle=89):
|
||||
solution = angle3
|
||||
return problem, solution
|
||||
|
||||
|
||||
def systemOfEquationsFunc(range_x=10, range_y=10, coeff_mult_range=10):
|
||||
# Generate solution point first
|
||||
x = random.randint(-range_x, range_x)
|
||||
@@ -331,6 +361,7 @@ def systemOfEquationsFunc(range_x = 10, range_y = 10, coeff_mult_range=10):
|
||||
|
||||
# Add random (non-zero) multiple of equations to each other
|
||||
|
||||
|
||||
def distanceTwoPointsFunc(maxValXY=20, minValXY=-20):
|
||||
point1X = random.randint(minValXY, maxValXY + 1)
|
||||
point1Y = random.randint(minValXY, maxValXY + 1)
|
||||
@@ -341,6 +372,7 @@ def distanceTwoPointsFunc(maxValXY = 20, minValXY=-20):
|
||||
problem = f"Find the distance between ({point1X}, {point1Y}) and ({point2X}, {point2Y})"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def pythagoreanTheoremFunc(maxLength=20):
|
||||
a = random.randint(1, maxLength)
|
||||
b = random.randint(1, maxLength)
|
||||
@@ -349,6 +381,7 @@ def pythagoreanTheoremFunc(maxLength = 20):
|
||||
solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def linearEquationsFunc(n=2, varRange=20, coeffRange=20):
|
||||
if n > 10:
|
||||
print("[!] n cannot be greater than 10")
|
||||
@@ -372,6 +405,7 @@ def linearEquationsFunc(n = 2, varRange = 20, coeffRange = 20):
|
||||
problem = "\n".join(problem)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def primeFactorsFunc(minVal=1, maxVal=200):
|
||||
a = random.randint(minVal, maxVal)
|
||||
n = a
|
||||
@@ -389,6 +423,7 @@ def primeFactorsFunc(minVal=1, maxVal=200):
|
||||
solution = f"{factors}"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def multiplyFractionsFunc(maxVal=10):
|
||||
a = random.randint(1, maxVal)
|
||||
b = random.randint(1, maxVal)
|
||||
@@ -398,6 +433,7 @@ def multiplyFractionsFunc(maxVal=10):
|
||||
b = random.randint(1, maxVal)
|
||||
while (c == d):
|
||||
d = random.randint(1, maxVal)
|
||||
|
||||
def calculate_gcd(x, y):
|
||||
while(y):
|
||||
x, y = y, x % y
|
||||
@@ -412,6 +448,7 @@ def multiplyFractionsFunc(maxVal=10):
|
||||
solution = x
|
||||
return problem, solution
|
||||
|
||||
|
||||
def regularPolygonAngleFunc(minVal=3, maxVal=20):
|
||||
sideNum = random.randint(minVal, maxVal)
|
||||
problem = f"Find the angle of a regular polygon with {sideNum} sides"
|
||||
@@ -419,6 +456,7 @@ def regularPolygonAngleFunc(minVal = 3,maxVal = 20):
|
||||
solution = 180 - exteriorAngle
|
||||
return problem, solution
|
||||
|
||||
|
||||
def combinationsFunc(maxlength=20):
|
||||
|
||||
def factorial(a):
|
||||
@@ -430,13 +468,12 @@ def combinationsFunc(maxlength=20):
|
||||
a = random.randint(10, maxlength)
|
||||
b = random.randint(0, 9)
|
||||
|
||||
|
||||
|
||||
solution = int(factorial(a) / (factorial(b) * factorial(a - b)))
|
||||
problem = "Number of combinations from {} objects picked {} at a time ".format(a, b)
|
||||
|
||||
return problem, solution
|
||||
|
||||
|
||||
def factorialFunc(maxInput=6):
|
||||
a = random.randint(0, maxInput)
|
||||
n = a
|
||||
@@ -452,6 +489,7 @@ def factorialFunc(maxInput = 6):
|
||||
solution = str(b)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def surfaceAreaCube(maxSide=20, unit='m'):
|
||||
a = random.randint(1, maxSide)
|
||||
problem = f"Surface area of cube with side = {a}{unit} is"
|
||||
@@ -459,6 +497,7 @@ def surfaceAreaCube(maxSide = 20, unit = 'm'):
|
||||
solution = f"{ans} {unit}^2"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def volumeCube(maxSide=20, unit='m'):
|
||||
a = random.randint(1, maxSide)
|
||||
problem = f"Volume of cube with side = {a}{unit} is"
|
||||
@@ -466,6 +505,7 @@ def volumeCube(maxSide = 20, unit = 'm'):
|
||||
solution = f"{ans} {unit}^3"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def surfaceAreaCuboid(maxSide=20, unit='m'):
|
||||
a = random.randint(1, maxSide)
|
||||
b = random.randint(1, maxSide)
|
||||
@@ -476,6 +516,7 @@ def surfaceAreaCuboid(maxSide = 20, unit = 'm'):
|
||||
solution = f"{ans} {unit}^2"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def volumeCuboid(maxSide=20, unit='m'):
|
||||
a = random.randint(1, maxSide)
|
||||
b = random.randint(1, maxSide)
|
||||
@@ -485,6 +526,7 @@ def volumeCuboid(maxSide = 20, unit = 'm'):
|
||||
solution = f"{ans} {unit}^3"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def surfaceAreaCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
||||
a = random.randint(1, maxHeight)
|
||||
b = random.randint(1, maxRadius)
|
||||
@@ -493,6 +535,7 @@ def surfaceAreaCylinder(maxRadius = 20, maxHeight = 50,unit = 'm'):
|
||||
solution = f"{ans} {unit}^2"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def volumeCylinder(maxRadius=20, maxHeight=50, unit='m'):
|
||||
a = random.randint(1, maxHeight)
|
||||
b = random.randint(1, maxRadius)
|
||||
@@ -501,6 +544,7 @@ def volumeCylinder(maxRadius = 20, maxHeight = 50, unit = 'm'):
|
||||
solution = f"{ans} {unit}^3"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def surfaceAreaCone(maxRadius=20, maxHeight=50, unit='m'):
|
||||
a = random.randint(1, maxHeight)
|
||||
b = random.randint(1, maxRadius)
|
||||
@@ -510,6 +554,7 @@ def surfaceAreaCone(maxRadius = 20, maxHeight = 50,unit = 'm'):
|
||||
solution = f"{ans} {unit}^2"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def volumeCone(maxRadius=20, maxHeight=50, unit='m'):
|
||||
a = random.randint(1, maxHeight)
|
||||
b = random.randint(1, maxRadius)
|
||||
@@ -518,6 +563,7 @@ def volumeCone(maxRadius = 20, maxHeight = 50, unit = 'm'):
|
||||
solution = f"{ans} {unit}^3"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def commonFactorsFunc(maxVal=100):
|
||||
a = random.randint(1, maxVal)
|
||||
b = random.randint(1, maxVal)
|
||||
@@ -537,6 +583,7 @@ def commonFactorsFunc(maxVal=100):
|
||||
solution = arr
|
||||
return problem, solution
|
||||
|
||||
|
||||
def intersectionOfTwoLinesFunc(
|
||||
minM=-10, maxM=10, minB=-10, maxB=10, minDenominator=1, maxDenominator=6
|
||||
):
|
||||
@@ -590,6 +637,7 @@ def intersectionOfTwoLinesFunc(
|
||||
solution = f"({fractionToString(intersection_x)}, {fractionToString(intersection_y)})"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def permutationFunc(maxlength=20):
|
||||
a = random.randint(10, maxlength)
|
||||
b = random.randint(0, 9)
|
||||
@@ -597,6 +645,7 @@ def permutationFunc(maxlength=20):
|
||||
problem = "Number of Permutations from {} objects picked {} at a time = ".format(a, b)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def vectorCrossFunc(minVal=-20, maxVal=20):
|
||||
a = [random.randint(minVal, maxVal) for i in range(3)]
|
||||
b = [random.randint(minVal, maxVal) for i in range(3)]
|
||||
@@ -605,6 +654,7 @@ def vectorCrossFunc(minVal=-20, maxVal=20):
|
||||
a[0] * b[1] - a[1] * b[0]]
|
||||
return str(a) + " X " + str(b) + " = ", str(c)
|
||||
|
||||
|
||||
def compareFractionsFunc(maxVal=10):
|
||||
a = random.randint(1, maxVal)
|
||||
b = random.randint(1, maxVal)
|
||||
@@ -629,6 +679,7 @@ def compareFractionsFunc(maxVal=10):
|
||||
problem = f"Which symbol represents the comparison between {a}/{b} and {c}/{d}?"
|
||||
return problem, solution
|
||||
|
||||
|
||||
def simpleInterestFunc(maxPrinciple=10000, maxRate=10, maxTime=10):
|
||||
a = random.randint(1000, maxPrinciple)
|
||||
b = random.randint(1, maxRate)
|
||||
@@ -638,6 +689,7 @@ def simpleInterestFunc(maxPrinciple = 10000, maxRate = 10, maxTime = 10):
|
||||
solution = round(d, 2)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def matrixMultiplicationFunc(maxVal=100):
|
||||
m = random.randint(2, 10)
|
||||
n = random.randint(2, 10)
|
||||
@@ -666,10 +718,11 @@ def matrixMultiplicationFunc(maxVal=100):
|
||||
for t in range(n):
|
||||
temp += a[r][t] * b[t][c]
|
||||
res[r].append(temp)
|
||||
problem= f"Multiply {a} and {b}" #consider using a, b instead of a_string, b_string if the problem doesn't look right
|
||||
solution= res#matrixMultiplicationFuncHelper(res)
|
||||
problem = f"Multiply \n{a_string}\n and \n\n{b_string}" # consider using a, b instead of a_string, b_string if the problem doesn't look right
|
||||
solution = matrixMultiplicationFuncHelper(res)
|
||||
return problem, solution
|
||||
|
||||
|
||||
def matrixMultiplicationFuncHelper(inp):
|
||||
m = len(inp)
|
||||
n = len(inp[0])
|
||||
@@ -681,6 +734,7 @@ def matrixMultiplicationFuncHelper(inp):
|
||||
string += "\n"
|
||||
return string
|
||||
|
||||
|
||||
def cubeRootFunc(minNo=1, maxNo=1000):
|
||||
b = random.randint(minNo, maxNo)
|
||||
a = b**(1 / 3)
|
||||
@@ -688,6 +742,7 @@ def cubeRootFunc(minNo = 1, maxNo = 1000):
|
||||
solution = str(round(a, 2))
|
||||
return problem, solution
|
||||
|
||||
|
||||
def powerRuleIntegrationFunc(maxCoef=10, maxExp=10, maxTerms=5):
|
||||
numTerms = random.randint(1, maxTerms)
|
||||
problem = ""
|
||||
@@ -699,7 +754,7 @@ def powerRuleIntegrationFunc(maxCoef = 10, maxExp = 10, maxTerms = 5):
|
||||
coefficient = random.randint(1, maxCoef)
|
||||
exponent = random.randint(1, maxExp)
|
||||
problem += str(coefficient) + "x^" + str(exponent)
|
||||
solution += "("+str(coefficient) +"/"+str(exponent + 1) +")x^" + str(exponent +1)
|
||||
solution += "(" + str(coefficient) + "/" + str(exponent) + ")x^" + str(exponent + 1)
|
||||
solution = solution + " + c"
|
||||
return problem, solution
|
||||
|
||||
@@ -714,6 +769,7 @@ def fourthAngleOfQuadriFunc(maxAngle = 180):
|
||||
solution = angle4
|
||||
return problem, solution
|
||||
|
||||
|
||||
def quadraticEquation(maxVal=100):
|
||||
a = random.randint(1, maxVal)
|
||||
c = random.randint(1, maxVal)
|
||||
@@ -837,6 +893,8 @@ def sumOfAnglesOfPolygonFunc(maxSides = 12):
|
||||
|
||||
# Format is:
|
||||
# <title> = Generator("<Title>", <id>, <generalized problem>, <generalized solution>, <function name>)
|
||||
|
||||
|
||||
addition = Generator("Addition", 0, "a+b=", "c", additionFunc)
|
||||
subtraction = Generator("Subtraction", 1, "a-b=", "c", subtractionFunc)
|
||||
multiplication = Generator("Multiplication", 2, "a*b=", "c", multiplicationFunc)
|
||||
@@ -860,7 +918,8 @@ doesTriangleExist = Generator("Triangle exists check", 19, "Does triangle with s
|
||||
midPointOfTwoPoint = Generator("Midpoint of the two point", 20, "((X1,Y1),(X2,Y2))=", "((X1+X2)/2,(Y1+Y2)/2)", MidPointOfTwoPointFunc)
|
||||
factoring = Generator("Factoring Quadratic", 21, "x^2+(x1+x2)+x1*x2", "(x-x1)(x-x2)", factoringFunc)
|
||||
thirdAngleOfTriangle = Generator("Third Angle of Triangle", 22, "Third Angle of the triangle = ", "angle3", thirdAngleOfTriangleFunc)
|
||||
systemOfEquations = Generator("Solve a System of Equations in R^2", 23, "2x + 5y = 13, -3x - 3y = -6", "x = -1, y = 3", systemOfEquationsFunc)
|
||||
systemOfEquations = Generator("Solve a System of Equations in R^2", 23, "2x + 5y = 13, -3x - 3y = -6", "x = -1, y = 3",
|
||||
systemOfEquationsFunc)
|
||||
distance2Point = Generator("Distance between 2 points", 24, "Find the distance between (x1,y1) and (x2,y2)", "sqrt(distanceSquared)", distanceTwoPointsFunc)
|
||||
pythagoreanTheorem = Generator("Pythagorean Theorem", 25, "The hypotenuse of a right triangle given the other two lengths a and b = ", "hypotenuse", pythagoreanTheoremFunc)
|
||||
linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12", "x=-20 & y=12", linearEquationsFunc) # This has multiple variables whereas #23 has only x and y
|
||||
@@ -885,7 +944,7 @@ compareFractions=Generator("Compare Fractions",44,"Which symbol represents the c
|
||||
simpleInterest = Generator("Simple Interest", 45, "Simple interest for a principle amount of a dollars, b% rate of interest and for a time period of c years is = ", "d dollars", simpleInterestFunc)
|
||||
matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multiply two matrices A and B", "C", matrixMultiplicationFunc)
|
||||
CubeRoot = Generator("Cube Root", 47, "Cuberoot of a upto 2 decimal places is", "b", cubeRootFunc)
|
||||
powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m+1)x^(m+1)", powerRuleIntegrationFunc)
|
||||
powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc)
|
||||
fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral", 49, "Fourth angle of Quadrilateral with angles a,b,c =", "angle4", fourthAngleOfQuadriFunc)
|
||||
quadraticEquationSolve = Generator("Quadratic Equation", 50, "Find the zeros {x1,x2} of the quadratic equation ax^2+bx+c=0", "x1,x2", quadraticEquation)
|
||||
hcf = Generator("HCF (Highest Common Factor)", 51, "HCF of a and b = ", "c", hcfFunc)
|
||||
|
||||
@@ -5,42 +5,42 @@ from hypothesis import strategies as st, given, assume
|
||||
|
||||
|
||||
@given(maxSum=st.integers(min_value=1), maxAddend=st.integers(min_value=1))
|
||||
def test_additionFunc(maxSum, maxAddend):
|
||||
def test_addition(maxSum, maxAddend):
|
||||
assume(maxSum > maxAddend)
|
||||
problem, solution = additionFunc(maxSum, maxAddend)
|
||||
problem, solution = addition.func(maxSum, maxAddend)
|
||||
assert eval(problem[:-1]) == int(solution)
|
||||
|
||||
|
||||
@given(maxMinuend=st.integers(min_value=1), maxDiff=st.integers(min_value=1))
|
||||
def test_subtractionFunc(maxMinuend, maxDiff):
|
||||
def test_subtraction(maxMinuend, maxDiff):
|
||||
assume(maxMinuend > maxDiff)
|
||||
problem, solution = subtractionFunc(maxMinuend, maxDiff)
|
||||
problem, solution = subtraction.func(maxMinuend, maxDiff)
|
||||
assert eval(problem[:-1]) == int(solution)
|
||||
|
||||
|
||||
@given(maxRes=st.integers(min_value=1), maxMulti=st.integers(min_value=1))
|
||||
def test_multiplicationFunc(maxRes, maxMulti):
|
||||
def test_multiplication(maxRes, maxMulti):
|
||||
assume(maxRes > maxMulti)
|
||||
problem, solution = multiplicationFunc(maxRes, maxMulti)
|
||||
problem, solution = multiplication.func(maxRes, maxMulti)
|
||||
assert eval(problem[:-1]) == int(solution)
|
||||
|
||||
|
||||
@given(maxRes=st.integers(min_value=1), maxDivid=st.integers(min_value=1))
|
||||
def test_divisionFunc(maxRes, maxDivid):
|
||||
def test_division(maxRes, maxDivid):
|
||||
assume(maxRes > maxDivid)
|
||||
problem, solution = divisionFunc(maxRes, maxDivid)
|
||||
problem, solution = division.func(maxRes, maxDivid)
|
||||
assert eval(problem[:-1]) == float(solution)
|
||||
|
||||
|
||||
@given(maxRes=st.integers(min_value=1), maxModulo=st.integers(min_value=1))
|
||||
def test_moduloFunc(maxRes, maxModulo):
|
||||
def test_moduloDivision(maxRes, maxModulo):
|
||||
assume(maxRes > maxModulo)
|
||||
problem, solution = moduloFunc(maxRes, maxModulo)
|
||||
problem, solution = moduloDivision.func(maxRes, maxModulo)
|
||||
assert eval(problem[:-1]) == int(solution)
|
||||
|
||||
|
||||
@given(minNo=st.integers(min_value=1), maxNo=st.integers(min_value=1, max_value=2 ** 50))
|
||||
def test_squareRootFunc(minNo, maxNo):
|
||||
def test_squareRoot(minNo, maxNo):
|
||||
assume(maxNo > minNo)
|
||||
problem, solution = squareRootFunc(minNo, maxNo)
|
||||
problem, solution = squareRoot.func(minNo, maxNo)
|
||||
assert eval(problem[:-1]) == float(solution)
|
||||
|
||||
Reference in New Issue
Block a user