Det4x4/sanek13 | Det4x4/Stef-Fun | ||||
---|---|---|---|---|---|
f | 1 | import numpy as np | f | 1 | import numpy as np |
2 | 2 | ||||
n | 3 | def det3(m): | n | 3 | def determ(M): |
4 | return m[0, 0] * m[1, 1] * m[2, 2] + m[0, 1] * m[1, 2] * m[2, 0] + m[1, 0] * m[2, 1] * m[0, 2] - (m[0, 2] * m[1, 1] * m[2, 0] + m[1, 0] * m[0, 1] * m[2, 2] + m[2, 1] * m[1, 2] * m[0, 0]) | 4 | return M[0, 0] * M[1, 1] * M[2, 2] + M[0, 1] * M[1, 2] * M[2, 0] + M[1, 0] * M[2, 1] * M[0, 2] - (M[0, 2] * M[1, 1] * M[2, 0] + M[1, 0] * M[0, 1] * M[2, 2] + M[2, 1] * M[1, 2] * M[0, 0]) | ||
5 | rows = [*eval(input())] | 5 | rows = [*eval(input())] | ||
n | 6 | m = np.array(rows) | n | 6 | M = np.array(rows) |
7 | res = 0 | 7 | res = 0 | ||
t | 8 | sh = [(1, 2, 3), (0, 2, 3), (0, 1, 3), (0, 1, 2)] | t | 8 | M_h = [(1, 2, 3), (0, 2, 3), (0, 1, 3), (0, 1, 2)] |
9 | for (i, ind) in enumerate(sh): | 9 | for (i, ind) in enumerate(M_h): | ||
10 | res += (-1) ** i * m[0, i] * det3(m[1:, ind]) | 10 | res += (-1) ** i * M[0, i] * determ(M[1:, ind]) | ||
11 | print(round(res)) | 11 | print(round(res)) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|