Skip to content

Instantly share code, notes, and snippets.

@lurecas
Last active August 31, 2015 06:41
Show Gist options
  • Save lurecas/49092e67f9a65eb99653 to your computer and use it in GitHub Desktop.
Save lurecas/49092e67f9a65eb99653 to your computer and use it in GitHub Desktop.

Cabify Mobile Challenge

Background

Cabify provides transportation services in Latin America and Spain. The operations team have decide they'd like to test out some new prices using an optimal route calculated with OSRM between the start and end points. They've decided on the following rates:

Country Price per km Price per min Currency
Spain (ES) 1.50€ 0.50€ EUR
Mexico (MX) 14$ 2.50$ MXN
Peru (PE) S./2.50 S./0.50 PEN

The Task

The following JSON contains an array of journeys generated over the last few weeks. Using the data provided, the public OSRM API, the sample rates, and the special discount conditions, add the following attributes to each journey:

  • distance - the optimum meters travelled.
  • duration - the optimum number of seconds the journey would have lasted.
  • currency - the currency the user should be billed in.
  • price - how much the journey cost.
  • discount - how much discount should be applied.
  • total_price - the price minus any discounts

The app will have some user interface structure, so the user can navigate through all the content easily:

  • country selector - this is the first screen of the app, where the user will choose one of the available countries.
  • journey list - this list will show a summary of each journey that belongs to the selected country.
  • journey detail - this screen will show all the details of a journey, including a map with markers for start and end location
[
   {
       "id": "1",
       "region": "ES",
       "user_id": "1",
       "start_loc": [
           40.4680577,
           -3.68662464
       ],
       "end_loc": [
           40.4693121,
           -3.57150993
       ],
       "created_at": "2015-04-28T23:55:23Z"
   },
   {
       "id": "2",
       "region": "ES",
       "user_id": "1",
       "start_loc": [
           40.42781612,
           -3.69053515
       ],
       "end_loc": [
           40.45273632,
           -3.70322515
       ],
       "created_at": "2015-04-30T23:55:23Z"
   },
   {
       "id": "3",
       "region": "ES",
       "user_id": "14",
       "start_loc": [
           40.4542094,
           -3.6812724999999773
       ],
       "end_loc": [
           40.4921,
           -3.5935399999999618
       ],
       "created_at": "2015-05-02T06:55:23Z"
   },
   {
       "id": "4",
       "region": "ES",
       "user_id": "1",
       "start_loc": [
           40.408851,
           -3.692484000000036
       ],
       "end_loc": [
           40.50638500000001,
           -3.6719112000000678
       ],
       "time": "2015-05-02T13:55:23Z"
   },
   {
       "id": "5",
       "region": "ES",
       "user_id": "14",
       "start_loc": [
           40.46645561017568,
           -3.689838834106922
       ],
       "end_loc": [
           40.411141,
           -3.69356
       ],
       "created_at": "2015-05-05T05:50:00Z"
   },
   {
       "id": "6",
       "region": "MX",
       "user_id": "14",
       "start_loc": [
           19.40531158447266,
           -99.17715454101562
       ],
       "end_loc": [
           19.49521636962891,
           -99.119587
       ],
       "created_at": "2015-05-05T16:30:11Z"
   },
   {
       "id": "7",
       "region": "MX",
       "user_id": "14",
       "start_loc": [
           19.44203186035156,
           -99.20143034309149
       ],
       "end_loc": [
           19.43360137939453,
           -99.0709228515625
       ],
       "created_at": "2015-05-05T18:45:00Z"
   },
   {
       "id": "8",
       "region": "MX",
       "user_id": "14",
       "start_loc": [
           19.39804091534896,
           -99.1644262522459
       ],
       "end_loc": [
           19.42952488,
           -99.17952076
       ],
       "created_at": "2015-05-05T20:53:19Z"
   },
   {
       "id": "9",
       "region": "PE",
       "user_id": "16",
       "start_loc": [
           -12.024053,
           -77.11203599999999
       ],
       "end_loc": [
           -12.0970329,
           -77.03390790000003
       ],
       "created_at": "2015-05-06T16:05:20Z"
   },
   {
       "id": "10",
       "region": "ES",
       "user_id": "121",
       "start_loc": [
           40.43969425642679,
           -3.8107149297015472
       ],
       "end_loc": [
           40.4907123187136,
           -3.593661562633359
       ],
       "created_at": "2015-05-10T10:00:00Z"
   },
   {
       "id": "11",
       "region": "ES",
       "user_id": "23",
       "start_loc": [
           40.43862915039062,
           -3.717599868774414
       ],
       "end_loc": [
           40.43637084960938,
           -3.685964584350586
       ],
       "created_at": "2015-05-15T18:15:19Z"
   }
]

Bonus tasks

We want you to feel free to add whatever feature you think fits on the purpose of the challenge. Here we give you a few ones:

  • As the Marketing people love giving away money, we can imagine a campaign where we offer a 3-for-2 journey. So for example, if the user makes 3 journeys in one day (UTC), the third journey will be free.
  • The user should be able to check the route that OSRM recommends us to take. This way the user can see a drawn route on the map on the journey's detail view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment