Difficulty: 90 The problem is clearly an instance of the Travelling Salesman Problem, with the difference that we only need to check if a given length is possible, instead of finding the minimum. The solution is a meet-in-the-middle approach: search for paths using half of the points, and store pairs of (set of used nodes, length) of in a set. Then do this a second time but then search in the set if a pair exists for exactly the rest of the nodes and the remaining target length. To avoid bookeeping about start/end of the paths, you can always start at a given node and loop over a midpoint.