Posts Tagged ‘google’

Google Treasure Hunt: Network Question

Wednesday, November 5th, 2008
Network Problem

Network Problem

The network question was by far the easiest one in GTH 2008 contest.

Sample question:

Below is a diagram of a computer network. The nodes are hosts on the network, and the lines between them are links. A packet is sent out from host N with a destination of 201.107.56.70. Which nodes does the packet pass through on its way to the destination? (include start and final node in your answer)

After that, Google presented a list of nodes with their IP addresses, 3 different static routes and a default gateway. This is the entry for host N:

N 97.134.15.173 88.42.227.237 => 53.138.73.76 201.107.56.70 => 179.138.156.133 68.190.198.0/24 => 248.194.205.8 246.10.120.232

Pretty easy:

  1. A packet going to 201.107.56.70 arrives at node N
  2. Does it match 88.42.227.237 destination host? No… next try
  3. Does it match 201.107.56.70 destination host? Yes!
  4. The packet is forwarded to the host having 179.138.156.133 IP address (which is host B):
B 179.138.156.133 31.114.20.211 => 248.194.205.8 53.138.73.76 => 97.134.15.173 248.194.205.0/24 => 67.244.46.98 53.138.73.76

And so forth…

<bonus>

How would route table at host B look like?

devel@stewie:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
31.114.20.211   248.194.205.8   255.255.255.255 U     0      0        0 eth0
53.138.73.76    97.134.15.173   255.255.255.255 U     0      0        0 eth0
248.194.205.0   67.244.46.98    255.255.255.0   U     0      0        0 eth0
0.0.0.0         53.138.73.76    0.0.0.0         UG    100    0        0 eth0

</bonus>

Google Treasure Winners announced (and I’m among them)

Wednesday, October 22nd, 2008

Google Treasure Hunt winners abound from Official Google Blog.

How did I win Google Treasure 2008? (1)

Monday, October 6th, 2008

It’s been 2 months since a nice girl at Google told me I won the Google Treasure Hunt 2008. One week ago, I got my present: a T-shirt and an engraved iPod Nano stating “Google Treasure Hunt ‘08 Winner”. I must admit I’m really surprised. I could have never imagined I had a single chance to be one of the winners. I can’t figure out how many people took part in the contest.

It’s particularly suprising given the fact that I’m not that good at maths and my prime number “skills” are scarce nowadays. It’s time now to try to explain how I managed to solve out the “games”.

The robot

A robot is located at the top-left corner of a X x Y grid (marked ‘Start’ in the diagram below).

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).

How many possible unique paths are there?

Quick facts:

  • 2×2 grid: 2 possible ways
  • 3×2 grid: 3 possible ways

So far, so good… What about a 30×40 grid?

I bet I was not the only naive guy who tried to get it by using a bruteforce 4 line Python script… OK… it took me less than a minute to realise that it wouldn’t work out (before 2040).

So…

What the heck? Let’s make use of some combinatorics.

In a 4×4 grid, the robot must move exactly 3 times to the right and 3 times downwards… So…

DDDRRR
DRDRDR

So… <hint>how many ways you can permute 3 R and 3 D in an 6 move set?</hint> I expanded that to the big grid, et voilà!

Simplicity is prerequisite for reliability.
Edsger Dijkstra