i am currently trying to draw lines over words that have been found in a word search matrix in python. what i currently have only puts a dot on words that were not used. but i would prefer to draw lines like in an actual word search game.
import sys
def search(grid, rc, word,path):
if word == "": return path
if rc not in grid.keys() or rc in path or word[0] not in [grid[rc]]: return[]
return [p for r in [-1,0,1] for c in [-1,0,1]
for p in search(grid, (rc[0]+r, rc[1]+c), word[1:], [rc]+path)]
grid = dict ([((row,col), ch) for row, line in enumerate(a)
for col, ch in enumerate(line)])
#print(grid)
mark = [path for word in word_list
for rc in grid.keys()
for path in search(grid,rc,word,[])]
print "\n".join([" ".join([ch if (row, col) in mark else '.' for col,ch in enumerate(line)])
for row,line in enumerate(a)])
where a is the 15 by 15 matrix of words and word_list is the list of words to be found.