t | def permuts(row): | t | def permuts(row): |
| if len(row) == 1: | | if len(row) == 1: |
| return [row] | | return [row] |
| permutsList = [] | | permutsList = [] |
| for i in range(len(row)): | | for i in range(len(row)): |
| row1 = row.copy() | | row1 = row.copy() |
| row1.remove(row[i]) | | row1.remove(row[i]) |
| k = permuts(row1) | | k = permuts(row1) |
| for j in range(len(k)): | | for j in range(len(k)): |
| t = [row[i]] | | t = [row[i]] |
| t += k[j] | | t += k[j] |
| permutsList.append(t) | | permutsList.append(t) |
| return permutsList | | return permutsList |
| | | |
| def inversions(l): | | def inversions(l): |
| ans = 0 | | ans = 0 |
| for i in range(len(l)): | | for i in range(len(l)): |
| for j in range(i + 1, len(l)): | | for j in range(i + 1, len(l)): |
| if l[i] > l[j]: | | if l[i] > l[j]: |
| ans += 1 | | ans += 1 |
| return ans | | return ans |
| | | |
| def Det4x4(matrix): | | def Det4x4(matrix): |
| ans = 0 | | ans = 0 |
| l = [] | | l = [] |
| inv = [] | | inv = [] |
| row = [x for x in range(len(matrix))] | | row = [x for x in range(len(matrix))] |
| l = permuts(row) | | l = permuts(row) |
| for i in range(len(l)): | | for i in range(len(l)): |
| k = inversions(l[i]) | | k = inversions(l[i]) |
| if k % 2: | | if k % 2: |
| inv.append(-1) | | inv.append(-1) |
| else: | | else: |
| inv.append(1) | | inv.append(1) |
| for i in range(len(l)): | | for i in range(len(l)): |
| k = 1 | | k = 1 |
| for row in range(len(matrix)): | | for row in range(len(matrix)): |
| k *= matrix[row][l[i][row]] | | k *= matrix[row][l[i][row]] |
| ans += inv[i] * k | | ans += inv[i] * k |
| return ans | | return ans |
| matrix = eval(input()) | | matrix = eval(input()) |
| print(Det4x4(matrix)) | | print(Det4x4(matrix)) |