We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
A=[[1,2],[2,3]]B=[[4,5],[7,8]]ROWS_A,COLS_A=len(A),len(A[0])ROWS_B,COLS_B=len(B),len(B[0])assertCOLS_A==ROWS_BCOMMON_D=ROWS_B# zeros for Rows-A x Cols-BM_TIMES=[]forrinrange(ROWS_A):M_TIMES.append([0]*COLS_B)# Loop over Rows-A, then Cols-B, then the common dimensionforrAinrange(ROWS_A):forcBinrange(COLS_B):fortinrange(COMMON_D):M_TIMES[rA][cB]+=A[rA][t]*B[t][cB]print(M_TIMES[rA][cB])
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Linear Algebra Foundations #3- Matrix Multiplication
You are viewing a single comment's thread. Return to all comments →