From 91b23a4c666f2442db41aef480a7649c1be13c6e Mon Sep 17 00:00:00 2001 From: akash khamkar <49859828+xatriya@users.noreply.github.com> Date: Wed, 14 Oct 2020 23:13:33 +0530 Subject: [PATCH 1/2] new 1s binary complement generated added . new 1s binary complement problem generator added . --- mathgenerator/mathgen.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 96e9c47..6ffa7ba 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -50,6 +50,19 @@ def divisionFunc(maxRes = 99, maxDivid = 99): problem = str(a) + "/" + str(b) + "=" solution = str(c) return problem, solution + +def binary_1s_Complement(maxDigits = 10): + question = '' + answer = '' + for i in range(random.randint(1,maxDigits)): + temp = str(random.randint(0, 1)) + question += temp + answer += "0" if temp == "1" else "1" + + problem = question + solution = answer + return problem, solution + # || Class Instances #Format is: @@ -58,4 +71,5 @@ addition = Generator("Addition", 2, "a+b=", "c", additionFunc) subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) +binary_complement_1s = Generator("binary_complement_1s", 6, "(1010)=", "0101", binary_1s_Complement) From 293fd0b65c412eb6ec323d8c16ec5c612f384ec2 Mon Sep 17 00:00:00 2001 From: akash khamkar <49859828+xatriya@users.noreply.github.com> Date: Wed, 14 Oct 2020 23:20:47 +0530 Subject: [PATCH 2/2] changed names --- mathgenerator/mathgen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 6ffa7ba..b027f41 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -51,7 +51,7 @@ def divisionFunc(maxRes = 99, maxDivid = 99): solution = str(c) return problem, solution -def binary_1s_Complement(maxDigits = 10): +def binaryComplement1sFunc(maxDigits = 10): question = '' answer = '' for i in range(random.randint(1,maxDigits)): @@ -71,5 +71,5 @@ addition = Generator("Addition", 2, "a+b=", "c", additionFunc) subtraction = Generator("Subtraction", 3, "a-b=", "c", subtractionFunc) multiplication = Generator("Multiplication", 4, "a*b=", "c", multiplicationFunc) division = Generator("Division", 5, "a/b=", "c", divisionFunc) -binary_complement_1s = Generator("binary_complement_1s", 6, "(1010)=", "0101", binary_1s_Complement) +binaryComplement1s = Generator("binary_complement_1s", 6, "(1010)=", "0101", binaryComplement1sFunc)