multiply two matrices together (return -1 if shapes of matrix don't align), i.e. C=A⋅B
Examples
Example 1:
Input:
A = [[1,2],[2,4]], B = [[2,1],[3,4]]Output:
[[ 8, 9],[16, 18]]Explanation: 1\*2 + 2\*3 = 8; 2\*2 + 3\*4 = 16; 1\*1 + 2\*4 = 9; 2\*1 + 4\*4 = 18 Example 2: input: A = [[1,2], [2,4]], B = [[2,1], [3,4], [4,5]] output: -1 reasoning: the length of the rows of A does not equal the column length of B
Starter Code
def matrixmul(a:list[list[int|float]],
b:list[list[int|float]])-> list[list[int|float]]:
return cPython3
ReadyLines: 1Characters: 0
Ready