Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Broken Clock by Moff
from datetime import datetime, timedelta
from re import match
def broken_clock(t1, t2, er):
s1, s2 = (datetime.strptime(t, '%H:%M:%S') for t in (t1, t2))
sr = match('\A([-|+]\d+){0}\sat\s(\d+){0}\Z'.format(
'\s(second|minute|hour)s?'), er).groups()
multiplier = {'second': 1, 'minute': 60, 'hour': 3600}
a = int(sr[0]) * multiplier.get(sr[1])
b = int(sr[2]) * multiplier.get(sr[3])
return (s1 + timedelta(seconds=(s2-s1).seconds) * b / (a + b)
).strftime('%H:%M:%S')
Aug. 8, 2015
Comments: