Hi, I have a problem statement as mentioned below :
I have a list of tasks, which needs to be allocated to users country wise. While allocating it is to be keep in mind that for every country, there is a designated primary user. If that user is not present, then it could be allocated to any random user who is present. Also, while allocating there is a upper limit of 100, it means that not more than 100 tasks could be allocated to a single user. Also, lets suppose, if total tasks are 200 and total available users are 4, then 200/4=50 i.e. not more than 50 tasks will be allocated to single user.
Input :
| S.No. | Task | Country |
| 1 | Task 1 | A |
| 2 | Task 2 | B |
| 3 | Task 3 | A |
| 4 | Task 4 | A |
| 5 | Task 5 | C |
| 6 | Task 6 | B |
| Country | Primary User | Present |
| A | User 1 | Yes |
| B | User 2 | Yes |
| C | User 3 | Yes |
Output :
| S.No. | Task | Country | Allocation |
| 1 | Task 1 | A | User 1 |
| 2 | Task 2 | B | User 2 |
| 3 | Task 3 | A | User 1 |
| 4 | Task 4 | A | User 3 |
| 5 | Task 5 | C | User 3 |
| 6 | Task 6 | B | User 2 |
I am mainly struggling with the limit check part, which is to be done dynamically while allocating it to a certain user. As there are total 6 tasks and 3 available users, so upper limit for any user is 2. As there are 3 tasks for country A, and thus 2 tasks allocated to User 1 and 1 task allocated to User 3. How to do all these allocations dynamically?