Question: def locate _ words ( grid: list [ str ] ) - > tuple [ list [ tuple [ int , int ] ] ,
def locatewordsgrid: liststr tuplelisttupleint int listtupleint int:
Given a grid represented as a list of strings, where represents open spaces
and represents filled squares, this function returns a tuple containing two
lists: one list with the starting x y coordinates of across words, and another
list with the starting x y coordinates of down words. A word must be at least
two letters long to be considered.
Parameters:
grid list of str: A list of strings representing the crossword grid.
Returns locatewords:
tuple: A tuple containing two lists:
List of x y coordinates for across words.
List of x y coordinates for down words.
height lengrid
width lengrid
acrosswords
downwords
for y in rangeheight:
for x in rangewidth:
if gridyx and x or gridyx :
if x width and gridyx :
acrosswords.appendx y
for y in rangeheight:
for x in rangewidth:
if gridyx and y or gridy x:
if y height and gridy x:
downwords.appendx y
return acrosswords, downwords
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
