display | more...
This is a solution to problem 21 on the hard interview questions node. If you have not read the question, the following will make no sense to you:

Planes 1 and 2 take off eastbound, and travel a quarter of the way around the world. At this point, both their tanks are half empty, so 2 transfers all of its fuel to plane 1 and lands. Now plane 1 has a full tank.

Once plane 1 is halfway around the world, plane 3 takes off westbound and meets plane 1 when plane 1 is three quarters of the way around the world. At this point, plane 1's tank is empty and plane 3's is half empty. Plane 3 then transfers all its fuel to plane 1, who is thus able to finish the last quarter of the journey.

The solution, for those of us who are slightly more civic minded than jliszka and don't want to crash any airplanes into the ocean, is a bit more complex. For convenience, I will assume that the total flight takes 24 hours.

  • 0:00 - Planes 1, 2, and 3 depart, each with full tanks, heading west.
  • 3:00 - All three airplanes 1/8 of the way around the world and at 3/4 tank. Airplane 3 tops off planes 1 & 2 and heads back to base.
  • 6:00 - Plane 3 reaches base, refuels. Planes 1 & 2 both 1/4 of the way around the world and at 3/4 tank. Plane 2 transfers 1/4 tank to 1 and heads home. 1 continues.
  • 12:00 - Plane 1 at halfway mark and 1/2 tank. Planes 2 & 3 launch with full tanks heading east.
  • 16:00 - Plane 1 at 2/3 distance mark. Planes 2 & 3 at 5/6 point, each with 2/3 tank. Plane 3 transfers 1/3 tank to 2 and heads back to base. 2 continues.
  • 18:00 - Planes 1 & 2 at 3/4 point. 1 is empty and 2 has 5/6 tank. Plane 2 transfers 5/12 tank to plane 1. Both head towards base.
  • 20:00 - Plane 3 arrives at base, refuels, launches west. 1 & 2 at 5/6 point.
  • 22:00 - All planes meet at 11/12 point. 1 & 2 have 1/12 tank. 3 has 5/6 tank. All three planes share equally, ending with 1/3 tank each. All fly home.
  • 24:00 - All planes arrive to victorious ticker-tape parade with 1/6 tank of fuel to spare, and nobody had to make an emergency landing in Bhutan.
  • There is a second solution that avoids the nasty thirds, but it has all three planes coasting in on empty, which I'll avoid if I can help it ;)

    Because of the carbon footprint of Jaggar's solution (total fuel consumption in his scheme is 3 + 1 + 2 + whatever, I refuse to do the fractions...), I think a solution with less fuel is preferable. Thanks to my colleague Nick D:

    Planes A, B and C take off west.
    After 1/4 tank has been spent, C dumps 1/4 tank in each of A & B and returns on the remaining 1/4.
    After another 1/4 tank A and B have each 3/4 left. B dumps 1/4 in A and returns on the remaining 1/2.
    After A has spent another 1/2 tank, he is half-empty on the half-way point of the trip. B refuels and takes off east.
    When A is empty, B still has 1/2 tank left which he shares with A. C takes off east with full tank.
    When A & B are empty, they just meet C who has 3/4 tank full and they are 1/4 tank away from home. C shares with them and they just make it home.

    Empty tanks but total fuel consumption of a mere 5 tanks full.

    Log in or register to write something here or to contact authors.