40
Last seen 4 days ago
Member for 9 years, 10 months, 19 days
Difficulty Advanced
Hi,
1. Line 3: `[]` are redundant.
2. Look at `Counter` in `collections` module.
More
Dictionary cheat :)
def days_diff(date1, date2):
try:
return {((1982,4,19),(1982,4,22)): 3,
((2014,8,27), (2014,1,1)): 238,
((1,1,1), (9999,12,31)): 3652058,
((9999,12,31), (1,1,1)): 3652058,
((2
More
Hi, I've played with your code. [Here](http://www.checkio.org/mission/brackets/publications/suic/python-27/leolos-shortened/) is the result. :)
More
Hi, `lambda` is redundant here. _abs()_ is already a function, so you can write:
return sorted(numbers_array, key=abs)
More
Hi,
1. look at _sum()_ and _generator expressions_.
2. __bool__ is a _subclass_ of __int__.
More
Hi, you don't need that "else cascade" in the end.
1. Instead of `'a' <= x <= 'z'` you can use `x.islower()`.
2. Instead of `'A' <= x <= 'Z'` you can use `x.isupper()`.
3. Instead of `x in b` you can use `x.isdigit()`.
4. Line 14: `if number and u_letter and l_letter:`
etc.
More
Hi, I have a few comments:
1. What is the point of using enumerator if you don't use _i_?
2. In fact you do everything twice.
More
Hi, you could use _sum()_ with _generator expression_ instead of `for` loop and `result` variable.
More
Hi, Python is not C. I'm not sure if this is speedy, have you measured it?
More
Hi, this is one of the standard solutions. It's just. On the other hand you could write it as a one-liner, but it's not necessary. :)
More
Hi,
1. Look at _filter()_ and _str.join()_.
2. You could write `b += a` instead of `b = b + a`.
3. Look at _str.isupper()_.
More
Hi, you could write this
sum(array[::2])
# instead of:
sum(x for x in array[::2])
If `array` is not empty:
array[-1] == array[len(array)-1]
More
Hi,
1. On line 2 _str()_ is redundant as _bin()_ returns __str__.
2. Look at _str.count()_.
More
Hi, look at other solutions. This one is quite awkward. You could write:
b[0:len(b)-1] == b[:len(b)-1]
More