Skip to content

Instantly share code, notes, and snippets.

@d-fal
Last active January 2, 2022 10:12
Show Gist options
  • Save d-fal/1a193a8c876bc7235bcc2524103461d3 to your computer and use it in GitHub Desktop.
Save d-fal/1a193a8c876bc7235bcc2524103461d3 to your computer and use it in GitHub Desktop.
Geographic proximity

We have a constellation of cities on a given map. The cities are distributed as below :

c1 --<2km>--- c2 -----<3km>---- c3 ------<2km>----- c4
|                                |                       
<1km>                           <2km>                        
|                                |
c5---<1km>--- c6 -----<2km>---- c7 ------<2km>----- c8----<5km>---c9
              |                 |
             <3km>             <9km>
              |                 |
c10---<4km>---c10-----<1km>----c11
          N
        W   E
          S

"<x km>" means the path is two-way, and distance is x km.

A: We have a cargo of fruits that should be distributed in all the cities above, what would be the best path in which the cargo would be delivered in the minimum amount of time. (hint: the shorter the journey path, the faster cargo delivers).

B: Now imagine the cargo contains some pills that should be delivered to some patients in each city. The number of patients in each city is as below: {c1: 78, c2: 102, c3: 234, c4:2 , c5: 133, c6: 1, c7: 0, c8: 212, c9: 100, c10: 94, c11: 120}

We have 600 pills and one hour to deliver the pills to the patients. We want to save lives as much as possible. The cargo speed is 12km/h

Write a program for each part and find the proper answers. Then, push the code to your github repo and email the repo address.

@d-fal
Copy link
Author

d-fal commented Jan 2, 2022

Note: the selected language would be any of the followings : (golang, python, php, c++)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment