Integer Multiplication with 2x2 Matrix

This commit is contained in:
ieshaan12
2020-10-15 23:10:36 +05:30
parent 24eac9596c
commit 85185a8376

View File

@@ -206,6 +206,17 @@ def divideFractionsFunc(maxVal=10):
solution = x solution = x
return problem, solution 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 # || Class Instances
#Format is: #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) decimalToBinary = Generator("Decimal to Binary",14,"Binary of a=","b",DecimalToBinaryFunc)
binaryToDecimal = Generator("Binary to Decimal",15,"Decimal of a=","b",BinaryToDecimalFunc) binaryToDecimal = Generator("Binary to Decimal",15,"Decimal of a=","b",BinaryToDecimalFunc)
fractionDivision = Generator("Fraction Division", 16, "(a/b)/(c/d)=", "x/y", divideFractionsFunc) 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)