unifystockx / code_compete

Coding Competition with TDD and TypeScript
MIT License
0 stars 2 forks source link

Assignment - Group people data based on their cities #8

Open krajasekhar-unify opened 3 years ago

krajasekhar-unify commented 3 years ago

Problem Statement: For the given array of people data, parse the data in to the form grouped by their cities. The output shall have count of the people,list of people for each city. (Please check sample output mentioned for reference) .

Sample Input

[
    {
      "_id": "5f322e9e0b033f228afd008a",
      "name": "Brown Lara",
      "gender": "male",
      "email": "brownlara@zolar.com",
      "phone": "+91 9411359806",
      "city": "Hyderabad"
    },
    {
      "_id": "5f322e9e90a973778cc279b2",
      "name": "Molina Barker",
      "gender": "male",
      "email": "molinabarker@zolar.com",
      "phone": "+91 8473520620",
      "city": "Bengaluru"
    },
    {
      "_id": "5f322e9ef93188370ee080e7",
      "name": "Loretta Mcintyre",
      "gender": "female",
      "email": "lorettamcintyre@zolar.com",
      "phone": "+91 1993560484",
      "city": "Hyderabad"
    },
    {
      "_id": "5f322e9e2c7c9b2c77a3ff73",
      "name": "Sherman Avila",
      "gender": "male",
      "email": "shermanavila@zolar.com",
      "phone": "+91 1825229684",
      "city": "Pune"
    },
    {
      "_id": "5f322e9e9a6b98a902c2b04d",
      "name": "Claire Molina",
      "gender": "female",
      "email": "clairemolina@zolar.com",
      "phone": "+91 3679340671",
      "city": "Bengaluru"
    }
  ]

Sample Output

[
    {
        "count": 2,
        "city": "Hyderabad",
        "people": [{"_id": "5f322e9e0b033f228afd008a", ...}, {"_id": "5f322e9ef93188370ee080e7", ...}]
    },
    {
        "count": 2,
        "city": "Bengaluru",
        "people": [{"_id": "5f322e9e90a973778cc279b2", ...}, {"_id": "5f322e9e9a6b98a902c2b04d", ...}],
    },
    {
        "count": 1,
        "city": "Pune",
        "people": [{"_id": "5f322e9e2c7c9b2c77a3ff73", ...}]
    }
  ]

Solution provided shall follow according to the guidelines.

krajasekhar-unify commented 3 years ago

Let's not close the issue until pull requests from all the assignee's get merged. Fine?