Created
June 18, 2021 15:17
-
-
Save amireshoon/c806385e1e5bd9e5dd6ef5ff1d7e3e3c to your computer and use it in GitHub Desktop.
Check two matrix and sum the keys if both equal to 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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