Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Determinant solution in Uncategorized category for Determinant by capback250
def det2(matrix):
return matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]
def alg_dop(matrix, i, j):
ad = [row for k, row in enumerate(matrix) if k != i]
ad = [col for k, col in enumerate(zip(*ad)) if k != j]
return ad
def checkio(matrix):
if len(matrix) == 1:
for x in matrix:
for y in x:
return y
elif len(matrix) == 2:
return det2(matrix)
return sum((-1)**j * matrix[0][j] * checkio(alg_dop(matrix, 0, j)) for j in range(len(matrix)))
Sept. 11, 2015