Skip to content

Commit be1cf69

Browse files
committed
Solve 2163 - The Force Awakens in python
1 parent db4ffff commit be1cf69

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

solutions/beecrowd/2163/2163.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
output = sys.stdout.write
5+
6+
while line := input().strip():
7+
n, m = map(int, line.split())
8+
x = y = 0
9+
10+
terrain = []
11+
for _ in range(n):
12+
terrain.append(list(map(int, input().split())))
13+
14+
for index_row, row in enumerate(terrain[1:-1], 1):
15+
for index_cell, cell in enumerate(row[1:-1], 1):
16+
if (
17+
cell == 42
18+
and terrain[index_row - 1][index_cell - 1] == 7
19+
and terrain[index_row - 1][index_cell] == 7
20+
and terrain[index_row - 1][index_cell + 1] == 7
21+
and terrain[index_row][index_cell - 1] == 7
22+
and terrain[index_row][index_cell + 1] == 7
23+
and terrain[index_row + 1][index_cell - 1] == 7
24+
and terrain[index_row + 1][index_cell] == 7
25+
and terrain[index_row + 1][index_cell + 1] == 7
26+
):
27+
x = index_row + 1
28+
y = index_cell + 1
29+
break
30+
31+
if x and y:
32+
break
33+
34+
output(f'{x} {y}\n')

0 commit comments

Comments
 (0)