11
Last seen 3 years ago
Member for 8 years, 8 months, 19 days
Difficulty Normal
why we need to use copy at 6th line?
I tried both (use copy and not) at this question, and both are work.
Could someone explain the difference?
More
### note:
```python
a or 1 == a if a != 0 else 1
```
More
replace
new = sorted(data)
by
data.sort()
so that, you could not to use "new" variable
More
you use ord() in order to check whether it is lower alphabetic,
and maybe you could use
```
import string
for c in text.lower():
if c in string.ascii_lowercase:
......
```
More
My code is very similiar to yours.But I use **accumulate(count(1))** instead of **count(1)**.
from itertools import count, accumulate
def checkio(food):
for pigeon in accumulate(count(1)):
if food < pigeon:
return max(feeded, food)
food -= pig
More
line 6~9
duration = duration // 60 + 1 if duration % 60 else duration // 60
Moreover, use **ceil** function in **math** module
from math import ceil
duration = ceil(duration/60)
More
line 11~14
1.use **get** method
data[d] = data.get(d, 0) + duration
2.**collections.defaultdict**
from collections import defaultdict as ddict
data = ddict(int)
# ~~~
data[d] += duration
More
the same one line code
Instead of using reduce function, I write a recursion function.
```python
checkio = lambda n: (n%10 or 1)*checkio(n//10) if n else 1
```
more explain:
> ( a or 1 ) == ( a if a != 0 else 1 )
### some question:
when i solve question on ckeckio,
sometimes, I don't know whethe
More