Question: 1 . 4 . Problem 4 Let's assume that there are two service periods: Service Period 1 consists of time slots 1 7 : 3

1.4. Problem 4
Let's assume that there are two service periods:
Service Period 1 consists of time slots 17:30,17:45,18:00,18:15
Service Period 2 consiss of time slots 20:45,21:00,21:15,21:30
The purpose of this question is find out how popular a particular dining time is (within its own service period). The way we are going to go about this is to find out the "rank" of a dining time amoung all other bookings received on each day. To make the idea clear, consider dining time 17:45. If everyday the first booked reservation is for 17:45(i.e., it has rank 1), then 17:45 is quite popular. On the other hand, if 17:45 is always the last dining time booked by customers on each day, it means that it is not that popular (perhaps it was booked because all other dining times were already booked by other customers). You are going to implement this idea in the next function.
The next function takes as input res_time, which is one of the eight times above as a datetime time. Given the inputted time, you will exclusively focus this analysis on either Service Period 1 or 2. For example, if the inputted res_time is 17:45, you should only consider reservations made during Service Period 1. For each day, find the first reservation that books at res_time (datetime_booked tells you the order in which reservations were scheduled). Within the given Service Period of interest, compute how many reservations have already been booked on that day before this reservation was made for res_time. If k1 reservations have already been made, this means that res_time was the k-th reservation that was booked on that day. We will say the "rank" of reservation time res_time on that day was k. So, if res_time was the first time booked on a particular day for the relevant Service Period, its rank on that day is 1. Return the average rank of res_time across all days in which a reservation for res_time was booked.
Notice: If there are two reservation which have the same booking time, they will have the same rank. For example, in the following table, both the first and second row (counting rows from zero) share Rank 2.
reservation_datreservation_timedatetime_bookedrank9/9/1718:15:002017-08-1510:03:0019/9/1718:00:002017-08-1510:04:0029/9/1717:45:002017-08-1510:04:0029/9/1717:30:002017-08-1510:05:004

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!