blob: d1f4e9d8091c9cefcce60242dd7dd0d06ce80b9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
class PlayField:
def __init__(self):
self.grid = [[None for _ in range(10)] for _ in range(20)]
def burn_rows(self) -> int:
""" Burn rows that can be filled and return how many of them were burnt """
rows_to_burn = []
for row in self.grid:
if all(map(lambda element: element is not None, row)):
rows_to_burn.append(row)
for row in rows_to_burn:
self.grid.insert(0, [None for _ in range(10)])
self.grid.remove(row)
return len(rows_to_burn)
|