mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
@@ -78,7 +78,7 @@ def binaryComplement1sFunc(maxDigits=10):
|
|||||||
question += temp
|
question += temp
|
||||||
answer += "0" if temp == "1" else "1"
|
answer += "0" if temp == "1" else "1"
|
||||||
|
|
||||||
problem = question
|
problem = question+"="
|
||||||
solution = answer
|
solution = answer
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ def lcmFunc(maxVal=20):
|
|||||||
while(y):
|
while(y):
|
||||||
x, y = y, x % y
|
x, y = y, x % y
|
||||||
d = c // x
|
d = c // x
|
||||||
problem = f"LCM of {a} and {b} = "
|
problem = f"LCM of {a} and {b} ="
|
||||||
solution = str(d)
|
solution = str(d)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,46 @@
|
|||||||
from math import sqrt
|
from math import sqrt
|
||||||
from mathgenerator.mathgen import *
|
from mathgenerator.mathgen import *
|
||||||
|
|
||||||
from hypothesis import strategies as st, given, assume
|
from hypothesis import strategies as st, given, assume
|
||||||
|
|
||||||
|
|
||||||
@given(maxSum=st.integers(min_value=1), maxAddend=st.integers(min_value=1))
|
@given(maxSum=st.integers(min_value=1), maxAddend=st.integers(min_value=1))
|
||||||
def test_addition(maxSum, maxAddend):
|
def test_addition(maxSum, maxAddend):
|
||||||
assume(maxSum > maxAddend)
|
assume(maxSum > maxAddend)
|
||||||
problem, solution = addition.func(maxSum, maxAddend)
|
problem, solution = addition.func(maxSum, maxAddend)
|
||||||
assert eval(problem[:-1]) == int(solution)
|
assert eval(problem[:-1]) == int(solution)
|
||||||
|
|
||||||
|
|
||||||
@given(maxMinuend=st.integers(min_value=1), maxDiff=st.integers(min_value=1))
|
@given(maxMinuend=st.integers(min_value=1), maxDiff=st.integers(min_value=1))
|
||||||
def test_subtraction(maxMinuend, maxDiff):
|
def test_subtraction(maxMinuend, maxDiff):
|
||||||
assume(maxMinuend > maxDiff)
|
assume(maxMinuend > maxDiff)
|
||||||
problem, solution = subtraction.func(maxMinuend, maxDiff)
|
problem, solution = subtraction.func(maxMinuend, maxDiff)
|
||||||
assert eval(problem[:-1]) == int(solution)
|
assert eval(problem[:-1]) == int(solution)
|
||||||
|
|
||||||
|
|
||||||
@given(maxRes=st.integers(min_value=1), maxMulti=st.integers(min_value=1))
|
@given(maxRes=st.integers(min_value=1), maxMulti=st.integers(min_value=1))
|
||||||
def test_multiplication(maxRes, maxMulti):
|
def test_multiplication(maxRes, maxMulti):
|
||||||
assume(maxRes > maxMulti)
|
assume(maxRes > maxMulti)
|
||||||
problem, solution = multiplication.func(maxRes, maxMulti)
|
problem, solution = multiplication.func(maxRes, maxMulti)
|
||||||
assert eval(problem[:-1]) == int(solution)
|
assert eval(problem[:-1]) == int(solution)
|
||||||
|
|
||||||
|
|
||||||
@given(maxRes=st.integers(min_value=1), maxDivid=st.integers(min_value=1))
|
@given(maxRes=st.integers(min_value=1), maxDivid=st.integers(min_value=1))
|
||||||
def test_division(maxRes, maxDivid):
|
def test_division(maxRes, maxDivid):
|
||||||
assume(maxRes > maxDivid)
|
assume(maxRes > maxDivid)
|
||||||
problem, solution = division.func(maxRes, maxDivid)
|
problem, solution = division.func(maxRes, maxDivid)
|
||||||
assert eval(problem[:-1]) == float(solution)
|
assert eval(problem[:-1]) == float(solution)
|
||||||
|
|
||||||
|
|
||||||
@given(maxRes=st.integers(min_value=1), maxModulo=st.integers(min_value=1))
|
@given(maxRes=st.integers(min_value=1), maxModulo=st.integers(min_value=1))
|
||||||
def test_moduloDivision(maxRes, maxModulo):
|
def test_moduloDivision(maxRes, maxModulo):
|
||||||
assume(maxRes > maxModulo)
|
assume(maxRes > maxModulo)
|
||||||
problem, solution = moduloDivision.func(maxRes, maxModulo)
|
problem, solution = moduloDivision.func(maxRes, maxModulo)
|
||||||
assert eval(problem[:-1]) == int(solution)
|
assert eval(problem[:-1]) == int(solution)
|
||||||
|
|
||||||
|
|
||||||
@given(minNo=st.integers(min_value=1), maxNo=st.integers(min_value=1, max_value=2 ** 50))
|
@given(minNo=st.integers(min_value=1), maxNo=st.integers(min_value=1, max_value=2 ** 50))
|
||||||
def test_squareRoot(minNo, maxNo):
|
def test_squareRoot(minNo, maxNo):
|
||||||
assume(maxNo > minNo)
|
assume(maxNo > minNo)
|
||||||
problem, solution = squareRoot.func(minNo, maxNo)
|
problem, solution = squareRoot.func(minNo, maxNo)
|
||||||
assert eval(problem[:-1]) == float(solution)
|
assert eval(problem[:-1]) == float(solution)
|
||||||
|
|||||||
Reference in New Issue
Block a user