Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I would like to design an API / That solves the following Problem.

Given a two-dimensional matrix, each of the entries represents a person:
1 0 1
0 0 0
0 1 0
If the entry is 1, we consider the represented person to be sick and we recognize this person as a patient. If two patients are adjacent to each

other in any direction (vertical, horizontal and oblique), we consider them part of the same patient group. For example, the following matrix
contains 4 patient groups:
1 1 0 0 0 0
0 1 0 0 0 0
1 0 1 0 0 0
0 0 0 0 1 0
0 0 0 0 0 1
1 1 0 1 0 0

Your API will receive a request like the following:
POST /api/patient-groups/calculate HTTP/1.1
Host: {url}:{port}
Content-Length: {content_length}
content-type: application/json
Accept: *
{
"matrix" : [
[1, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[1, 0, 1, 0, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1],
[1, 1, 0, 1, 0, 0]
]
}
And return a response body like this:
{
"numberOfGroups": 4
}

Here is another example:
{
"matrix" : [
[1, 0, 1, 1, 1],
[1, 0, 0, 0, 0],
[1, 0, 0, 0, 1],
[0, 0, 1, 0, 0],
[0, 1, 0, 0, 0],
[0, 1, 0, 0, 1]
]
}
And the response body should be:
{
"numberOfGroups": 5
}

What I have tried:

I am trying to develop this thing Using .NET Core services libraries. need to HOST using HTTP protocol, and Creating client for sending request. with 1.) Code Maintainability 2) Memory Usage 3) Time Complexity 4) Testability.

Any One Suggest Which approach is better with which programming language and on which environment.

Thanks in Advance.
With Regards.
Neel.
Posted
Updated 9-Jun-21 22:19pm

1 solution

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 
Comments
meetnneel 10-Jun-21 5:12am    
Thanks for your valuable comments, and your concern for helping nature. that you do have.

Thank you.
Neel.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900