diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index a7063b2..e9987ad 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -206,6 +206,17 @@ def divideFractionsFunc(maxVal=10): solution = x return problem, solution +def multiplyIntToMatrix22(maxMatrixVal = 10, maxRes = 100): + a = random.randint(0, maxMatrixVal) + b = random.randint(0, maxMatrixVal) + c = random.randint(0, maxMatrixVal) + d = random.randint(0, maxMatrixVal) + constant = random.randint(0, int(maxRes/max(a,b,c,d))) + problem = f"{constant} * [[{a}, {b}], [{c}, {d}]] = " + solution = f"[[{a*constant},{b*constant}],[{c*constant},{d*constant}]]" + return problem, solution + + # || Class Instances #Format is: @@ -227,3 +238,4 @@ intDivision = Generator("Easy Division", 13,"a/b=","c",divisionToIntFunc) decimalToBinary = Generator("Decimal to Binary",14,"Binary of a=","b",DecimalToBinaryFunc) binaryToDecimal = Generator("Binary to Decimal",15,"Decimal of a=","b",BinaryToDecimalFunc) fractionDivision = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y", divideFractionsFunc) +intMatrix22Multiplication = Generator("Integer Multiplication with 2x2 Matrix", 17, "k * [[a,b],[c,d]]=", "[[k*a,k*b],[k*c,k*d]]", multiplyIntToMatrix22) \ No newline at end of file