1def det(matrix):
2 order=len(matrix)
3 posdet=0
4 for i in range(order):
5 posdet+=reduce((lambda x, y: x * y), [matrix[(i+j)%order][j] for j in range(order)])
6 negdet=0
7 for i in range(order):
8 negdet+=reduce((lambda x, y: x * y), [matrix[(order-i-j)%order][j] for j in range(order)])
9 return posdet-negdet
10