Johnny is trying to create crossword puzzles, but he is having difficulty making words match each other.
He has come up with several simple word rectangles: that is, groups of words that form a rectangle where all horizontal and vertical paths form a word.
However, to make a good puzzle, he needs some word rectangles that are somewhat larger than 3x4. Instead of agonizing over the arrangement letters for hours, Johnny would prefer to have a program that does this for him--and in as few characters as possible, because long blocks of code are extremely intimidating for casual programmers like Johnny.
- a text file dictionary where words are separated by newlines in alphabetical order,
- input specifying the number of rows and columns in the words rectangle (which can be provided however is most convenient in your programming language of choice)
generate at least one word rectangle. If it is not possible to generate a word rectangle with the given lexicon and dimensions, the program need not have defined behaviour. It is not necessary for the program to be able to generate rectangles which contain more than 64 letters or have dimensions that exceed 8 in either direction. The program should be able to complete in a reasonable amount of time, say, in thirty minutes or less.
EDIT: If you are doing an NxN rectangle, you are permitted to use a smaller dictionary file that only contains words that have a length of N letters.