40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi,
1. `result` is redundant. You can return the `sorted(...)` directly.
2. `lambda` is redundant. `key=abs` is enough.
Best,
suic
More
Hi,
1. `sum(array) * len(array)` is redundant you can `return 0`.
2. If `array` is not empty then `array[len(array)] == array[-1]`.
More
It's a bit "overlamdized" :)
A small tip:
# Change b, c in a way you don't need to use not
# and then you can write:
return a(data) and b(data) and c(data)
# what you could transform
return all((a(data), b(data), c(data)))
# and finally:
return all(f(data) for
More
Hi, a few things:
1. string is iterable therefore list() is redundant.
2. check str.isupper
3. in python you can write: 'A' <= letter <= 'Z'
More
Hi, two things:
1. Why text[::], why not just text?
2. lambda is redundant:
lambda x: x.isupper()
# is the same as
str.isupper # without ()!
More
Hi, in this case:
lambda l: l.isupper()
# is the same as:
unicode.isupper # without ()!
More
Hi, you could omit the if in lambda:
# 1. using filter()
# 2. or use True == 0 and 0 * string = "":
x * x.isupper()
More
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