16 Sep 2004 Lolindrath   » (Journeyer)

Google Billboard Problem

I don't know how many of you have heard about this. Here it is: http://www.npr.org/features/feature.php?wfId=3916173 basically if you solve this problem you go to step 2 in the process. I wrote a nice solution in C# and then found out that people have already posted the answer which is no fun. Anyway, I won't tell you what it is, you can run my code to find that out. This is just the method you'll need to run inside a thread. You'll have to figure out which namespaces to import and what variables you might still need.

Basically it checks for the first couple primes and brute forces the rest by looking up every DNS name and checking if it works or not. It took only a few seconds to find the solution. You'll also need the digits of e.

private void PrimeSearch()
{
	StreamReader sr = new StreamReader("c:\\e.5mil");

string digits = sr.ReadToEnd();

sr.Close();

digits = digits.Replace("\n", "");

for(int i = 1; i < digits.Length - 10; i++) { long num = long.Parse(digits.Substring(i, 10));

if(num % 2 == 0 || num % 3 == 0 || num % 5 == 0 || num % 7 == 0) continue;

string address = "http://www." + digits.Substring(i, 10) + ".com/"; HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(address); wr.AllowAutoRedirect = true;

try { WebResponse page = wr.GetResponse();

if(page.ContentType == "text/html") { textBox1.Text += "\n" + address; } } catch(WebException ex) { if(ex.Status != WebExceptionStatus.NameResolutionFailure) MessageBox.Show(ex.Message); }

label1.Text = i.ToString(); Thread.Sleep(1); } }

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!