0

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.

candy007
  • 11
  • 1
  • What? Could you clarify what you have now, and what you would like instead? Do you mean [strike-through](http://en.wikipedia.org/wiki/Strikethrough)? – jonrsharpe Dec 16 '14 at 11:36
  • yes strike through. i believe this is achieved using matplotlib inline but i do not know how to. – candy007 Dec 16 '14 at 11:44
  • ...but you don't seem to be using `matplotlib`. If you're just printing text in the terminal see e.g. http://stackoverflow.com/q/25244454/3001761, http://stackoverflow.com/q/8357203/3001761 – jonrsharpe Dec 16 '14 at 11:46

0 Answers0