Homework problem (for a 5th grader!) using Dijkstra's algorithm