Jan Van den Bergh's solution:

Source code not yet available. Algorithm used: shortest path algorithm. Biggest problem: fit everything into memory.