Question: Please fill in the two function to solve this problem? The Problem: Matching Group Schedules The group schedule matching problem takes two or more arrays
Please fill in the two function to solve this problem?
The Problem: Matching Group Schedules
The group schedule matching problem takes two or more arrays as input. The arrays
represent availabilities and daily working periods of group members. It outputs an array
containing intervals of time when all members are available for a meeting.
Let us assume there are at least two persons in your class project group. You want to
schedule a meeting with another group member. The members decide to provide you with
a a schedule of their daily activities, containing times of planned engagements. They are
not available to have a meeting you during these periods. b the earliest and latest times at
which they are available for meetings daily. Your schedule and availabilities are provided
too.
Write an algorithm that takes in your schedule, your daily availability earliest time, latest
time and that of your group member or members and the duration of the meeting you
want to schedule. Time is given and should be returned in military format. For example: :
: The given times output should be sorted in ascending order.
An algorithm for solving this problem involves combing the two subarrays into an array
containing a set of unavailabilities, with consideration of the daily active periods.
Here is the code:
import sys
def groupschedule persSchedule, persDailyAct, persSchedule, persDailyAct,duration :
updatedSchedule updateSchedulepersSchedule, persDailyAct
updatedSchedule updateSchedulepersSchedule, persDailyAct
mergedSchedulemergedSchedulesupdatedSchedule updatedSchedule
sortedSchedules sortedAllSchedulesmergedSchedule
print matchedAvailabilitiessortedSchedulesduration
def updateScheduleSchedule DailyAct:
updatedSchedule Schedule: #make a copy of the schedule
updatedSchedule list
updatedSchedule.insert: DailyAct #update unavailable schedules and add early morning hours
updatedSchedule.appendDailyAct: #update unavailable schedules and add after work hours
return updatedSchedule
#return listmaplambda s: convertToMinutess convertToMinutess updatedSchedule
def mergedSchedulespersSchedule, persSchedule:
merged
ij
while i lenpersSchedule and j lenpersSchedule:
meeting meetingpersSchedulei persSchedulej
if meeting meeting:
merged.appendmeeting
i
else:
merged.appendmeeting
j
while i lenpersSchedule:
merged.appendmeeting
i
while i lenpersSchedule:
merged.appendmeeting
j
return merged
def sortedAllSchedules Schedule:
allSchedules Schedule:
#Todo: write a function to arrange all schedules. New meeting starts AFTER the end of current meeting.
def matchedAvailabilitiesSchedule duration:
availabilities
#Todo: write a function to match all availabilities
def convertToMinutestime:
hours, minutes listmapint time.split:
return hours minutes
def convertMinutestoHourminutes:
hours minutes
mins minutes
toString strhours
toStringMins strmins if mins else strmins
return toString : toStringMins
def main:
persSchedule inputEnter schedule for person :
persSchedule inputEnter schedule for person :
persDailyAct inputEnter Daily Availability for pers :
persDailyAct inputEnter Daily Availability for pers :
duration inputEnter duration of the proposed meeting:
groupSchedule groupschedule persSchedule, persDailyAct, persSchedule, persDailyAct,duration
if namemain:
main
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
