[Community Puzzle] Treasure hunt

More specifically it’s a generalisation of the Hamiltonian path problem, which is known to be NP-complete even for the grid graphs we’re dealing with here. Interestingly however, if the grid graph has no holes in it (in our case: no walls that aren’t connected to the edge of the map by other walls) then there is a polynomial time algorithm for finding Hamiltonian cycles[*]. I can’t immediately tell if it would adapt to our gold-maximising problem (ie. what exactly it outputs when there is no Hamiltonian cycle) but it looks promising. Perhaps there is a hard puzzle in this problem waiting to get out :slight_smile:

[*] C. Umans and W. Lenhart, “Hamiltonian cycles in solid grid graphs,” Proceedings 38th Annual Symposium on Foundations of Computer Science, 1997

1 Like

That’s quite interesting. Thanks for sharing. I guess it makes sense intuitively because solid graphs like you described don’t have “cycles” around group/s of walls.

Missing tags for BFS, DFS, Pathfinding