Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
re solution in Clear category for Broken Clock by gyahun_dash
import datetime as dt, re
def broken_clock(start_t, wrong_t, error):
seconds = dict(second=1, minute=60, hour=3600)
regexp = re.compile('(?P[-+]?\d+) (?Psecond|minute|hour)')
digitize = lambda m: int(m.group('value')) * seconds[m.group('unit')]
start, wrong = [dt.datetime.strptime(t, '%X') for t in (start_t, wrong_t)]
error, scale = map(digitize, regexp.finditer(error))
return (start + (wrong - start) * scale / (scale + error)).strftime('%X')
Nov. 18, 2014