Merge branch 'master' into patch-1

This commit is contained in:
Luke Weiler
2020-10-15 10:22:52 -04:00
committed by GitHub

View File

@@ -173,6 +173,30 @@ def BinaryToDecimal(max_dig=10):
solution=int(problem, 2); solution=int(problem, 2);
return problem, solution return problem, solution
def divideFractionsFunc(maxVal=10):
a = random.randint(1, maxVal)
b = random.randint(1, maxVal)
while (a == b):
b = random.randint(1, maxVal)
c = random.randint(1, maxVal)
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
return x
tmp_n = a * d
tmp_d = b * c
gcd = calculate_gcd(tmp_n, tmp_d)
x = f"{tmp_n//gcd}/{tmp_d//gcd}"
if (tmp_d == 1 or tmp_d == gcd):
x = f"{tmp_n//gcd}"
# for equal numerator and denominators
problem = f"({a}/{b})/({c}/{d})"
solution = x
return problem, solution
# || Class Instances # || Class Instances
#Format is: #Format is:
@@ -192,4 +216,5 @@ basicAlgebra = Generator("Basic_Algebra", 13, "ax + b = c", "d", basicAlgebraFun
log = Generator("Logarithm", 13, "log2(8)", "3", logFunc) log = Generator("Logarithm", 13, "log2(8)", "3", logFunc)
intdivision = Generator("Easy Divisio",14,"a/b=","c",divisionToIntFunc) intdivision = Generator("Easy Divisio",14,"a/b=","c",divisionToIntFunc)
decimaltobinary = Generator("Decimal to Binary",15,"Binary of a=","b",DecimalToBinary) decimaltobinary = Generator("Decimal to Binary",15,"Binary of a=","b",DecimalToBinary)
binarytodecimal = Generator("Decimal to Binary",16,"Decimal of a=","b",BinaryToDecimal) binarytodecimal = Generator("Binary to Decimal",16,"Decimal of a=","b",BinaryToDecimal)
fractionDivision = Generator("Fraction Division", 17, "(a/b)/(c/d)=", "x/y", divideFractionsFunc)