nibot ([personal profile] nibot) wrote2004-07-13 02:11 am

google challenge

So, Google currently has a little promotion that involves a sort of puzzle hunt. The first puzzle, published on billboards and at [livejournal.com profile] googleblogatom is to find the first 10-digit prime number to occur in consecutive digits of e.

I tried to solve it using only standard unix programs, with the following pipeline:

cat e.2mil | delay_line 10 | factor | awk '$1=$2":" {print($2)}'

That pops out the right answer immediately...

e.2mil is a text file containing the first 2 million digits of e, and delay_line is a little C program that takes a stream of characters and whenever it receives a character after the ninth character, it outputs the previous ten characters seen. It would be much more satisfying if delay_line were implemented as a clever script and perhaps if e.2mil were generated somehow instead of with Mathematica or a Google search. (I know that there are faster ways to check primality than explicitly computing factors, but obviously this is quick enough...)

Two fun exercises on the side: download GNU coreutils and look at the sourcecode to factor to see how it works (it uses 'Wheel Factorization'), and compute the expected position of the first 10-digit prime in a random sequence of digits.

The second puzzle is to find what comes next in this sequence: 7182818284, 8182845904, 8747135266, 7427466391, _____ .

Further notes will appear on [livejournal.com profile] nibot_lab.

[identity profile] eigenvalue.livejournal.com 2004-07-13 07:40 am (UTC)(link)
Hmm, what's so interesting about primes in the digits of e? I don't see what Google is trying to do ...

[identity profile] nibot.livejournal.com 2004-07-13 07:06 pm (UTC)(link)
Nothing really.. it's just a convenient source of pseudorandom digits. (-:

They're just posing some puzzles...

[identity profile] eigenvalue.livejournal.com 2004-07-13 07:35 pm (UTC)(link)
Hmm, right.

In any case, I liked your solution method.