The Oxford Green Belt Way problem
Here is a problem for you to test your programming skills.
The Oxford Green Belt Way is a 50-mile circular walk around the city. It goes through the beautiful countryside, quiet fields and friendly villages.
The group of international studens on their trip to Oxford wanted to walk entire path in one day. Each student walked through part of the path and at the end of the day they collected their GPS tracks. Now they want to check whether they achieved their goal.
Write a program that analyses the tracks and tells whether the merged GPS tracks form a closed path or not. Tracks can be merged only if one ends where another starts with precision \(10^{-6}\).
Input begins with the number of tracks (not more than 100). Each track begins with a number of points (not more than 10,000). Each point is a pair of floating point numbers, latitude and longitude (all around 51.751944, -1.257778).
If points from merged tracks form a closed path the output should be either "true" (or path lenth calculated with Haversine formula if you are good with spherical geometry). If they don't, the expected output is "false".
Sample input:
2
2
51.751944 -1.257778
51.751934 -1.257798
2
51.751934 -1.257798
51.751944 -1.257778
Sample output:
true
The sample input contains two tracks, first ends where second starts and seconds ends where the first starts. The path is closed so the answer is "true".
If your solution is in F#, C#, JavaScript, or Go want, you can post it solution in comments and I will check whether it is correct or not.