User:FLEM/Crosswords: Difference between revisions
Line 10: | Line 10: | ||
Create a grid of whatever size and a list of words. | Create a grid of whatever size and a list of words. | ||
Shuffle the word list, and then sort the words by longest to shortest. | Shuffle the word list, and then sort the words by longest to shortest. | ||
Place the first and longest word at the upper left most position, 1,1 (vertical or horizontal). | Place the first and longest word at the upper left most position, 1,1 (vertical or horizontal). | ||
Move onto next word, loop over each letter in the word and each cell in the grid looking for letter to letter matches. | Move onto next word, loop over each letter in the word and each cell in the grid looking for letter to letter matches. | ||
When a match is found, simply add that position to a suggested coordinate list for that word. | When a match is found, simply add that position to a suggested coordinate list for that word. | ||
Loop over the suggested coordinate list and "score" the word placement based on how many other words it crosses. Scores of 0 indicate either bad placement (adjacent to existing words) or that there were no word crosses. | |||
Loop over the suggested coordinate list and "score" the word placement based on how many other words it crosses. Scores of 0 indicate either bad placement (adjacent to existing | |||
words) or that there were no word crosses. | |||
Back to step #4 until word list is exhausted. | Back to step #4 until word list is exhausted. | ||
Revision as of 00:24, 9 February 2022
.experiments
08.02.2022
there has to be a way to put a dot or something at the end of words!
Create a grid of whatever size and a list of words.
Shuffle the word list, and then sort the words by longest to shortest.
Place the first and longest word at the upper left most position, 1,1 (vertical or horizontal).
Move onto next word, loop over each letter in the word and each cell in the grid looking for letter to letter matches.
When a match is found, simply add that position to a suggested coordinate list for that word.
Loop over the suggested coordinate list and "score" the word placement based on how many other words it crosses. Scores of 0 indicate either bad placement (adjacent to existing
words) or that there were no word crosses.
Back to step #4 until word list is exhausted.
.bibliography
https://medium.com/@vanacorec/backtracking-and-crossword-puzzles-4abe195166f9