31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 2 months, 8 days
Difficulty Normal
You can skip parenthesis:
if number % 5 == 0 and number % 3 == 0:
More
**map(int, [n for n in str(number) if n!='0'])** is very bad. You can do it in one pass, just convert to int inside list comprehension.
n0 is bad name for variable. I prefer to use **res** or **result** in such cases.
More
**pr = reduce(...** => **return reduce(...**
you can replace you lambda with **mul** from operator module
More
you can simplify expression: **if product == 0:** => **if product**
you can simplify you code by set product to 1 at line 2.
More
line 3: http://www.checkio.org/forum/post/1618/proper-way-to-check-if-sequence-is-empty/
More
You can omit last argument of reduce.
Pydocs: If the optional initializer is present, it is placed before the items of the iterable in the calculation.
More
you can use builtin function **len** instead of this lambda: **lambda x: len(x)**
see **str.endswith** in python docs
you can throw away lines 2 and 3, because **for i in []** will do no cycles.
More
In line 4-5 you made some checks, but same checks will be done in line 7(inside endswith).
I did not test it but think that removing lines 4-5 will make you code to work faster.
More
you can use builtin function **len** instead of you lambda: **lambda x: len(x)**
removing check at line 2-3 will not affect result.
More
You can replace **frozenset(second.split(','))** with **second.split(',')** it will speedup you code.
More
Theres is function in standard library that do the same as **lambda e: abs(e)** you should use it instead of this lambda.
More
There is function in standard library that do the same as **lambda x: abs(x)** you should use it instead of this lambda.
More
you can iterate over items in list:
output=[numbers_dict[item] for item in numbers_list]
More