]> Skullheadx's Git Forge - The-Traveling-Salesman-Problem.git/commitdiff
brute force desc
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Tue, 27 Dec 2022 04:56:50 +0000 (23:56 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Tue, 27 Dec 2022 04:56:50 +0000 (23:56 -0500)
.gitignore
README.md

index 5159ca085cb09e561ad091a76f738e001d54b3ca..883019e4bb7443dfe7fe724c3cbc5f5935472047 100644 (file)
@@ -3,3 +3,4 @@
 /workspace.xml
 .idea/
 __pycache__/
+*.txt
index 357d91711a90d4af86382a7e5a002dbdcb27f526..61b3c6bb8364a2ee823dec3b503f5c1b169b332a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -4,8 +4,9 @@ My solutions to the Traveling Salesman Problem (TSP) inspired by video presented
 (https://youtu.be/GiDsjIBOVoA)
 
 --------------------------------------------------------------------------------------------------------------
-TSP Problem Definition
-If a salesman starts at a town and wants to travel to every other town only once, what is the shortest path he should take?
+**TSP Problem Definition**
+
+_If a salesman starts at a town and wants to travel to every other town only once, what is the shortest path he should take such that he ends up in the town he started in?_
 
 Assuming that:
 1. Each town is connected by a direct edge
@@ -13,3 +14,6 @@ Assuming that:
 3. The direct path to a town is always the shortest, i.e. going directly from town A to town C is faster than going from town A to town B and then town C
 
 --------------------------------------------------------------------------------------------------------------
+**Method 1: Brute Force**
+
+By checking every single possibility and calculating the distance of each route, the shortest path can be determined. However, this strategy does not work for a large number of towns because as **n**, the number of towns, increases, on the first turn, (starting at any town) there are n-1 towns to choose from, then on the second turn there are n-2 choices and so on until there is only one option left which is to return to the starting town. This means that there are `(n - 1)! / 2` total possibilities accounting for duplicates.