Scenario in PHP

This is a common PHP test scenario (below). Does anyone seen a solution for this scenario? I've seen this in the past, but can't find it anymore.. Any help would be nice

Code:

"This summer you plan to go traveling around the world. You are lucky to have 32 friends
around the globe who will host and help you. Given a list of your
friends' GPS locations, write a script that will help you find the shortest path to visit all 32 of
your friends 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 begging or end of the file
The list will being in "Beijing", you must begin your route there
The schema for this file is as follows:
<city name> \t <latitude> \t <longitude> \n
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 1 PHP file called "solve.php"
Begin and end this file with the standard <?php ?> tags
The file must use Unix line endings
You will have access to all the standard PHP functions available in version 5.2.12
The max memory your script can use is 128 megabytes
The maximum execution time is 5 minutes
Output
Your script's final (and only) output will be using the standard "print()" 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 delimeter
(\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:
<city name> \n
Example output print:
Beijing
Vladivostok
Dakar
Singapore

Note that adblockers might block our captcha, and other functionality on BHW so if you don't see the captcha or see reduced functionality please disable adblockers to ensure full functionality, note we only allow relevant management verified ads on BHW.