Skip to content

Commit fabdd45

Browse files
committed
[2023-11-23] BOJ 16955 풀이
1 parent f2feb25 commit fabdd45

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

BOJ/brute_force/BOJ_16955.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
def check(x, y):
2+
for k in range(8):
3+
cnt, empty = 1, 0
4+
nx, ny = x, y
5+
for _ in range(4):
6+
nx += d[k][0]
7+
ny += d[k][1]
8+
if nx < 0 or ny < 0 or nx >= 10 or ny >= 10:
9+
continue
10+
if grid[nx][ny] == 'X':
11+
cnt += 1
12+
if grid[nx][ny] == '.':
13+
empty += 1
14+
if cnt == 4 and empty == 1:
15+
return True
16+
return False
17+
18+
grid = [list(input()) for _ in range(10)]
19+
answer = 0
20+
d =[(0, 1), (1, 1), (1,0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1)]
21+
start = []
22+
for i in range(10):
23+
for j in range(10):
24+
if grid[i][j] == 'X':
25+
start.append((i, j))
26+
for a, b in start:
27+
if check(a, b):
28+
answer = 1
29+
print(answer)

0 commit comments

Comments
 (0)