0

Python word search game help

hi, i was just trying to get my head around a question that came up in a test a few days ago. I need to create a python program that can take a grid of letters and extract words from it. the hidden words will be vertical, horizontal and backwards but NOT diagonal... so basically a simple word search game. Any help from someone that knows what they're doing would be appreciated as its been playing with my head for a few days now. thanks

16th Dec 2017, 9:10 PM
Python
Python - avatar
1 Réponse
- 1
Turn the grid into arrays the loop through the arrays with a dictionary that does partial word searches e.g. BATS ATEB TEAS Would produce the following arrays BATS ATEB TEAS BAT ATE TEA SBS Otherwise an x+y array would produce x+y array (x y.length and y x.length arrays) You can check for duplicates first Then go through each to find words in a dictionary. e.g. in BATS it would go B Then BA Then BAT Then BATS Then A Then AT Then ATS ... Then S ... Then STAB ... Then AB Finally B Usually beside A or I single letters are not words. So after AT when S is added the list should go back to 0, hence AT is a word. So for SBS It will try S and SB but not SBS, since no words I know begins with SB then it will try B and BS (here we check if just BS is a word. Basically before the list becomes 0 or when the last letter is reached you check if those letters are an entry.
17th Dec 2017, 2:35 AM
H Chiang