Last active
October 12, 2018 21:25
-
-
Save hughdbrown/964c984c19a2b81f88a30bf4c511e772 to your computer and use it in GitHub Desktop.
Try to find a meeting time that works for our team
This file contains hidden or 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
tzs = [ | |
("GMT", 0), | |
("Boston", -4), | |
("Denver", -6), | |
("Singapore", +8), | |
("Kyiv", +3), | |
] | |
def time_in(city, offset): | |
return city, [(offset + i + 24) % 24 for i in range(24)] | |
good_times = {} | |
for city, offset in tzs: | |
city, times = time_in(city, offset) | |
offsets = [i for i, t in enumerate(times) if 6 <= t <= 20] | |
good_times[city] = offsets | |
print("{0:12} {1}".format(city, " ".join("{0:02d}".format(t) for t in times))) | |
print(sorted(reduce( | |
lambda a, b: set(a).intersection(set(b)), | |
good_times.values(), | |
set(range(24)) | |
))) | |
from collections import Counter | |
c = Counter( | |
i | |
for good_time in good_times.values() | |
for i in good_time | |
) | |
print(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment