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: 8 additions & 1 deletion services/enclose_moose_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ def __init__(self, encoded_grid: str, wall_budget: int):
if self.N <= 1:
raise HTTPException(400, detail="Level must be bigger than one square")

seen_moose = False
for tile in encoded_grid:
if tile == "H":
if not seen_moose:
seen_moose = True
else:
raise HTTPException(400, detail='There can only be one moose ("H")')

if tile not in ("\n", ".", "~", "H", "C", "G", "S") and not tile.isnumeric():
raise HTTPException(400, detail=f'Level contained unknown encoding: "{tile}"')

if "H" not in encoded_grid:
if not seen_moose:
raise HTTPException(400, detail='Level must contain a moose ("H")')

if "\n" not in encoded_grid:
Expand Down
Loading