第7回(OOP-第3回)
スライド
code:red_and_black.py
can_move = set()
W,H = 0,0
def check(h, w):
if not (h, w) in can_move and Tilehw != "#": can_move.add((h, w))
for d in range(-1,2):
if 0 <= h + d < H:
check(h+d, w)
if 0 <= w + d < W:
check(h, w+d)
while True:
W, H = map(int, input().split())
if W == 0 and H == 0:
break
can_move = set()
Tile = []
(h, w) = (0, 0)
for i in range(H):
Row = input()
Rowl = []
for r in range(len(Row)):
(h, w) = (i, r)
Tile.append(Rowl)
check(h,w)
print(len(can_move))