Skip to content

Commit 94e8cd7

Browse files
authored
Merge pull request #264 from ikostan/main
Merge from master
2 parents eebda3b + 17448cc commit 94e8cd7

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

flower-field/flower_field.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,12 @@ def _calc_surrounding_flowers(i_row: int, i_col: int, garden: list[str]) -> int:
6969
:returns: Number of adjacent flowers (0–8).
7070
:rtype: int
7171
"""
72-
total: list[int] = [0]
73-
# Only compute neighbors for empty squares; flowers are preserved by caller.
74-
if garden[i_row][i_col] == " ":
75-
# Count flowers all around current position
76-
total = [
77-
_process_cell(i_row, offset_row, i_col, offset_col, garden)
78-
for offset_row, offset_col in COORDINATES
79-
]
80-
81-
return sum(total)
72+
if garden[i_row][i_col] != " ":
73+
return 0
74+
return sum(
75+
_process_cell(i_row, offset_row, i_col, offset_col, garden)
76+
for offset_row, offset_col in COORDINATES
77+
)
8278

8379

8480
def _process_cell(i_row, offset_row, i_col, offset_col, garden) -> int:

0 commit comments

Comments
 (0)