Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Word search algorithm

Tags:

algorithm

I am trying to come up with a better approach than the "brute force" method, but am at somewhat of a loss.

Here is a simple case:

Given a finite number of pre-chosen letters, and a hatch (like a crossword overlap) I am attempting to find all combination of words that can be used. (Words are retrieved from a dictionary database.)

Example:

Given the letters:
a,c,r,e,t,u,p,l,m,o
how many combinations of words can fit in the following crossword puzzle?

   _
 _ _ _ _ 
   _
   _
   _ _ _

One example:

  c
t r e e
  e
  e
  p o t

Of course the search time increases dramatically with each letter or addition to the crossword hatch. Any suggestions for a better way to search?

like image 341
kylex Avatar asked Sep 09 '11 01:09

kylex


People also ask

What is the trick to word searches?

Use a highlighter pen or light-colored pencil if you want to mark on top of the words you find. Otherwise, use a pen or pencil to draw loops around the words. Search for less-common letters in a word, such as J, B, K, Q, X, Y, or Z. This strategy makes the rest of the word easier to find.

What is word search from a grid?

A word search is a puzzle that uses words and puts them in a grid. The point of the game is to find all of the words hidden in the grid.

What are the rules of word search puzzles?

Words should be interlinked (cross at letters) and a large majority of the letters in the grid should be crossed by words. The words should be linked thematically, although the word list need not be provided. Standard variations, including missing letters, rebus clues, or bending words, are also encouraged.

How does a word search work?

A word search, word find, word seek, word sleuth or mystery word puzzle is a word game that consists of the letters of words placed in a grid, which usually has a rectangular or square shape. The objective of this puzzle is to find and mark all the words hidden inside the box.


1 Answers

Check out the open source arccc, which fills in crossword grids by treating them as a constraint satisfaction problem. If you would like to do this yourself as a learning exercise, reading up on CSPs should be a good starting point.

As for limiting the alphabet, that's best done as a preprocessing step on the source dictionary.

like image 60
Martin DeMello Avatar answered Oct 18 '22 06:10

Martin DeMello