Skip to content

Instantly share code, notes, and snippets.

@amireshoon
Created June 18, 2021 15:17
Show Gist options
  • Save amireshoon/c806385e1e5bd9e5dd6ef5ff1d7e3e3c to your computer and use it in GitHub Desktop.
Save amireshoon/c806385e1e5bd9e5dd6ef5ff1d7e3e3c to your computer and use it in GitHub Desktop.
Check two matrix and sum the keys if both equal to 1
m = [
[1,2,1,1,1,0,2,1,1],
[2,2,1,1,2,3,6,2,1],
[1,2,1,1,1,0,1,1,1],
[2,2,1,1,2,3,1,2,1]
]
for i in range(0, len(m), 2):
total = 0
for k,j in enumerate(m[i]):
if j == m[i+1][k] and j == 1:
total = total + j + m[i+1][k]
print(total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment