Skip to content

Instantly share code, notes, and snippets.

@maehrm
Created March 14, 2026 01:11
Show Gist options
  • Select an option

  • Save maehrm/7647d9a17c7d5b4f29253e136f3c1c2e to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/7647d9a17c7d5b4f29253e136f3c1c2e to your computer and use it in GitHub Desktop.
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
ans = 0
for i in range(H - 1):
for j in range(W - 1):
cnt = 0
for di, dj in ((0, 0), (0, 1), (1, 0), (1, 1)):
if S[i + di][j + dj] == "#":
cnt += 1
if cnt == 1 or cnt == 3:
ans += 1
print(ans)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment