Skip to content

quang4dev/Traveler-Man

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Scenario

"You are a successful salesman working for a big company. You have 32 big accounts around the globe to visit on a periodic basis, and you have been assigned the project of saving money on your already dilated travel expense allowance. Given a list of your companies GPS locations, write a script that will help you find the shortest path to visit all 32 places once." Input file specifications

The input file will contain a listing of cities and coordinates in a tab-delimited file. The filename is named exactly "cities.txt". Your script will assume this file is located on the same directory where the script is executed. There are no additional spaces or lines at the beginning or end of the file. The list will being in "Beijing", you must begin your route there

An example input file:

Beijing 39.93 116.40

Vladivostok 43.8 131.54

Dakar 14.40 -17.28

Singapore 1.14 103.55(...)

Script and Runtime Specifications You must submit exactly file called "solve.php" in a git repository. The maximum execution time is 15 minutes. Output Your script's final (and only) output will be using any standard output function.

Do not attempt to write to disk, only print to screen. The output must consist of a list of the 32 original cities provided in the input file "cities.txt". These 32 cities should be ordered in the exact order in which you will visit your friends. There must be only one city name (exact spelling) per line followed by a newline delimiter (\n).

You will be judged on the total distance covered in your travels, the shorter the better. You cannot visit a city twice, and you must visit all cities The schema for your output print should be: Beijing\n Vladivostok\n Dakar\n Singapore (...)

List of cities (cities.txt)

Beijing 39.93 116.40 Tokyo 35.40 139.45 Vladivostok 43.8 131.54 Dakar 14.40 -17.28 Singapore 1.14 103.55 San Francisco 37.47 -122.26 Auckland -36.52 174.45 London 51.32 -0.5 Reykjavík 64.4 -21.58 Paris 48.86 2.34 Prague 50.5 14.26 New York 40.47 -73.58 New Delhi 28.60 77.22 Rio -22.57 -43.12 Mexico City 19.26 -99.7 Lima -12 -77.2 Moscow 55.45 37.36 Cairo 30.2 31.21 Toronto 43.40 -79.24 Santiago -12.56 -38.27 Caracas 10.28 -67.2 San Jose 9.55 -84.02 Lusaka -15.25 28.16 Casablanca 33.35 -7.39 Astana 51.10 71.30 Bangkok 13.45 100.30 Perth -31.57 115.52 Melbourne -37.47 144.58 Vancouver 49.16 -123.07 Anchorage 61.17 -150.02 Accra 5.35 -0.06 Jerusalem 31.78 35.22

About

Traveling Saleman In PHP

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages