Question: def has _ ship ( fleet _ grid: list [ list [ str ] ] , row _ start: int, col _ start: int, ship
def hasshipfleetgrid: listliststr rowstart: int, colstart: int,
shipsymbol: str shipsize: int bool:
Return True if and only if a ship that uses shipsymbol as its ship
symbol and has length shipsize appears in fleetgrid starting at
position rowstart, colstart where rowstart, colstart is the
topmostleftmost corner of the ship.
If the ship has shipsize or more and appears as both a column and a row,
return False.
Preconditions:
lenfleetgrid
lenfleetgridi lenfleetgrid
for each value of in rangelenfleetgrid
rowstart lenfleetgrid
colstart lenfleetgrid
MINSHIPSIZE shipsize MAXSHIPSIZE
fleetgridij shipsymbol for each of the coordinates
rowstart colstart or
rowstart, colstart
when those coordinates are valid indexes for fleetgrid hasshipgridb
True
hasshipgridb
False
hasshipgridb
False
hasshipgrid
True
grid bbbb EMPTY, EMPTYb EMPTY, EMPTY
hasshipgrid
False
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
