Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
ceil from math and groupby from itertools solution in Clear category for Call to Home by Oleg_Domokeev
from math import ceil
from itertools import groupby
def total_cost(calls):
# list of [date, call in tariff minutes] for iach call
calls_min = [[call[0], ceil(int(call[2]) / 60)] for call in [call.split() for call in calls]]
# list of total minutes a day
minutes = [sum([elem[1] for elem in g]) for k, g in groupby(calls_min, lambda call: call[0])]
return sum(map(lambda x: x * (x <= 100) + (2 * x - 100) * (x > 100), minutes))
Sept. 10, 2018
Comments: