Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
9-liner: o'clock solution in Clear category for Broken Clock by przemyslaw.daniel
from datetime import datetime
def broken_clock(starting_time, wrong_time, error_description):
ft = lambda x: datetime.strptime(x, '%H:%M:%S')
mt = lambda x: {'second': 1, 'minute': 60, 'hour': 3600}[x.rstrip('s')]
tm, ed = ft(wrong_time) - ft(starting_time), error_description.split()
d1, d2 = int(ed[0])*mt(ed[1]), int(ed[3])*mt(ed[4])
return (tm*d2/(d1+d2)+ft(starting_time)).strftime('%H:%M:%S')
Dec. 30, 2016
Comments: