Implementation of the shortest path algorithm for a programming challenge.