mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
* Improve generator __init__ function * Move Generator to new file, remove mathgen * Remove getGenList redundancies * Add backwards compatibility import mathgen from * Insort to genList * Linter fixes * Lint fixes
25 lines
612 B
Python
25 lines
612 B
Python
from ...generator import Generator
|
|
import random
|
|
|
|
|
|
def gen_func(maxDigits=10, format='string'):
|
|
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"
|
|
|
|
if format == 'string':
|
|
problem = question + "="
|
|
return problem, answer
|
|
elif format == 'latex':
|
|
return "Latex unavailable"
|
|
else:
|
|
return problem, answer
|
|
|
|
|
|
binary_complement_1s = Generator("Binary Complement 1s", 4,
|
|
gen_func, ["maxDigits=10"])
|