I have an app that allow students to book a private lecture with a teacher. Each teacher can specify:
- time period that he is available, for example from 4pm to 8pm and from 9pm to 11pm (so there might be many periods within the same day)
- booking length for example teacher might allow 60 minutes and 90 minutes bookings
- break length - might be zero on non zero, for exmaple 15 minutes break between lectures
Now my goal is to create a grid of times that user can pick in a way that maximizes the total teacher bookings count, i.e. minimize the unused time from the time period given by the teacher. So I would prevent user from booking a meeting at 4:30pm because teacher "lose" the time from 4pm to 4:30pm. Any ideas and suggestions how to write this kind of algorithm?
EDIT
Here are some additional details. The goal for teacher is to have as much bookings as possible (i.e. earn as much as possible) within defined time periods. When one student book a date, from example 5pm to 6pm, this date of course became unavailable for other students. The thing here is to define an algorithm that returns a set of date at which student can book a meeting and which maximize teacher bookings length during the defined time period. So if teacher said "I'm available from 4pm to 8pm, I don't need a break between meetings and I offer only 60 minutes meetings", the algorithm should return dates "4pm, 5pm, 6pm, 7pm " thanks to which teacher will use his entire availability. If the algorithm would return "4:30pm" and some student book it, then there would be left only 2 valid slots which is not acceptable. If teacher decide to have "10 minute break between meetings" then of course only 3 meetings are possible to do and hence student have a little bit more dates to choose because for example do not have to take place at 4pm but it might be at 4:10pm and still there might be 3 bookings within time period.
My current idea is to first divide the time period from 4pm to 8pm (in that example) into slots of 5 minute length each, then count how much minutes can we fill with bookings taking into account deifned break length and meeting lengths and then for each slot check "if we allow book at that slot (and for defined meeting length chosen by user), are we still able to use other slots to obtain the calculated maximum bookings minutes length"?