A: Pawn on a Grid (Atcoder)

Hyoungtak (Alvin) Cha·2023년 1월 2일
0

Problem Statement
There is a grid with H rows from top to bottom and W columns from left to right. Each square has a piece placed on it or is empty.

...
How many squares in the grid have pieces on them?

Constraints
1≤H,W≤10
H and W are integers.

Output
Print the number of squares with pieces as an integer.

PS: I got the input in h and w and for h amount of times, counted the number of '#'s in the S.

h, w = map(int, input().split())
cnt = 0
for _ in range(h):
    cnt += input().count('#')
print(cnt)

0개의 댓글