• Don't understand how calc seconds.

Question related to mission Call to Home

 

If there were two calls in day, for example - 4500 and 1800, How do calc bill? 4500/60 + 1500/60 + (1800-1500)/60= 75 + 25 + 5*2 = 110, is it correct?

My code:

def total_cost(bills):
    bill_dict={}
    for days in bills:
        days=days.split(" ")
        if days[0] in bill_dict.keys():
            bill_dict[days[0]].append(days[2])
        else:
            bill_dict[days[0]]=[days[2]]
    print(bill_dict)
    answer=0
    for key in bill_dict.keys():
        money_day=0
        duration_day=0
        for duration in bill_dict[key]:
            if duration_day+int(duration) <=6000:
                money_day+=int(duration)//60 + min(1,int(duration)%60)
               # print(money_day)
            if duration_day + int(duration) > 6000:
                cache=max(0,6000 - duration_day)
                money_day+=cache//60
                money_day+=(int(duration)-cache)//60 * 2 + 2*min(1,(int(duration)-cache)%60)

                #print(int(duration),money_day,cache)
            duration_day+=int(duration)
        print(key,duration_day,bill_dict[key], money_day)

        bill_dict[key].append(money_day)
        answer+=money_day

    print(answer,bill_dict)
    return answer

I fail on test: total_cost(["2054-07-17 10:21:08 1958","2054-07-17 16:17:18 1388","2054-07-18 00:30:57 729","2054-07-18 03:55:30 4970","2054-07-18 23:10:05 5397","2054-07-19 16:37:31 5894","2054-07-20 11:21:10 2537","2054-07-20 17:09:49 4398","2054-07-21 04:17:34 2839","2054-07-21 06:23:25 6229","2054-07-21 10:21:01 4540","2054-07-21 22:10:46 5599","2054-07-22 11:26:43 6199","2054-07-23 02:02:52 818","2054-07-23 14:30:19 3244","2054-07-23 20:46:25 380","2054-07-24 08:41:40 4774","2054-07-24 23:33:14 5206","2054-07-25 08:47:44 3848","2054-07-25 11:32:40 694","2054-07-25 18:28:25 5974","2054-07-26 09:24:52 4550","2054-07-26 13:06:07 6637","2054-07-27 09:03:40 177","2054-07-27 13:11:42 5736","2054-07-27 15:53:26 5698","2054-07-28 09:51:43 1996","2054-07-28 14:03:30 432"]) My answer - 2378