Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 28, 2020 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/bb96d0c5089858b3de2110ec208f55a5 to your computer and use it in GitHub Desktop.
Save parzibyte/bb96d0c5089858b3de2110ec208f55a5 to your computer and use it in GitHub Desktop.
def producto_matrices(a, b):
filas_a = len(a)
filas_b = len(b)
columnas_a = len(a[0])
columnas_b = len(b[0])
if columnas_a != filas_b:
return None
# Asignar espacio al producto. Es decir, rellenar con "espacios vacíos"
producto = []
for i in range(filas_b):
producto.append([])
for j in range(columnas_b):
producto[i].append(None)
# Rellenar el producto
for c in range(columnas_b):
for i in range(filas_a):
suma = 0
for j in range(columnas_a):
suma += a[i][j]*b[j][c]
producto[i][c] = suma
return producto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment