Google Treasure Hunt puzzles are too easy?

2008 May 23rd | By brutuscat | Comments (0) | Permalink

Under: Java - PHP - opinion - programming

Seems that the Google guys are getting softy. The last two questions of the Google Treasure Hunt 2008 were easily solved.

The Question #1 is about paths. We have a robot that can move down or right, in a n x m grid. So how many possible paths exists, from the top left to the top right?

It gets solved just searching in Google for “grid path right down” from there you will get the equation that you must run on any language that has Big Integer implementations, since involves the calculations factorial.

Example of our solution for the first puzzle in Java:

BigInteger dividend = factorial( (rows-1)+(columns-1) );
BigInteger divisor = factorial(rows-1).multiply(factorial(columns -1));
System.out.println(dividend.divide(divisor));

The Question #2 seems to be even easier. It involves to transverse a directory tree, filtering the files that verifies 2 conditions based on the path string and the extension string (like .txt or .xml). Then reading some specific line. All files are text files this simplifies then things even more. Nothing hard to any programmer.

Snippet of our solution for the second puzzle in PHP:

// Setting where's the Google Treasure Hunt Directory
$dirbase = 'GoogleTreasureHunt08_11336769377172459175';

// Creating and loading the directory Tree
$tree = new Mytree($dirbase);
$tree->load();

// Getting the leaf Files
$leafs = $tree->get_leafs();

// Filtering to files that satisfies the conditions
$cond1 = array_filter ($leafs, filter_bycond1);
$cond2 = array_filter ($leafs, filter_bycond2);

// Doing the sums at the right line number
$sum1 = array_reduce($cond1, create_function('$v, $node',
             '$v = ($v == null) ? 0 : $v;'.
             '$v += (int)read_line($node->data, 5);'.
            'return $v;'));
$sum2 = array_reduce($cond2, create_function('$v, $node',
            '$v = ($v == null) ? 0 : $v;'.
            '$v += (int)read_line($node->data, 5);'.
            'return $v;'));

echo $sum1, '<br>';
echo $sum2, '<br>';

// Obtaining result
echo $sum1 * $sum2;

So as you see, there’s no complication at all. I would expect some challenge when Google uses the “Puzzle” word. Maybe they aren’t what they were? I don’t know, but I will be expecting some real challenge to solve :).

Robot solution:  GTH Q1 Java solution

File transeversing solutino: GTH Q2 PHP solution

Data portability is good, but Late 2.0

2008 May 9th | By swain | Comments (0) | Permalink

Under: opinion

Back in 2001 we wrote an arcane simple perl script just for fun. The script gave you the freedom to export IMDB movies from your ranking to your web page. Now in 2008 and with business goals in mind, we need to export/interact with information from sites like LinkedIn and add it to our handcrafted mashup pipeline or our CRM, but it’s not possible without being blocked, see LinkedIn Scraper for more information.

Data portability is a must (sometimes an API is enough) but the "official" data portability innitiative came very late:

> whois dataportability.org

Domain ID:D149678191-LROR
Domain Name:DATAPORTABILITY.ORG
Created On:07-Nov-2007 04:21:39 UTC

Last Updated On:07-Jan-2008 03:49:01 UTC
Expiration Date:07-Nov-2008 04:21:39 UTC

On the other side, sites like LinkedIn increase their business risks if they share too much data and become easily replaceable. So the question is how to deal with this conflict of interest? An obvious business model  is what SalesForce does with AppExchange and Facebook does with Facebook applications: Run your applications within their [eco]system.

So now in 2008 LinkedIn has been lazy to balance between being open or not (even putting a public price to their data sharing policies), but the data portability "lobby" woke up too late, or Late 2.0.