problem 60 as a graph, still might be more efficient