Thu Aug 25 2016
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
Asana is exploring a smart-workload feature designed to streamline task assignment between coworkers. Newly created tasks will be automatically assigned to the team member with the lightest workload. For each person the following information is known:

name - their name, a string containing only uppercase and lowercase letters;
status - their vacation indicator status, which is "0" if the person is on a vacation, or "1" otherwise;
projects - the number of projects they are currently involved in;
tasks - the number of tasks assigned to the report.
If a person's vacation indicator value is set to "0", this means they are on vacation and cannot be assigned new tasks. Conversely, a vacation indicator value of "1" means they are open to receive task assignments.

Asana sorts team members according to their availability. Person A has a higher availability than person B if they have fewer tasks to do than B, or if these numbers are equal but A has fewer assigned projects than B. Put another way, we can say that person A has a higher availability than person B if their (tasks, projects) pair is less than the same pair for B.

Your task is to find the name of the person with the highest availability. It is guaranteed that there is exactly one such person.

Example

Consider information about two team members:

John, with status = "1", projects = "2" and tasks = "6", represented as ["John", "1", "2", "6"];
Martin, with status = "1", projects = "1" and tasks = "5", represented as ["Martin", "1", "1", "5"].
For this case, the output should be smartAssigning(information) = "Martin".

Here John and Martin's vacation indicators are both "1", so both of them are open to new assignments. Martin is only assigned 5 tasks while John is assigned 6, so Martin has the highest availability.

For the following employees' information:

John, with status = "1", projects = "2" and tasks = "6", represented as ["John", "1", "2", "6"];
Martin, with status = "0", projects = "1" and tasks = "5", represented as ["Martin", "0", "1", "5"];
the output should be smartAssigning(information) = "John".

In this example Martin cannot be assigned any new tasks because his vacation indicator is "0". Therefore, "John" has the highest availability.

For the following information:

John, with status = "1", projects = "1" and tasks = "6", represented as ["John", "1", "1", "6"];
Martin, with status = "1", projects = "2" and tasks = "6", represented as ["Martin", "1", "2", "6"];
the output should be smartAssigning(information) = "John".

Both John and Martin's vacation indicators are "1", and the number of tasks each of them is assigned is 6. However, John is involved in just 1 project, while Martin is involved in 2, so John has the highest availability.