Coding Challenge 351 Traveling Salesperson
>> YOUR LINK HERE: ___ http://youtube.com/watch?v=BAejnwN4Ccw
In Part 1 of this multi-part coding challenge, I introduce the classic computer science problem of the Traveling Salesperson (TSP) and discuss the pitfalls with a brute force solution. In Part 2, I discuss Lexicographic Ordering and demonstrate one algorithm to iterate over all the permutations of an array. In Part 3, I apply this algorithm to a brute-force solution of the TSP problem. Every single route permutation is checked one by one. In Part 4, I attempt to create a solution to the TSP problem with a genetic algorithm, and then I add a “crossover” algorithm in Part 5. Code: https://thecodingtrain.com/challenges... • p5.js Web Editor Sketches: • πΉοΈ Part 1: Traveling Salesperson (TSP): https://editor.p5js.org/codingtrain/s... • πΉοΈ Part 2: Lexicographic Order: https://editor.p5js.org/codingtrain/s... • πΉοΈ Part 3: TSP with Lexicographic Order: https://editor.p5js.org/codingtrain/s... • πΉοΈ Part 4: TSP with Genetic Algorithm: https://editor.p5js.org/codingtrain/s... • πΉοΈ Part 5: TSP with Genetic Algorithm and Crossover: https://editor.p5js.org/codingtrain/s... • Other Parts of this Challenge: • πΊ Part 2: Lexicographic Order: • Coding Challenge #35.2: Lexicographic... • πΊ Part 3: TSP with Lexicographic Order: • Coding Challenge #35.3: Traveling Sal... • πΊ Part 4: TSP with Genetic Algorithm: • Coding Challenge #35.4: Traveling Sal... • πΊ Part 5: TSP with Genetic Algorithm and Crossover: • Coding Challenge #35.5: TSP with Gene... • π₯ Previous video: • Coding Challenge #34: Diffusion-Limit... • π₯ Next video: • Coding Challenge #36: Blobby! • π₯ All videos: • Coding Challenges • References: • π Traveling Salesman on Wikipedia: https://en.wikipedia.org/wiki/Travell... • π¨οΈ Permutation Algorithm Using Lexicographic Ordering: https://www.quora.com/How-would-you-e... • π Array on MDN: https://developer.mozilla.org/en/docs... • π Array.includes() on MDN: https://developer.mozilla.org/en/docs... • π Array.reverse() on MDN: https://developer.mozilla.org/en/docs... • π ES6 Sets on MDN: https://developer.mozilla.org/en/docs... • πΎ The Nature of Code Part 2: https://github.com/shiffman/NOC-S17-2... • π The Nature of Code: http://natureofcode.com/ • Videos: • π₯ Improved Pool Selection: • 9.8: Weighted Selection (for Genetic ... • π₯ Genetic Algorithm Playlist: • 9: Genetic Algorithms - The Nature of... • π΄ Live Stream Archive #57: • Live Stream #57 - Traveling Salesperson • Related Coding Challenges: • π #29 Smart Rockets in p5.js: • Coding Challenge #29: Smart Rockets i... • π #51 A* Pathfinding Algorithm: • A* Pathfinding Algorithm (Coding Chal... • π #69 Evolutionary Steering Behaviors: • Coding Challenge #69: Evolutionary St... • π #70 Nearest Neighbors Recommendation Engine: • Coding Challenge #70: Nearest Neighbo... • Timestamps: • 00:00 Welcome to this coding challenge! • 00:50 What is the Traveling Salesperson problem? • 04:50 Code! Placing random cities on the canvas • 07:30 Go through the cities in order • 08:13 Shuffling the array with swaps • 11:35 Computing the distance and saving the shortest one • 15:20 Oups! Fixing an array index error • 17:00 How to make a copy of an array? • 19:43 Storing a copy of the best cities path ever • 20:24 Drawing the best cities path ever • 21:00 The limits of this brute force algorithm • Editing by Mathieu Blanchette • Animations by Jason Heglund • Music from Epidemic Sound • π Website: http://thecodingtrain.com/ • πΎ Share Your Creation! https://thecodingtrain.com/guides/pas... • π© Suggest Topics: https://github.com/CodingTrain/Sugges... • π‘ GitHub: https://github.com/CodingTrain • π¬ Discord: / discord • π Membership: http://youtube.com/thecodingtrain/join • π Store: https://standard.tv/codingtrain • ποΈ Twitter: / thecodingtrain • πΈ Instagram: / the.coding.train • π₯ Coding Challenges: • Coding Challenges • π₯ Intro to Programming: • Start learning here! • π p5.js: https://p5js.org • π p5.js Web Editor: https://editor.p5js.org/ • π Processing: https://processing.org • π Code of Conduct: https://github.com/CodingTrain/Code-o... • This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecod... • #travelingsalesperson #permutation #lexicographicordering #natureofcode #geneticalgorithm #evolution #bruteforce #factorial #arrays #p5js
#############################
