Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Broken Clock by suic
from time import strftime, gmtime
def broken_clock(t0, tb, err):
conv_dict = {"second": 1, "minute": 60, "hour": 3600,
"seconds": 1, "minutes": 60, "hours": 3600}
nv, nm, _, mv, mm = err.split(" ")
t0, tb = map(to_seconds, (t0, tb))
m = int(mv) * conv_dict[mm]
n = int(nv) * conv_dict[nm]
tw = t0 + (m / (n + m)) * (tb - t0)
return strftime("%H:%M:%S", gmtime(tw))
def to_seconds(t):
return sum([int(v) * (60 ** (2 - int(i)))
for i, v in enumerate(t.split(":"))])
Nov. 18, 2014
Comments: