Input - (“mon 10:00 am”, mon 11:00 am) Output - [11005, 11010, 11015…11100] Output starts with 1 if the day is monday, 2 if tuesday and so on till 7 for sunday Append 5 min interval times to that till the end time So here it is 10:05 as first case, so its written as 11005 2nd is 10:10 so its written as 11010
defget_intervals(self, start, end) -> List: start_time = Time(start) end_time = Time(end) if start_time.min % 5 > 0: start_time.add(5 - start_time.min % 5) end_time.add(1) res = [] while start_time < end_time: res.append(start_time.get_numeric()) start_time.add(5) return res
classTime:
def__init__(self, time): parts = time.split(' ') day = DAY_DICT[parts[0]] time_parts = parts[1].split(':') hour = int(time_parts[0]) % 12 + (0if parts[2] == 'am'else12) # remember paren (0 ...12), and % 12 self.day = day self.hour = hour self.min = int(time_parts[1])
def__lt__(self, other): if self.day < other.day or (self.day == other.day and self.hour < other.hour) or \ (self.day == other.day and self.hour == other.hour and self.min < other.min): returnTrue else: returnFalse