Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Call to Home by TovarischZhukov
from datetime import datetime
def total_cost(calls):
curr_date=None
total=0
for call in calls:
call=call.split(" ")
call_date=datetime.strptime(call[0],"%Y-%m-%d")
dur=int(call[2])
if dur > 60:
if dur%60:
dur=dur/60+1
else:
dur=dur/60
else:
dur=1
if call_date != curr_date:
mday=0
curr_date=call_date
per1=dur
per2=0
if (mday+dur)>100:
if mday<100:
per1=100-mday
per2=dur-per1
else:
per1=0
per2=dur
total+= per1+2*per2
mday+=dur
return total
Dec. 20, 2015