GeekStreet

Geek stuff, mostly.

Wednesday, July 14, 2004

Google puzzle

Some time last week, a huge billboard appeared on Highway 101 in Silicon Valley. It said simply:

"{ First 10 digit prime in consecutive digits of e }.com"
While this has not made much of a stir(where stir=when somebody claims he wrote the linux kernel) on the Intarweb, it's something of a teeny puzzle.
The first ten-digit prime number in the digits of e is 7427466391.

The billboard was a hint to go to 7427466391.com, where the next step of the puzzle lay.

Congratulations. You've made it to level 2. Go to www.Linux.org and enter Bobsyouruncle as the login and the answer to this equation as the password.

f(1)= 7182818284
f(2)= 8182845904
f(3)= 8747135266
f(4)= 7427466391
f(5)= __________
Meanwhile, astute puzzle-solvers had done a whois query on the site, and found the name of Google in the fine print.

Of course, I cheated.

Feel free to try your hand at the puzzle, before reading the rest.

The clue is that, the digits sum to 49, for all these numbers. The digits of e are available on the web, from where I obtained the first 2M digits in the expansion. Next, a ruby script to look for my numbers.
(I love the way Ruby gets out of my way)

class Array
def sum
inject(0) {|s,i| s+i}
end
end

def _find49(str)
arr = str.scan(/\d/).collect {|i| i.to_i}
found = []
arr.each_index { |i|
if(i < arr.length - 10)
if(arr[i..i+9].sum == 49)
found << arr[i..i+9].inject(0){|s,ii| s*10+ii} if(arr[i]>0)
end
end
}
found
end
require 'yaml'
list = _find49(File.open('C:\Files\Docs\e.2mil') {|f| f.read})
File.open('C:\Files\Docs\data.yaml',"w") {|f| f.write(list.to_yaml)}


A moment's grokking of the resulting yaml file in irb gave me the answer.

Well, disappointingly, that was the last step of the puzzle, leading here. Bah.

(The whole thing was being discussed on JoS forums, from where I picked up the relevant hints.)