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: 9:30,
22:21. The given times (output) should be sorted in ascending order.
An algorithm for solving this problem involves combing the two sub-arrays into an array
containing a set of unavailabilities, with consideration of the daily active periods.
Here is the code:
import sys
def groupschedule (pers1Schedule, pers1DailyAct, pers2Schedule, pers2DailyAct,duration ):
updatedSchedule1= updateSchedule(pers1Schedule, pers1DailyAct)
updatedSchedule2= updateSchedule(pers2Schedule, pers2DailyAct)
mergedSchedule=mergedSchedules(updatedSchedule1, updatedSchedule2)
sortedSchedules= sortedAllSchedules(mergedSchedule)
print ( matchedAvailabilities(sortedSchedules,duration))
def updateSchedule(Schedule, DailyAct):
updatedSchedule = Schedule[:] #make a copy of the schedule
updatedSchedule =list()
updatedSchedule.insert(0,['0:00', DailyAct[0]]) #update unavailable schedules and add early morning hours
updatedSchedule.append([DailyAct[1],'23:59']) #update unavailable schedules and add after work hours
return updatedSchedule
#return list(map(lambda s: [convertToMinutes(s[0]), convertToMinutes(s[1])], updatedSchedule))
def mergedSchedules(pers1Schedule, pers2Schedule):
merged =[]
i,j =0,0
while i len(pers1Schedule) and j len(pers2Schedule):
meeting1, meeting2=pers1Schedule[i], pers2Schedule[j]
if meeting1[0]= meeting2[0]:
merged.append(meeting1)
i+=1
else:
merged.append(meeting2)
j+=1
while i len(pers1Schedule):
merged.append(meeting1)
i+=1
while i len(pers2Schedule):
merged.append(meeting2)
j+=1
return merged
def sortedAllSchedules (Schedule):
allSchedules =[Schedule[0][:]]
********#Todo: write a function to arrange all schedules. New meeting starts AFTER the end of current meeting.******
def matchedAvailabilities(Schedule, duration):
availabilities=[]
********#Todo: write a function to match all availabilities********
def convertToMinutes(time):
hours, minutes = list(map(int, time.split(":")))
return hours *60+ minutes
def convertMinutestoHour(minutes):
hours = minutes //60
mins = minutes%60
toString = str(hours)
toStringMins ="0"+ str(mins) if mins10 else str(mins)
return toString +":"+ toStringMins
def main():
pers1Schedule = input("Enter schedule for person 1:")
pers2Schedule = input("Enter schedule for person 2:")
pers1DailyAct = input("Enter Daily Availability for pers 1: ")
pers2DailyAct = input("Enter Daily Availability for pers 2: ")
duration = input("Enter duration of the proposed meeting: ")
groupSchedule1= groupschedule (pers1Schedule, pers1DailyAct, pers2Schedule, pers2DailyAct,duration )
if __name__=="__main__":
main()
Please fill in the two function to solve this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!