import sys
def get_bigger(time1,time2):
for i in range(3):
if time1[i] > time2[i]:
return time1,time2
elif time1[i] < time2[i]:
return time2,time1
return time1,time2
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
timestamp=test.split()
time1=map(int,timestamp[0].split(":"))
time2=map(int,timestamp[1].split(":"))
time1,time2=get_bigger(time1,time2)
val=[0]*3
for i in range(2,-1,-1):
val[i]=time1[i]-time2[i]
if val[i] < 0:
if i > 0 :
val[i] += 60
time1[i-1] -= 1
else:
val[i] += 24
sol=""
for i in range(3):
if i > 0:
sol += ":"
sol += str(val[i]).zfill(2)
print sol
test_cases.close()
def get_bigger(time1,time2):
for i in range(3):
if time1[i] > time2[i]:
return time1,time2
elif time1[i] < time2[i]:
return time2,time1
return time1,time2
test_cases = open(sys.argv[1], 'r')
for test in test_cases:
timestamp=test.split()
time1=map(int,timestamp[0].split(":"))
time2=map(int,timestamp[1].split(":"))
time1,time2=get_bigger(time1,time2)
val=[0]*3
for i in range(2,-1,-1):
val[i]=time1[i]-time2[i]
if val[i] < 0:
if i > 0 :
val[i] += 60
time1[i-1] -= 1
else:
val[i] += 24
sol=""
for i in range(3):
if i > 0:
sol += ":"
sol += str(val[i]).zfill(2)
print sol
test_cases.close()
No comments:
Post a Comment