Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, m = map(int, input().split())
- a = []
- for i in range(n):
- s = input()
- a.append(s)
- di = [-1, 1, 0, 0]
- dj = [0, 0, 1, -1]
- for i in range(n):
- for j in range(m):
- if a[i][j] == '#':
- print(a[i][j], end='')
- continue #go to the next j
- hasHashtagNeighbor = False
- for d in range(4):
- ni = i + di[d]
- nj = j + dj[d]
- if ni >= 0 and nj >= 0 and ni < n and nj < m and a[ni][nj] == '#':
- hasHashtagNeighbor = True
- if hasHashtagNeighbor == True:
- print('X', end='')
- else:
- print('.', end='')
- print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement