Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions flower-field/flower_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,9 @@ def _validate(garden: list[str]):
other than space or ``*``.
"""
garden_length = len(garden[0])
# when the board receives malformed input
for row in garden:
# when the board receives malformed input
# garden is not a rectangle due to inconsistent row length
if len(row) != garden_length:
raise ValueError("The board is invalid with current input.")
# contains invalid chars inside row
valid_chars = all(char in " *" for char in row)
if not valid_chars:
# or contains invalid chars inside the row
if len(row) != garden_length or not all(char in " *" for char in row):
raise ValueError("The board is invalid with current input.")