Skip to content

Instantly share code, notes, and snippets.

@hughdbrown
Last active October 12, 2018 21:25
Show Gist options
  • Save hughdbrown/964c984c19a2b81f88a30bf4c511e772 to your computer and use it in GitHub Desktop.
Save hughdbrown/964c984c19a2b81f88a30bf4c511e772 to your computer and use it in GitHub Desktop.
Try to find a meeting time that works for our team
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