Question: Write a function that takes 2 inputs: A 3 x N matrix of data on people in the region. Each column represents a different person.

Write a function that takes 2 inputs:
A 3xN matrix of data on people in the region. Each column represents a different person.
Row 1 is eligibility.
Row 2 is how many doses they have received
Row 3 is how many days it has been since their last dose. Those who haven't had any vaccine doses will have a -1 in this row.
The number of vaccines available on a day
The function should return one output:
A 1 xN array containing either 1 or 0.
1 represents an individual who is to receive a vaccine dose
0 represents an individual who will not receive a vaccine dose
Column indices in your input matrix and output array represent the same individuals.
The number of 1's in your output array should always be equal to the number of vaccines available that day.
Your function should prioritize lower phase numbers for receiving a vaccine.
Your function should prioritize first doses over second doses for people in the same phase.
You function should only give vaccines to individuals who have received fewer than 2 doses.
Your function should not give vaccines to individuals who have received a vaccine dose within the last 21 days.
If two people are at the same phase, have the same number of doses, and are able to receive a vaccine today, but there is only 1 dose left for that day, give the vaccine to the person with the lower column index.
Hints:
Priorities: Loops and counting variables can be just as important as conditional statements for implementing priority. You can use loop counting variables to track phase number, for instance.
Remember that your input and output share a column index.
Testing Your Code: Examples
Here is an example matrix of data:
\table[[1,5,3,2,4,4,2,2,3,5],[2,1,1,2,0,1,1,1,0,0],[30,22,23,25,-1,30,18,25,-1,-1]]
For this example, if there were 2 doses of the vaccine available, the output would be:
\table[[0,0,0,0,0,0,0,1,1,0]]
If there were 4 doses of the vaccine available, the output would be:
\table[[0,0,1,0,1,0,0,1,1,0]]
In another example, if your matrix of data was:
\table[[4,3,2,1,5,3,2,1],[0,0,0,1,0,0,1,0],[-1,-1,-1,18,-1,-1,10,-1]]
And there were 5 doses available, the output would be:
\table[[1,1,0,0,1,0,1]]
Please generate at least 2 pieces of test data yourself. They can be small (i.e. the sizes of these examples) and determine what the correct output would be in order to further test your function.
When generating test cases, try to test as many rules as possible with each test case.
Write a function that takes 2 inputs: A 3 x N

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!