Treebeard's Stumper Answer12 May 2000

Science Fair Crossword

It seems so simple. Take a list
of words, say the first names of all Dunn Middle School students and staff, and
arrange them all crossword-style in the smallest possible square
grid. But there are too many possibilities for even my fast
computer program to check them all! That's my project for this year's
DMS Science Fair, just one among the many interesting projects and collections.
Here is my best shot (so far)
at making a real crossword puzzle with my XWORD program.
The answers are all DMS first names, and we all wrote
our own tough clues.

This puzzle will only make sense to DMS kids.
I know these kids pretty well, and I couldn't guess half their clues!
The kids did better, and Whitney and Amanda finished it first.
You can also get the DMS word list and try it without clues
as a 'fill-in' or 'criss-cross', or whatever you call that type of puzzle.
Duplicate names are only used once in the grid. (Thanks, Graybear!)

Last week's crossword solution is below.
The clues were too hard for me, but the kids did better.
Amanda and Whitney got it first. I can fit all DMS staff and
students into a 21 x 21 grid except "cianna," who pushes it to
21 x 22. That took 21 hours of computer time! There might be a
better solution, but there is no simple algorithm to find it except to
keep trying. Mathematicians call such problems intractable or
NP-complete.
They are the basis of modern cryptography because they
are so hard to solve, even for fast computers.

Graybear took the DMS word list and
solved the puzzle without using the clues:

It took me less than an hour to get the solutions... There is not a
unique solution, there are four, but I believe I can narrow it down to
two by assuming that 34-Down "Mojo man" is Marc, and 28-Down "Short
stuff" is Mary. The other pair is 39-Down "Horse named 'Kate'" and
45-Across "Basketball singer" which are Amanda and Cianna.

I'm impressed, Graybear! Mojo is my dog, so 34-down is me.

Here's my best shot at making a word grid from the
26 science words in my ABCs of Science stumper.
A grid of 23 by 23 is the best I can do.
This was hard since most words are long and share the same "ology" ending.

Crossword puzzles are more difficult to make than to solve.
There are just too many possibilities to check them all systematically in any
realistic time-frame, even with fast computers. Even if a potentially best solution is found,
there's no way to prove it's the best except to check every other possible
arrangement. So the programming goal isn't to find the best arrangement right off,
but to quickly find an ok solution, and then improve it as better solutions are found.
There's no easy way to know when we're done.

Factoring big numbers into primes
is another classic intractable problem.
There are mathematical shortcuts, but in the end, you basically have to try dividing your
number by every prime number less than its square root. When numbers get very big,
the task is too much, even for fast computers. At least that's the hope, since
modern encryption programs and secure servers use this intractable math problem to make their secret keys.
The Traveling Salesman problem is another classic intractable problem.
There may well be a better solution to the DMS word list, and I just haven't found it yet.
There's no way to know except to keep searching.
Bonus stumper: which Simpsons episode also mentions NP-complete problems?

My XWORD program does better than the commercial Crossword Compiler program at finding tight
grids for random word lists, but it's still a pretty dumb program. It starts by
scoring each word for how many letters it shares with other words in the list,
and then it normalizes the scores for word length. It usually starts with a high-scoring
medium-length word, and usually puts it near a corner, and then
builds a linked list of crossed-words from that.
If it's the best so far, it remembers.
Then it tries another, and so on.
It doesn't get any smarter as it works longer, but it randomly breaks its own rules now and then.
Is that enough to be AI?

My program can't (yet) put words into solid blocks. Real crossword
puzzles like you find in the newspaper always feature solid word grids,
and they are always symmetrical. That's much harder. Good crossword
grids are still mostly contructed by hand, though computer
dictionary searches
with wildcard characters are helpful. I've never tried to make
a real crossword grid by hand. It's a special skill with commercial
value. Crossword enthusiasts can recognize the style of individual
constructors. The commercial Crossword Compiler program can make real
puzzles, and it has many other useful features. My program is not
meant to compete.

Making a minimum crossword grid from a list of words is known as a
Crozzle, after an Australian newspaper puzzle. This was the spring 1996
problem for the
Programmer Of The Month (POTM) contest.
The POTM Web site includes C code, discussion of algorithms, and more good stumpers. They
don't accept BASIC code in their contests due to their professional Unix bias. They ran each entered program with three different word lists
for a max time of 10 minutes each, and recorded words used, connector letters, and total letters.
I did it too and got these results:

Eighth place is not bad for good ol' DOS BASIC in this competition!
And I ran my program on my home computer, not the fast Unix box the others ran on!
The winning programs made tighter grids by putting words right next to each other.
My program can't do that yet, but I know how to do it.

You can download my XWORD program with source code and executable from
Treebeard's Basic Vault.
This is a rough draft DOS BASIC/QBasic/QuickBasic program that runs fine in a Command window under Win98.
It will make a crossword grid from any word list, and save it as an HTML file ready for the Web.
I used my program to make the crosswords and solutions on this page.
It's primative, but it might be a useful program for teachers.

Making a minimum crossword grid from a list of words is known as a
Crozzle, after an Australian newspaper puzzle. This was the spring 1996 problem for the
Programmer Of The Month (POTM) contest.
The POTM site includes C code, discussion of algorithms, and more good stumpers.
But I started from scratch, using good old BASIC.

Crossword Compiler is a highly regarded
commercial crossword puzzle program for constructors. They offer a free demo,
but you have to pay for the real thing.
There are many other programs freely available, eg at the
Crossword Archive.