dijkstra solution for problem 18 along with library example