From 4f18c547f7612e7628b8ded3a9a7166a4c07a975 Mon Sep 17 00:00:00 2001 From: mushahidq Date: Thu, 15 Oct 2020 00:53:51 +0530 Subject: [PATCH 01/12] Fixed useless parameters on Multiplication --- mathgenerator/mathgen.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 0931109..79d5510 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -36,9 +36,16 @@ def subtractionFunc(maxMinuend = 99, maxDiff = 99): return problem, solution def multiplicationFunc(maxRes = 99, maxMulti = 99): - a = random.randint(0, maxMulti) - b = random.randint(0, min(maxRes, maxMulti)) - c = a*b + c = random.randint(0, maxMulti) # Generate the solution to the problem + i = int(1) + j = 0 #Indices for the loop + d = [] #Array to store the factors + while(i<=c): #Factors are less than or eqaul to the number + if(c%i == 0): #If the remainder is 0, the number is a factor + d[j] = i #Store the factor + j += 1 #Move to the next index + a = random.randint(0, c) #Generate a multiplicant + b = c/a #Find the other multiplicant problem = str(a) + "*" + str(b) + "=" solution = str(c) return problem, solution From c5ede58ba7ddc25d6286f845d45640214222723a Mon Sep 17 00:00:00 2001 From: mushahidq Date: Thu, 15 Oct 2020 00:55:19 +0530 Subject: [PATCH 02/12] Fixed useless parameters on Multiplication --- mathgenerator/mathgen.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 79d5510..f3b61a6 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -44,6 +44,7 @@ def multiplicationFunc(maxRes = 99, maxMulti = 99): if(c%i == 0): #If the remainder is 0, the number is a factor d[j] = i #Store the factor j += 1 #Move to the next index + i += 1 #Next number a = random.randint(0, c) #Generate a multiplicant b = c/a #Find the other multiplicant problem = str(a) + "*" + str(b) + "=" From 8e2df67c1e2ea74d7ba6eebd9ad1531bc4330b72 Mon Sep 17 00:00:00 2001 From: Mohammed Mushahid Qureshi Date: Thu, 15 Oct 2020 00:58:52 +0530 Subject: [PATCH 03/12] Update mathgen.py --- mathgenerator/mathgen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index f3b61a6..b31369a 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -40,7 +40,7 @@ def multiplicationFunc(maxRes = 99, maxMulti = 99): i = int(1) j = 0 #Indices for the loop d = [] #Array to store the factors - while(i<=c): #Factors are less than or eqaul to the number + while(i<=c): #Factors are less than or equal to the number if(c%i == 0): #If the remainder is 0, the number is a factor d[j] = i #Store the factor j += 1 #Move to the next index @@ -96,4 +96,4 @@ 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) 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/12] 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 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 05/12] 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 06/12] 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 07/12] 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 e121dd8b1ec77a1d03490936fb0b6e03cd6294ae Mon Sep 17 00:00:00 2001 From: Mohammed Mushahid Qureshi Date: Thu, 15 Oct 2020 09:49:32 +0530 Subject: [PATCH 08/12] Fixed Multiplication parameters --- mathgenerator/mathgen.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index b31369a..2e99246 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -36,17 +36,9 @@ def subtractionFunc(maxMinuend = 99, maxDiff = 99): return problem, solution def multiplicationFunc(maxRes = 99, maxMulti = 99): - c = random.randint(0, maxMulti) # Generate the solution to the problem - i = int(1) - j = 0 #Indices for the loop - d = [] #Array to store the factors - while(i<=c): #Factors are less than or equal to the number - if(c%i == 0): #If the remainder is 0, the number is a factor - d[j] = i #Store the factor - j += 1 #Move to the next index - i += 1 #Next number - a = random.randint(0, c) #Generate a multiplicant - b = c/a #Find the other multiplicant + a = random.randint(0, maxMulti) + b = random.randint(0, min(int(maxMulti/a), maxRes)) + c = a*b problem = str(a) + "*" + str(b) + "=" solution = str(c) return problem, solution From bcffaa0f470af341385e495a182826878166c675 Mon Sep 17 00:00:00 2001 From: bottleInALightning Date: Thu, 15 Oct 2020 11:03:23 +0200 Subject: [PATCH 09/12] 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 10/12] 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 From 50eff003a30013b2d2494ec95d7e41581da1a901 Mon Sep 17 00:00:00 2001 From: Gokul <43350089+gokulp01@users.noreply.github.com> Date: Thu, 15 Oct 2020 17:26:23 +0530 Subject: [PATCH 11/12] Added Decimal to Binary generator --- mathgenerator/mathgen.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index ed5a3ab..cefaa62 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -156,6 +156,14 @@ def divisionToIntFunc(maxA=25, maxB=25): problem = f"{divisor}/{dividend} = " solution=int(divisor/dividend) return problem,solution + +def decimalToBinary(max_dec=99): + a = random.randint(1, max_dec) + b = bin(a).replace("0b", "") + problem = "Binary of "+str(a)+"=" + solution = str(b) + return problem, solution + # || Class Instances #Format is: @@ -173,4 +181,5 @@ 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 +intdivision = Generator("Easy Divisio",14,"a/b=","c",divisionToIntFunc) +decimaltobinary = Generator("Decimal to Binary",15,"Binary of a=","c",decimalToBinary) From 2ede20d06d48e1a74998f63f131db2af4792a87b Mon Sep 17 00:00:00 2001 From: Gokul <43350089+gokulp01@users.noreply.github.com> Date: Thu, 15 Oct 2020 17:33:35 +0530 Subject: [PATCH 12/12] Updated Decimal to Binary generator --- mathgenerator/mathgen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index cefaa62..6a0731c 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -182,4 +182,4 @@ 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) -decimaltobinary = Generator("Decimal to Binary",15,"Binary of a=","c",decimalToBinary) +decimaltobinary = Generator("Decimal to Binary",15,"Binary of a=","b",decimalToBinary)