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 inputs:
A matrix of data on people in the region. Each column represents a different person.
Row is eligibility.
Row is how many doses they have received
Row is how many days it has been since their last dose. Those who haven't had any vaccine doses will have a in this row.
The number of vaccines available on a day
The function should return one output:
A xN array containing either or
represents an individual who is to receive a vaccine dose
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 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 doses.
Your function should not give vaccines to individuals who have received a vaccine dose within the last 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 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
For this example, if there were doses of the vaccine available, the output would be:
table
If there were doses of the vaccine available, the output would be:
table
In another example, if your matrix of data was:
table
And there were doses available, the output would be:
table
Please generate at least pieces of test data yourself. They can be small ie 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
