Question: def validate _ symbol _ counts ( fleet _ grid: list [ list [ str ] ] , ship _ symbols: list [ str ]
def validatesymbolcountsfleetgrid: listliststr
shipsymbols: liststr
shipsizes: listint bool:
"Return True if and only if fleetgrid contains each ship symbol in
shipsymbols the correct corresponding number of times from shipsizes,
and nothing else except for the EMPTY character.
shipsymbols and shipsizes are parallel lists.
Note: This function does not consider whether ship symbols are positioned
in an appropriate manner to form a complete ship. It simply validates the
symbol counts.
Preconditions:
def ountsrid: list
ymbols: list
izes: list bool:
True and only rid contains each ship symbol
ymbols the correct corresponding number times from izes,
and nothing else except for the EMPTY character.
ymbols and izes are parallel lists.
Note: This function does not consider whether ship symbols are positioned
appropriate manner form a complete ship. simply validates the
symbol counts.
Preconditions:
lenrid
lenrid lenrid
for each value rangerid
lenymbols lenizes and lenymbols
lenymbols
for each value rangeymbols
lenizes
for each value rangeizes
grid EMPTY EMPTY
ships
sizes
ounts ships, sizes
True
grid EMPTY, EMPTY EMPTY
ships
sizes
ounts ships, sizes
True
grid
ships
sizes
ounts ships, sizes
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
