Press space to switch between algorithms used. Blue = current permutation Red = solution permutation (sorry if it looks incorrect, the path is supposed to wrap back to the start but i got lazy)
@turkey3 started this and by inspecting his code I figured out what he was doing: https://en.wikipedia.org/wiki/P_versus_NP_problem So here's a step further to the problem with implementations for Dijkstra pathfinding and lexicographic permutation. Since there is no point to use Scratch for the super intense NP-hard problems, I've decided to slow things down to show you how it works, and why it is an important problem in computer science to cut down the time complexity. Please take note that even though the Dijkstra pathfinding takes barely any time to solve, it generally does not yield the true shortest path. Here is the Wikipedia article on TSP for those who are interested: https://en.wikipedia.org/wiki/Travelling_salesman_problem Wikipedia article for permutation: https://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order