I have been given a matrix containing a crossword puzzle plan - of course, unfilled. The goal is to complete the entire puzzle - this is a task from Checkio, and I have been struggling with this for quite some time.
From what I understand about complexity, there is no perfect algorithm for this problem. However, there should be a better way to do this, right? I tried different things, and the results were not good with the increase in the number of words in the crossword and / or dictionary.
So, some of the things I tried:
- simple crude forcing. Did not work at all, as he ignored the rewriting of intersections.
- forced formatting while saving all relevant data - worked, as expected, using a specific dictionary, turning into hell with a moderately large one, even with optimization of the word length. Figures.
- filling in dead crossroads is an idea in which I thought it was better not to worry about intersecting words, instead focusing on letters. How to start with As and see if you can complete the entire crossword puzzle with these limitations. If this doesn’t work for some words, increase one of the letters and try all this again. The results were terrible, as you might expect.
- recursive research - worked fine on simpler drawings, but fell exactly with more complex ones. There was a problem with a simple one that was solved quite simply, but I did not find a reasonable solution to the situation where the path splits and then joins several further splits again (so that there is nothing left to solve for the second branch, but it does not know that).
- minimizing intersections - not yet tested, but looks promising. The idea is that I find the shortest list of words containing all intersections ... which also do not intersect with every Other. Then I can simply use the generator for each of these words and then check if the dependent words exist with these intersections. If they do not, I just grab the next word from the generator.
. , , , , , .
, ?
:
- , , , . - , .
:
['...XXXXXX',
'.XXX.X...',
'.....X.XX',
'XXXX.X...',
'XX...X.XX',
'XX.XXX.X.',
'X......X.',
'XX.X.XXX.',
'XXXX.....']

.
, "" - , , .