Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's how I would try this. First construct a prefix tree.</p> <p>Pick a word and place it horizontally on top. Pick a word and place it vertically. Alternate them until exhausted options. By alternating you start to fix the first letters and eliminating lots of mismatching words. If you really do find such square, then do a check whether they can be made with those pieces.</p> <p>For 5x5 squares: after doing some thinking it can't be worse than O(12000!/11990!) for random text words. But thinking about it a little bit more. Every time you fix a letter (in normal text) you eliminate about 90% (an optimistic guess) of your words. This means after three iterations you've got 12 words. So the actual speed would be</p> <pre><code>O(n * n/10 * n/10 * n/100 * n/100 * n/1000 * n/1000 ... which for 12000 elements acts something like n^4 algorithm </code></pre> <p>which isn't that bad.</p> <p>Probably someone can do a better analysis of the problem. But the search for words should still converge quite quickly.</p> <p>There can be more eliminating done by abusing the infrequent letters. Essentially find all words that have infrequent letters. Try to make a matching positions for each letters. Construct a set of valid letters for each position.</p> <p>For example, let's say we have four words with letter Q in it.</p> <pre><code> AQFED, ZQABE, EDQDE, ELQUO this means there are two valid positionings of those: xZxxx AQFED xAxxx ---&gt; this limits our search for words that contain [ABDEFZ] as the second letter xBxxx xExxx same for the other EDQDE ---&gt; this limits our search for words that contain [EDLU] as the third letter ELQUO all appropriate words are in union of those two conditions </code></pre> <p>So basically, if we have multiple words that contain infrequent letter X in word S at position N, means that other words that are in that matrix must have letter that is also in S in position n.</p> <p>Formula:</p> <ul> <li>Find all words that contain infrequent letter X at position 1 (next iteration 2, 3... )</li> <li>Make a set A out of the letters in those words</li> <li>Keep only those words from the dictionary that have letter from set A in position 1</li> <li>Try to fit those into the matrix (with the first method)</li> <li>Repeat with position 2</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload