Problem10

This commit is contained in:
t3xhno
2024-02-06 17:02:38 +01:00
parent 25e9167e85
commit a8b7f49051
2 changed files with 53 additions and 0 deletions

19
lib/matrix.py Normal file
View File

@@ -0,0 +1,19 @@
def prodAdj(take, i, j, matrix):
result = [0, 0, 0, 0]
# On the x axis
if j < len(matrix[i]) - take + 1:
result[0] = matrix[i][j] * matrix[i][j + 1] * matrix[i][j + 2] * matrix[i][j + 3]
# On the y axis
if i < len(matrix) - take + 1:
result[1] = matrix[i][j] * matrix[i + 1][j] * matrix[i + 2][j] * matrix[i + 3][j]
# Diagonally to the right
if i < len(matrix) - take + 1 and j < len(matrix[i]) - take + 1:
result[2] = matrix[i][j] * matrix[i + 1][j + 1] * matrix[i + 2][j + 2] * matrix[i + 3][j + 3]
# Diagonally to the left
if i < len(matrix) - take + 1 and j > take - 1:
result[3] = matrix[i][j] * matrix[i + 1][j - 1] * matrix[i + 2][j - 2] * matrix[i + 3][j - 3]
return result