Link to home
Start Free TrialLog in
Avatar of Philippe Renaud
Philippe RenaudFlag for Canada

asked on

Vb.NET algorithm Challenge

Hello EE!

I need hlep to create a little algorithm that would help to determine next location of a car.

Let's say I have Car 1 and Car 2.

If Car 1 Car and Car 2 leaves from point A and Car 1 goes to address 123 VB Street and Car 2 goes to 456 Csharp Road,

If there is one more address to go, I need a way to know wich car should go (less distance)
and it goes like this... if there were 2 more address... need to check again etc....

same thing for more cars... (lets start with 2 maybe...)


Can you help me??
Avatar of Cluskitt
Cluskitt
Flag of Portugal image

I assume you want an algorithm in pseudo language? Should be something like:

For Each Address
  Distance = 999999999999
  CarToGo = 0
  For Each Car
    If Car.DistanceToAddress < Distance Then
      CarToGo = Car
    End If
  Loop
  SendCar(CarToGo)
Loop

This should work for however many addresses and cars you wish.
Avatar of Philippe Renaud

ASKER

Well actually I am not sure how to detect address locations (lays say read google map maybe??) and by code detect distance from there etc... ?
You would have to connect to the Google Maps API (check this page, for instance: http://www.phpclasses.org/package/3827-PHP-Get-coordinates-of-an-address-using-Google-Maps.html) and retrieve the coordinates for each address. Then you would have to calculate the distance between them. For that you would need to find out the distance between one point and another. After that, it's simply a question of triangulating to find out the real distance (in a straight line, anyway).
Sounds interesting...
Only little problem is im not that great in .net, any possibility we can add some code (not pseudo) to the answer ? maybe you dont have time tho
ASKER CERTIFIED SOLUTION
Avatar of Cluskitt
Cluskitt
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial