Problem 4 – Using Python to find most efficient route
For this problem, when learning about algorithms, we will use a common algorithm—the Travelling Salesman Problem (TSP). Let's set up the problem itself.
A salesman needs to travel to a set number of cities or locations. Let's say the salesman has 10 locations to go to. They could go to those 10 locations in a lot of different orders. Our goal with this algorithm is to create the best possible, most efficient route to hit those locations.
Note that for this particular scenario, as we will do in the next problem, we'll employ straightforward analysis by using the four elements of the computational thinking process.
Defining the problem (TSP)
This problem is a little more complex than how it appears initially. Think of it this way. If we have 10 destinations and we are calculating round-trip permutations to check the fastest routes, we're left with more than 300,000 possible permutations...