Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Broken Clock by StanislauL
calc = {'sec': 1, 'min': 60, 'hou': 3600}
from datetime import datetime, timedelta
import math
def broken_clock(s_t, w_t, e_d):
start = datetime.strptime(s_t, '%H:%M:%S')
wrong = datetime.strptime(w_t, '%H:%M:%S')
err = e_d.split()
c1 = int(err[0]) * calc[err[1][:3]]
c2 = int(err[3]) * calc[err[4][:3]]
tmp = math.ceil((wrong - start).seconds/(c2 + c1) * c1)
wrong-=timedelta(seconds = tmp)
return str(wrong).split()[-1]
Feb. 14, 2018
Comments: