This approach does NOT solve the problem in under a minute,
unless of course you are extremely lucky. The best time I've
seen so far has been about 76 seconds. Before I came up with
this code, I tried to search for the solution by generating a
list of all possible solutions based on the information given in
the guesses. This was feasible with the 5 digit problem, but
completely intractable with the 16 digit problem. The approach
here, simple yet effective, is to make a random guess, and then
vary each digit in the guess from [0..9], generating a score of
how well the guess matched the given numbermind clues. You then
improve the guess by selecting those digits that had a unique
low score. It turns out this approach converges rather quickly,
but can often be stuck in cycles, so we test for this and try a
differenct random first guess if a cycle is detected. Once you
run the program, you might have time for a cup of coffee, or
maybe even a dinner. HenryLaxen 2008-03-12

Here's another solution, and this one squeaks by in just under a minute on my machine. The basic idea is to just do a back-tracking search, but with some semi-smart pruning and guess ordering. The code is in pretty much the order I wrote it, so most prefixes of this code should also compile. This also means you should be able to figure out what each function does one at a time.

The solution to this problem isn't terribly difficult, once you
know that the numbers the problem is referring to are called
semiprimes. In fact there is an excellent write-up at:
http://mathworld.wolfram.com/Semiprime.html which provides an
explicit formula for the number of semiprimes less than a given
number.

The problem with this formula is the use of pi(n) where pi is
the number of primes less than n. For Mathematica users this is
no problem since the function is built in, but for us poor
Haskeller's we have to build it ourselves. This is what took
the most time for me, to come up with a pi(n) function that can
compute pi(50000000) in less than the lifetime of the universe.
Thus I embarked on a long and circuitous journey that eventually
led me to the PI module below, which does little more than read
a 26MB file of prime numbers into memory and computes a map from
which we can calculate pi(n). I am sure there must be a better
way of doing this, and I look forward to this entry being
amended (or replaced) with a more reasonable solution.
HenryLaxen Mar 24, 2008

For those of us who can reach all the back into our sophomore
calculus class memories, we will find the dreaded Lagrange
Multipliers, which say that if you want to max(min)imize f
subject to a constraint g, then the gradients of f and g have to
be parallel, or grad f = L * grad g.