You will write three functions: one that tells you whether two matrices can be multiplied, one that multiplies them by the row-by-column rule, and one that finds a power of a square matrix. A matrix is a list of rows. The checker tests many cases.
The idea. The product exists when the number of columns of equals the number of rows of . Entry of is the sum of A[i][k] * B[k][j] over k. A power is multiplied by itself times.
Your tasks.
can_multiply(A, B). Return True or False.multiply(A, B). Return the product as a list of rows.power(A, n). Return for , using multiply.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…