1

Is there some feasible (i.e. polynomial time) algorithm which builds, starting from a small (~20) set of words, a crossword which maximizes (or at least for which is "big") the number of intersection? Or, if the intersection criteria is impractical, is it possible to maximize the density (in some sense) of the crossword?

I have already written an exhaustive search in Python, but it takes too long for more than six words...

See also: Algorithm to generate a crossword (but the answers there, althought good, do not really tackle my issue).

Community
  • 1
  • 1
  • 2
    What exactly is the "issue" those solutions do not tackle? You do realize that algorithms need concrete definitions to work from; things like "dense (in some sense)" are pretty difficult to code to. And maximizing multiple criteria at once is kind of fuzzy, too: how much density are you willing to sacrifice for an extra intersection? – Scott Hunter Mar 19 '15 at 23:41
  • My primary issue is to maximize the number of intersections. I can specify the density part by asking to minimize its size (columns+rows), but I left it ambiguous since I'm not prejudicious towards other ways to measure its density (e.g. mean sup distance from the center)... – Brainstorming Mar 19 '15 at 23:47
  • A somehow better than brute-force solution here: https://colab.research.google.com/drive/1z9tQ61NFKufKMhALj-AQi9nINnqMwiZk#scrollTo=ZyoCZzgaxeiL – Brainstorming Jul 03 '21 at 10:11

1 Answers1

0

Is there some polynomial time algorithm ?

Answer: No.

For a simple version: if a word end's letter is the same of another word beginning's, we can concatenate them. for example:

cat+tree+element -> Valid
aaa+aaa -> Valid
cab+aboard -> Invalid ('a' != 'b')

Question is: try to concatenate words as many as possible.

But it's equivalent to Hamiltonian path problem, so we don't have any polynomial time algorithm for this problem.

See this for details: Hamiltonian path problem

PS:

For a small (~20) set, you can try heuristic search or Dynamic programming method to get a feasible solution.

Sayakiss
  • 6,878
  • 8
  • 61
  • 107