40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi, one comment: I would replace lines 13-15 with one line:
# You can apply map(int, ) directly on splitted_data
# and use it as argument of date
year, month, day = map(int, splited_data[0].split('-'))
# In fact you can eliminate these these three variables
call_data
More
Hi, comments are fine, but they make the code less readable. Splitting to paragraphs would make it more readable. E. g.:
# To simplify the code, we use a defaultdict of lists that will contain
# one entry per day containing all the minutes used by calls
daily_calls = defaultdict(li
More
Hi, nice solution. There's one thing: As you don't use _time_ variable, you could write:
data, _, seconds = i.split()
More
Hi, it's very easy to read ;) I have two little comments:
1. You don't use the _t_ variable, so you could write:
d, _, s = call.split(' ')
2. But you could use it to reduce duplication:
t = math.ceil(int(s) / 60)
if d not in seconds:
seconds[d] = t
...
More
Or a big one? :D
1. Look at _extended slices_: `array[::2]`
2. _sum()_ built-in function: `sum(array[::2])`
3. You could write `i += 2`
More
Hi, Rodnee is right. You shouldn't forget that
1. __list__ is iterable, therefore `''.join(letters)` on line is redundant.
2. There's a _filter()_ built-in function.
3. __Counter__ is a __dict__.
Then:
~~~
from collections import Counter
def checkio(text):
all_counts = Counter(filter(str.isa
More
Hi,
1. _list()_ is redundant, _sorted()_ works with any iterable.
2. There's a set intersection operator: `&`.
More
Hi, _lambda_ is redundant as _abs()_ is already a function:
return sorted(numbers_array, key=abs)
More
Hi, you can replace `elfis` with `ifs`. As you return in each branch you don't need `elif`.
More
Hi, look at [extended slices](https://docs.python.org/3/whatsnew/2.3.html?highlight=extended%20slices#extended-slices) and slices with negative indices.
More
> (My professor told us about it and we need to get to lv12 for a grade)
That's funny. I've never head a course which would require to play on-line game to get the grade :)
P. S.: Your comment is not [PEP8](https://www.python.org/dev/peps/pep-0008/) compliant. :)
More
Hi, docstring should be right after the function definition. Try this:
>>> def my_function():
... """This is my docstring."""
... return x + y
...
>>> help(my_function)
More