-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtempCodeRunnerFile.python
More file actions
41 lines (34 loc) · 917 Bytes
/
tempCodeRunnerFile.python
File metadata and controls
41 lines (34 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
matriz = [
[1, 0, 0],
[1, 1, 0],
[0, 0, 0]
]
count = 0
for i in range(3):
for j in range(3):
count = 0
if 0 <= i-1:
if 0 <= j-1:
if matriz[i-1][j-1] == 1:
count += 1
if matriz[i-1][j] == 1:
count += 1
if j+1 < 3:
if matriz[i-1][j+1] == 1:
count += 1
if 0 <= j-1:
if matriz[i][j-1] == 1:
count += 1
if j+1 < 3:
if matriz[i][j+1] == 1:
count += 1
if i + 1 < 3:
if 0 <= j-1:
if matriz[i + 1][j-1] == 1:
count += 1
if matriz[i+1][j] == 1:
count += 1
if j+1 < 3:
if matriz[i+1][j+1] == 1:
count += 1
print(count, i, j)