From 4f18c547f7612e7628b8ded3a9a7166a4c07a975 Mon Sep 17 00:00:00 2001 From: mushahidq Date: Thu, 15 Oct 2020 00:53:51 +0530 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 e121dd8b1ec77a1d03490936fb0b6e03cd6294ae Mon Sep 17 00:00:00 2001 From: Mohammed Mushahid Qureshi Date: Thu, 15 Oct 2020 09:49:32 +0530 Subject: [PATCH 4/4] 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