Problem 4 – using Python to find the most efficient route
For this problem, when learning about algorithms, we will use a common algorithm – the traveling 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 and 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 it appears initially. Think of it this way – if we have 10 destinations and we calculate round-trip permutations to check the fastest routes, we’re left with more than 300,000 possible...