Challenge (07/10/2020)

We post one challenging problem here every week. Solution due is 11:59 PM every Friday. We offer awards to two responders. 1. The first one with the right solution. 2. The correct solution with fewest code statements.

If we get only one correct solution, we will skip the award for the fewest code statements.

You need to create an account in this club in order to participate in this competition. The solution can use one of these three languages: Java, Python, JavaScript. You can submit your solution to this topic. Make sure your name and email account are in the end of the solution.

If you want that we indent your code correctly, please submit your code to this challenge along with a screenshot of your code in your IDE or your code file as an attachment. Remember you still need to submit your code as text here. Thanks for your participation.

Problem: Tom decides to visit his friends who work in different cities in U.S. He can choose how many friends he wants to visit. Once he decides on that, he will get a list of distances from one city to all other cities he has chosen. Can you help Tom write an application to find out the shortest distance he will travel yet he can visit all those chosen friends (no coming back to the same cites except coming back to Tom’s home). Please print out the order of the cities he will visit in order to get the shortest distance. And also print out the total distance that he will travel when he gets back home. Let’s say if he chooses to see 5 cities, the first input value will be 5. You then get 5 lists with 5 distance values which are the distance from that city to other cities and to Tom’s home. Make sure the distance between two cities will not conflict to each other when they appear in two different lists.

Leave a Reply