1047. Game time with minutes in python
This is the solution of this problem in python:
h1,m1,h2,m2=input().split()
h1=int(h1)
m1=int(m1)
h2=int(h2)
m2=int(m2)
if(h1>h2):
count_passed_time = (h1*3600)+(m1*60)
count_remain_time1 = (86400-count_passed_time)
count_remain_time2 = (h2*3600)+(m2*60)
count_total_time = count_remain_time1+count_remain_time2
H = count_total_time/3600
count_total_time = count_total_time%3600
M = count_total_time/60
print("O JOGO DUROU %i HORA(S) E %i MINUTO(S)"%(H,M))
elif(h2>h1):
M = (60-m1)+m2
H = h2-(h1+1)
if(M>=60):
Q = M/60
H = H+Q
M = M%60
print("O JOGO DUROU %i HORA(S) E %i MINUTO(S)"%(H,M))
elif(h1==h2):
if(m2>m1):
M=m2-m1
H = 0
elif(m1==m2):
M = 0
H = 24
elif(m1>m2):
count_passed_time = (h1*3600)+(m1*60)
count_remain_time1 = (86400-count_passed_time)
count_remain_time2 = (h2*3600)+(m2*60)
count_total_time = count_remain_time1+count_remain_time2
H = count_total_time/3600
count_total_time = count_total_time%3600
M = count_total_time/60
print("O JOGO DUROU %i HORA(S) E %i MINUTO(S)"%(H,M))
No comments