Archive for the ‘Google Code Jam’ category

Get to Work – March 2010

April 26th, 2010

Google Code Jam – Get to Work

The problem:
For anyone looking at this problem, here’s something that you should know about this problem. Although it’s not explicitly stated that I saw, the sample data implies that if an employee is in the office hometown, that person does not need to commute via a vehicle and can be excluded.

Other than that, it’s relatively simple. Create a list of employees with their hometown and commuter capacity, then just iterate through that list (sorted by commuter capacity) for each hometown. You should be able to either determine that minimum number of cars needed or that it’s impossible relatively quickly.
» Read more: Get to Work – March 2010

Odd Man Out – March 2010

April 25th, 2010

Google Code Jam – Odd Man Out

The problem:
This problem is pretty easy. Basically, we have N number of integers with one of them being unique. It’s easy enough to simply search through a list of the provided integers until you run across one that has only 1 match in the list – that’s your answer.

And yes, I know I can break the loop after I’ve found the lone integer – since this is so quick running and it’s nothing important, I didn’t bother going back to fix that.
» Read more: Odd Man Out – March 2010

Alien Numbers – April 2008

February 13th, 2010

Google Code Jam – Alien Numbers

The problem:
This problem is basically asking us to do conversions from base-X to base-Y. To do that, we’re going to do 2 conversions: one from base-X to base-10, then one from base-10 to base Y.

The conversion for base-10 is pretty simple. If we have a number in base-3 such as 201, then that can be represented in base-10 by the following: (2 * 3^2) + (0 * 3^1) + (1 * 3^0) = 19.

To convert to base-Y, we’re going to use the following method (using base-5 for our conversion and 19 (base-10) as our example).
19 / 5 = 3 R 4
3 / 5 = 0 R 3

We then take those remainders and write them down in reverse, so 19 (base-10) = 34 (base 5). Converting the numbers to the “Alien” numbers is a simple process of matching up the digits with their corresponding index in the given alien numbers.

» Read more: Alien Numbers – April 2008