Skip to content

Instantly share code, notes, and snippets.

@yawboakye
Created October 16, 2016 19:18
Show Gist options
  • Save yawboakye/dbc50bd3a3b7251b72018e0645d2eeef to your computer and use it in GitHub Desktop.
Save yawboakye/dbc50bd3a3b7251b72018e0645d2eeef to your computer and use it in GitHub Desktop.
#!/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