how to draw lines over words found in a word search matrix in python -
i trying draw lines on words have been found in word search matrix in python. have puts dot on words not used. prefer draw lines in 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 r in [-1,0,1] c in [-1,0,1] p in search(grid, (rc[0]+r, rc[1]+c), word[1:], [rc]+path)] grid = dict ([((row,col), ch) row, line in enumerate(a) col, ch in enumerate(line)]) #print(grid) mark = [path word in word_list rc in grid.keys() path in search(grid,rc,word,[])] print "\n".join([" ".join([ch if (row, col) in mark else '.' col,ch in enumerate(line)]) row,line in enumerate(a)])
where 15 15 matrix of words , word_list list of words found.
Comments
Post a Comment