Knight's Tour in Python - Getting Path from Predecessors
问题 I'm trying to adapt a Depth-First Search algorithm in Python to solve the Knight's Tour puzzle. I think I've nearly succeeded, by producing a dictionary of predecessors for all the visited squares. However, I'm stuck on how to find the autual path for the Knight. Currently, using the current return value from tour() in path() gives a disappointing path of [(0, 0), (2, 1)] . I think the crux of the issue is determining at what point inside tour() all squares are visited and at that point