Archive for the ‘Google Code Jam’ Category

Google Code Jam

August 28, 2008

I enjoy solvingĀ  Google Code Jam so here is the round 2 Problem:

Near the planet Mars, in a faraway galaxy similar to our own, there is a fight to the death between the imperial forces and the rebels. The rebel army has N ships which we will consider as points (xi, yi, zi). Each ship has a receiver with power pi. The rebel army needs to be able to send messages from the central cruiser to all the ships, but they are tight on finances, so they cannot afford a strong transmitter.

If the cruiser is placed at (x, y, z), and one of the other ships is at (xi, yi, zi) and has a receiver of power pi, then the power of the cruiser’s transmitter needs to be at least:

(|xi – x| + |yi – y| + |zi – z|) / pi
Your task is to find the position for the cruiser that minimizes the power required for its transmitter, and to output that power.