python counter转dict_关于Dict(),Counter()踩过的一点坑

本文讨论了如何在Python中将Counter对象转换为dict,并在计费算法中应用这一转换。通过示例解释了在处理电话通话记录时,如何计算每日通话费用,包括遇到的坑和解决方案,如使用dict.get()、Counter和defaultdict。
摘要由CSDN通过智能技术生成

首先上题目,题目思路很简单,乍看一下也是很好解决,但是在解题的过程中还是遇到不少坑,Python虽然轮子多,但是坑也不少。

这里简单反思一下解题过程中,遇到的各种各样的坑。

The bill is represented as an array with information about the calls. Help Nicola to calculate the cost for each of Sophia calls. Each call is represented as a string with date, time and duration of the call in seconds in the follow format:

"YYYY-MM-DD hh:mm:ss duration"

The date and time in this information are the start of the call.

Space-Time Communications Co. has several rules on how to calculate the cost of calls:

First 100 (one hundred) minutes in one day are priced at 1 coin per minute;

After 100 minutes in one day, each minute costs 2 coins per minute;

All calls are rounded up to the nearest minute. For example 59 sec ≈ 1 min, 61 sec ≈ 2 min;

Calls count on the day when they began. For example if a call was started 2014-01-01 23

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值