31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 2 months, 8 days
Difficulty Normal
**You dont need lambda 1**: just call you code in place
**You dont need lambda 2** push = stack.appned
More
Python have frozenset, it is exacly what you need. Same as set, but hashable and immutable. It is best way in current case, becuase it interacts with other sets.
Other solution is to use tuple. It is hashable too. **"%s:%s"** -> **(a, b)**. And sort it just before convertation: tuple(sorted(conne
More
String are too hot for this just [freeze set](https://docs.python.org/2/library/stdtypes.html#frozenset).
Empty string after methods looks ugly.
https://docs.python.org/2/tutorial/datastructures.html#sets
Similarly to list comprehensions, set comprehensions are also supported:
>>> a
More
No need braces on line 5
_placements is same as permutation
_all_possible_scores return tuple of two args, but second is not used
comment in line 23 can be placed in docstring
**have_seen_equivalent_for** return True or None
generator expression is too huge
More
\# in real life use module re
This life is quite real :)
https://docs.python.org/2/library/stdtypes.html#str.isalpha
No need to add branch with nothing.
else: # optionnal
continue # explicitly do nothing
You can use enumerate instead of range.
More
You solution is potentialy wrong.
In precondition: string.ascii_letters + **string.punctuation**
Your **".,;:?!"** is not cover all punctuation
You can simplify you code by using None as split separator (https://docs.python.org/2/library/stdtypes.html#str.split)
You can zip message and scores. Or
More
You call key twice on each compare.
So you will have issue in certain cases: (key=next)
You need only one call per item.
flexible_reduce is just proxy for call another function, you can remove it.
More
If you can import you can use https://docs.python.org/2/library/heapq.html#heapq.nlargest
import are prohibited by description "Some builtin functions are closed here: import, ..." You use issue in task checker for your solution.
More
oh, so complex
you know there is only two items, so map(sub(...)) can be simplified
days_diff=lambda *a: abs(operator.sub(*map(datetime.date, *zip(*a))).days)
do you know about starmap?
from itertools import starmap
days_diff=lambda *a: abs(operator.sub(*starmap(datetime.date, a)).da
More
It is not fits to clear.
You can throw away you **re.sub** and use **str.replace**.
More
Some notes about style:
no need parenthesis and you miss space after coma
return ",".join(phrases).replace("right", "left")
More
See comments [here](http://www.checkio.org/mission/secret-message/publications/theholy7/python-3/first/)
More
> \# This one use ()
Tuple? Or unnercessary parenthesis?
This comment is confusing.
More