Question: def has _ ship ( fleet _ grid: list [ list [ str ] ] , row _ start: int, col _ start: int, ship

def has_ship(fleet_grid: list[list[str]], row_start: int, col_start: int,
ship_symbol: str, ship_size: int)-> bool:
"""Return True if and only if a ship that (1) uses ship_symbol as its ship
symbol and (2) has length ship_size appears in fleet_grid starting at
position (row_start, col_start), where (row_start, col_start) is the
top-most/left-most corner of the ship.
If the ship has ship_size 2 or more and appears as both a column and a row,
return False.
Preconditions:
0 len(fleet_grid)
len(fleet_grid[i])== len(fleet_grid)
for each value of i in range(len(fleet_grid))
0 row_start len(fleet_grid)
0 col_start len(fleet_grid)
MIN_SHIP_SIZE = ship_size = MAX_SHIP_SIZE
fleet_grid[i][j]!= ship_symbol for each of the coordinates
(i,j)=(row_start -1, col_start) or
(i,j)=(row_start, col_start -1)
when those coordinates are valid indexes for fleet_grid> has_ship(grid,0,1,'b',2)
True
has_ship(grid,0,1,'b',1)
False
has_ship(grid,0,1,'b',3)
False
has_ship(grid,1,0,'a',1)
True
grid =[['b','b','b'],['b', EMPTY, EMPTY],['b', EMPTY, EMPTY]]
has_ship(grid,0,0,?'b',3
False
"""
 def has_ship(fleet_grid: list[list[str]], row_start: int, col_start: int, ship_symbol: str, ship_size: int)->

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!