Created
October 16, 2016 19:18
-
-
Save yawboakye/dbc50bd3a3b7251b72018e0645d2eeef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
e_o_d = 23 | |
def find_pockets_of_free_time(meeting_times): | |
day = [False] * 24 | |
available_times = [] | |
for start, finish in meeting_times: | |
if start > finish: finish = e_o_d | |
if finish == e_o_d: finish += 1 | |
day[start:finish] = [True] * len(range(start, finish)) | |
s = 0 | |
for hour, busy in enumerate(day): | |
if busy: | |
if not day[s]: | |
available_times.append((s, hour)) | |
s = hour + 1 | |
if not day[-1]: | |
available_times.append((s, e_o_d)) | |
return available_times |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment