Pool Matching

Start Timer

0:00:00

Upvote
0
Downvote
Save question
Mark as completed
View comments (6)

Create a function called pool_matching(candidates: list[Candidate]) which accepts a list of candidates and matches pairs of them together based on:

  1. Scheduled availability
  2. Similar interests

Return a list of Itineraries containing the details of the match. Candidates are defined by a class Candidate with the following attributes:

class Candidate:
    def __init__(self, 
                 name: str, 
                 availability: list[datetime], 
                 interests: list[str]):
        self.name = name
        self.availability = availability
        self.interests = interests

On the other hand, itineraries are defined by the following attributes:

class Itinerary:
    def __init__(self, 
                 candidates: list[Candidate], 
		 dates: list[datetime],
		 common_interests: list[str]):
        self.candidates = candidates
        self.dates = dates
        self.common_interests = common_interests

Example:

candidates = []
bob = Candidate(
    "Bob",
    [datetime(2024, 1, 10), datetime(2024, 1, 11)],
    ["rock climbing", "tech", "data science"],
)
joe = Candidate(
    "Joe",
    [datetime(2024, 1, 10), datetime(2024, 4, 9)],
    ["rock climbing", "swimming", "data science"],
)
carolyn = Candidate(
    "Carolyn", 
    [datetime(2024, 1, 11), datetime(2021, 1, 12)], 
    ["data science"]
)
dan = Candidate(
    "Dan", 
    [datetime(2024, 1, 12)], 
    ["rock climbing"]
)

candidates.append(bob)
candidates.append(joe)
candidates.append(carolyn)
candidates.append(dan)
pool_matching(candidates)

Output:

| candidates         | dates          | common_interests                  |
|--------------------|----------------|-----------------------------------|
| ["Bob", "Joe"]     | ["2024-01-10"] | ["rock climbing", "data science"] |
| ["Bob", "Carolyn"] | ["2024-01-11"] | ["data science"]                  |

Note: An itinerary should be created for each unique pair of individuals. If a person (for example, ‘A’) is scheduled to meet with multiple people (such as ‘B’ and ‘C’) on the same day, separate itineraries should be generated: one for the pairing of ‘A’ and ‘B’, and another for ‘A’ and ‘C’.

.
.
.
.
.


Comments

Loading comments